How do I force Packer to use Azure client secret in GitHub Actions workflow?

HOW TO -️ October 18, 2021

I use the following yml workflow in GitHub:

ERROR Rendering Code Block

The Azure service principal credentials are stored as GitHub repository secrets. I can successfully build the image from my local machine using the same credentials as zsh environment variables:

ERROR Rendering Code Block

However, in the GitHub workflow, Packer tries to use Managed Identity, instead of the service principal and fails with the following error message:

ERROR Rendering Code Block

Answer

I think I need to declare the variables in the Packer template so I can set them using the -var argument when calling packer build.

Initializing...