hashicorp / packer-plugin-azure

Packer plugin for Azure Virtual Machine Image Builders
https://www.packer.io/docs/builders/azure
Mozilla Public License 2.0
50 stars 78 forks source link

az account-get-acccess-token fails #434

Open Binternet opened 1 month ago

Binternet commented 1 month ago

Overview of the Issue

I am using azure-cli to as the auth procedure.

yet az get-access-token fails due to unknown --scope argument

Reproduction Steps

run packer build with azure-arm builder using the same versions which I use.

Plugin and Packer version

packer v1.11.1 [go1.21.10 windows amd64 azure-plugin v2.1.7_x5.0_windows_amd64

Operating system and Environment details

Windows OS, Architecture, and any other information you can provide about the environment.

Log Fragments and crash.log files

machine readable: azure-arm.example, error []string{"running azure CLI: exit status 2: ERROR: unrecognized arguments: --scope https://management.azure.com/.default\r\n\r\nTRY THIS:\r\nhttps://aka.ms/cli_ref\r\nRead more about the command in the reference docs"}

JenGoldstrich commented 2 weeks ago

Hey @Binternet I was unable to reproduce this, I tried both the latest versions of packer and the Azure plugin and the ones you specified, on Windows (10) using powershell and cmd. I was able to successfully build Azure packer templates using CLI auth.

What is the terminal environment this is running in? (Powershell, cmd, etc), and can I get the output of your build with the environment variable PACKER_LOG set to 1 (this enables verbose logging)

Could you also run az account get-access-token --scope https://management.azure.com/.default --tenant your-tenant-id -o=json from the same terminal session and let me know if that works and returns a token?

The current version of the Azure CLI definitely supports the scope argument, but maybe there's a weird parsing issue happening with that argument (since it includes the scope url (the argument's value) in the error message 🤔