Packer template for Azure VM created in Private Subnet without Public IP


Packer temporary virtual machine:

  1. Must be placed in pre-defined Azure VNet’s Subnet (instead of default temporary VNet and Subnet created by Packer)
  2. Must have Private IP only (instead of defaults with Public IP)



Network-related Packer options

virtual_network_name option enables private communication with the VM, no public IP address is used or provisioned
virtual_network_resource_group_name option specify the resource group containing the virtual network
virtual_network_subnet_name option specify Subnet from virtual_network_name the virtual network

Execution environment

Azure DevOps is recommended to execute Packer based on pipeline
Pipeline supports Pull requests verification and provisioning based on commit to mainline
Azure DevOps agent must have access to the virtual network that is used for VM provisioning
Azure DevOps agent must have installed Ansible version 2.5.15 because of winrm communicator

If Packer is executed locally variables must be specified, e.g.:
packer build -force -var "project=ere" -var "environment=sbx" -var "subscription_id=b31bc8ae-8938-41f1-b0b2-f707d811d596" ./template.json