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


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


The code can be found on my Github account at

To clone the repository:

git clone


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:

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


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.