I tried to create an image using a sample packer build which was violated by policy network interface cannot have public ip
The error is as below .
" Build 'azure-arm' errored after 1 minute 33 seconds: deployments.DeploymentsClient#Validate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidTemplateDeployment" Message="The template deployment failed because of policy violation. Please see details for more information." Details=[{"additionalInfo":[{"info":{"evaluationDetails":{"evaluatedExpressions":[{"expression":"type","expressionKind":"Field","expressionValue":"Microsoft.Network/networkInterfaces","operator":"Equals","path":"type","res ult":"True"
please find the packer template as below
{
"builders": [
{
"name": "image",
"type": "azure-arm",
"os_disk_size_gb": "256",
"vm_size": "Standard_F8s_v2",
"managed_image_storage_account_type": "Standard_LRS",
"client_id": "xxxxxxxxxxxxxxxxxxx",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"subscription_id": "xxxxxxxxxxxxxxxxxxxxxxxx",
"object_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"managed_image_name": "mypackerimage",
"managed_image_resource_group_name": "resource_group_name",
"build_resource_group_name": "rg",
"virtual_network_name": "VizDev-AzureDevOps-vnet",
"virtual_network_resource_group_name": "VizDev-AzureDevOps",
"virtual_network_subnet_name": "default",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2022-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_username": "packer"
}
],
"provisioners": [
{
"type": "shell",
"script": "./provisioning-script.sh"
},
{
"type": "powershell",
"inline": [
"Write-Output 'Hello, Packer!'"
]
}
]
}
It depends on what you have in your configuration file. Yes, but it can be customized. Please check docs:
You have to specify
virtual_network_resource_group_name,virtual_network_nameandvirtual_network_subnet_nameto create VM without public IP.Example: