When you run the packer build
command, give it the -on-error=ask
flag.
By default, packer build
will delete the resource group as soon as the build fails.
-on-error=ask
will pause it and wait for your input so you have time to remote in to the VM and diagnose the failure.
When the build fails, you will see this:
At the beginning of the build log (written to console), find the resource group name for the VM:
Log into the Azure Portal. Find that resource group under Resource groups
. You should see the resources for the Packer build:
Select the VM in the resource group. Click Connect:
This will download an RDP file. Open that and enter the credentials found in the JSON file you pass to packer build
: