Closed ahsonkhan closed 1 month ago
@ahsonkhan - Thank you for bringing this issue to us. We are investigating on this issue , and will get back to you after our findings.
@ahsonkhan - Can you please execute az logout first and try again az login and I would suggest you to set default subscription by executing az account set -s "Subscription ID"
@ahsonkhan - Can you please update us if you have tried the above steps.
@ahsonkhan - Thank you, as there is no response on this ticket, I will be closing this ticket. Please re-open another ticket if you face the related error.
Description
From https://github.com/Azure/azure-sdk-for-cpp/pull/5800 The az cli and AzureCliCredential work as expected on Ubuntu, but the same sample and
az account get-access-token
command fails on Windows, with an error asking to re-runaz login
.However, the cli task already successfully ran az login:
And subsequent runs of
az account show
andaz account list
also work as expected. It seems like there is an issue with the az cli config and login context.There is a difference of behavior between Windows and Ubuntu when it comes to the AzureCLI@2 task and the az cli command line.
Windows (fails)
Ubuntu (works)
1) The CI machine images have different settings. On Windows, AZURE_CONFIG_DIR env var is set to C:\azureCli, whereas on Ubuntu that env var isn’t set. The fact that this env var is set on Windows is preventing az cli from getting the login context. 2) I am not sure how
useGlobalConfig
is supposed to work to make sure the machine and the az cli task all use the same login context on Windows. It seems like when that is set to false (default), the azure-pipelines-task sets theAZURE_CONFIG_DIR
env var to a temp directory. https://github.com/microsoft/azure-pipelines-tasks/blob/1e374b1730e8d81a6ba2e733048fa061b410a642/Tasks/AzureCLIV2/azureclitask.ts#L247-L259 3) For az cli to work as expected on Ubuntu, the cli task needsuseGlobalConfig:true
(which results inAZURE_CONFIG_DIR
not being present at all). On Windows, whetheruseGlobalConfig
is set or not,az account get-access-token ...
fails with the az login error ("ERROR: Please run 'az login' to setup account.”). From the table below, the only scenario that works as expected is green. I can’t get Windows to be green regardless of setting.C:\azureCli
D:\a\_work\_temp\.azclitask
mnt/vss/_work/_temp/.azclitask
Only when
useGlobalConfig:true
does manually setting AZURE_CONFIG_DIR take effect. Trying to set it to some value, as per the documentation, to isolate the az cli config and context, doesn’t work. WithuseGlobalConfig:false
, manually settingAZURE_CONFIG_DIR
is ignored. I don’t understand this behavior and it doesn’t seem to be documented anywhere.I am not sure why az cli fails and is unable to honor the
useGlobalConfig:true
flag on Windows. I also don’t know how to unset theAZURE_CONFIG_DIR
prior to theAzureCLI@2
task starts in the yaml (to match the behavior I am seeing on Ubuntu), nor whether that would bring parity of behavior between Ubuntu/Windows. Setting it to an empty string ('') causes the AzDo task to fail since that isn’t a valid path value.Image Version: https://github.com/actions/runner-images/blob/win19/20240707.1/images/windows/Windows2019-Readme.md
C++ sample being run: https://github.com/ahsonkhan/azure-sdk-for-cpp/blob/4f087568210ba32878d58e26a7dbb7b9eebdb2b7/sdk/keyvault/azure-security-keyvault-keys/samples/sample1-hello-world/sample1_hello_world.cpp#L27
This is the task: https://github.com/ahsonkhan/azure-sdk-for-cpp/blob/4f087568210ba32878d58e26a7dbb7b9eebdb2b7/eng/pipelines/templates/jobs/live.tests.yml#L247C5-L287C49
Related issue: https://github.com/microsoft/azure-pipelines-tasks/issues/20167
Platforms affected
Runner images affected
Image version and build link
https://github.com/ahsonkhan/azure-sdk-for-cpp/blob/4f087568210ba32878d58e26a7dbb7b9eebdb2b7/eng/pipelines/templates/jobs/live.tests.yml#L247C5-L287C49
Image Version: https://github.com/actions/runner-images/blob/win19/20240707.1/images/windows/Windows2019-Readme.md
Agent name: 'azsdk-pool-mms-win-2019-general 1' Agent machine name: '503a4e48c000000' Current agent version: '3.241.0' Operating System Runner Image 1ES Hosted Pool Current image version: '20240707.1.0'
Is it regression?
No
Expected behavior
On Ubuntu, basic hello world sample which uses AzureCliCredential works to fetch an access token when
az account get-access-token ...
is run https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3965291&view=logs&j=ea109acd-b7d3-5ded-4f2b-e0ac8b0c5651&t=82c3d730-b00d-5c6a-3ffd-b86aefe48338Actual behavior
On Windows, basic hello world sample which uses AzureCliCredential fails with error asking to run
az login
. https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3965291&view=logs&j=4dce5c19-e405-5fa0-33da-8863256ab80c&t=69517a0c-c3cc-5eee-5bb1-071e8e1abea9Repro steps
https://github.com/ahsonkhan/azure-sdk-for-cpp/blob/4f087568210ba32878d58e26a7dbb7b9eebdb2b7/eng/pipelines/templates/jobs/live.tests.yml#L247C5-L287C49