Christof VG

You don't need to come out of your comfort zone, if automation is in it!

pfSense on Azure - Part 4 - Deploy pfSense in Azure with ARM templates

Read time: 5 minutes
Execution time: 5 minutes

Series overview

Introduction

After publishing part 1 through 3, someone brought to my attention that I should do the deployment using ARM templates instead of using PowerShell. This is completely true, so I created the necessary ARM templates to deploy the exact same environment. I made use of a main template that gathers all parameters and creates all resource groups. It also deploys 4 linked templates:

  • virtualNetwork.json: Deploys the virtual network and subnets
  • managedDisk.json: Deploys a managed disk from the uploaded VHD
  • pfSense.json: Deploys an instance of pfSense, attaching the managed disk
  • managementVM.json: Deploys a management VM to access and configure the pfSense instance

    Code

The code can be found on my Github account at https://github.com/christofvg/AzurePfSense.

To clone the repository:

1
git clone https://github.com/christofvg/AzurePfSense.git

Deployment

The deployment is completely configured using the azuredeploy.parameters.json file. All parameters are available in that file except for 2 parameters that should be passed during the deployment as they should not be entered in source control.

  • vhdStorageAccountName: Name of the storage account where the vhd file is stored
  • managementVmAdminPassword: Management virtual machine password

To deploy the template using PowerShell:

1
New-AzureRmDeployment -Location <location> -TemplateFile <path to azuredeploy.json> -TemplateParameterFile <path to azuredeploy.parameters.json> -vhdStorageAccountName <storageAccountName> -managementVmAdminPassword <password> -Verbose

Conclusion

Using ARM templates, a deployment is done in a few minutes with a single command. Very suitable for deployments that need to be redeployed often. This is specially the case in lab environments.