actions / runner-images

GitHub Actions runner images
MIT License
9.79k stars 3k forks source link

[BUG]: AzureCLI@2 task - Behavioral difference between Windows and Ubuntu when trying useGlobalConfig resulting in az login error #10246

Closed ahsonkhan closed 1 month ago

ahsonkhan commented 1 month ago

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-run az login.

However, the cli task already successfully ran az login:

C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" login --service-principal -u --tenant --allow-no-subscriptions --federated-token ***"

And subsequent runs of az account show and az 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)

knack.util.CLIError: Please run 'az login' to setup account.

Ubuntu (works)

[2024-07-16T09:27:14.3542439Z T: 140439931482368] INFO : Identity: DefaultAzureCredential: Successfully got token from AzureCliCredential. This credential will be reused for subsequent calls.

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 the AZURE_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 needs useGlobalConfig:true (which results in AZURE_CONFIG_DIR not being present at all). On Windows, whether useGlobalConfig 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.

I got Ubuntu to work (with useGlobalConfig: true), but can't get Windows to work with any setting. useGlobalConfig:true useGlobalConfig:false
Windows AZURE_CONFIG_DIR is set to C:\azureCli AZURE_CONFIG_DIR is set to D:\a\_work\_temp\.azclitask
Ubuntu AZURE_CONFIG_DIR is not present (i.e. not set to anything) AZURE_CONFIG_DIR is set to 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. With useGlobalConfig:false, manually setting AZURE_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 the AZURE_CONFIG_DIR prior to the AzureCLI@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.

FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

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-b86aefe48338

2024-07-16T09:27:05.3419561Z **********Running sample: /mnt/vss/_work/1/s/build/sdk/keyvault/azure-security-keyvault-keys/samples/sample1-hello-world/sample1-hello-world
2024-07-16T09:27:05.3461351Z [2024-07-16T09:27:05.3458609Z T: 139856026943744] INFO  : Identity: AzureCliCredential created.
2024-07-16T09:27:05.3483483Z Successful creation does not guarantee further successful token retrieval.
2024-07-16T09:27:05.8508803Z [2024-07-16T09:27:05.8502918Z T: 139856026943744] WARN  : Identity: AzureCliCredential !!! AZ VERSION !!! azure-cli                         2.62.0
2024-07-16T09:27:05.8511091Z 
2024-07-16T09:27:05.8514820Z core                              2.62.0
2024-07-16T09:27:05.8515816Z telemetry                          1.1.0
2024-07-16T09:27:05.8516542Z 
2024-07-16T09:27:05.8517582Z Dependencies:
2024-07-16T09:27:05.8519593Z msal                              1.28.1
2024-07-16T09:27:05.8520931Z azure-mgmt-resource               23.1.1
2024-07-16T09:27:05.8521713Z 
2024-07-16T09:27:05.8522889Z Python location '/opt/az/bin/python3'
2024-07-16T09:27:05.8533921Z Extensions directory '/home/cloudtest/.azure/cliextensions'
2024-07-16T09:27:05.8534422Z 
2024-07-16T09:27:05.8535119Z Python (Linux) 3.11.8 (main, Jul  4 2024, 02:23:43) [GCC 9.4.0]
2024-07-16T09:27:05.8553292Z 
2024-07-16T09:27:05.8554078Z Legal docs and information: aka.ms/AzureCliLegal
2024-07-16T09:27:05.8619245Z 
2024-07-16T09:27:05.8623833Z 
2024-07-16T09:27:05.8628689Z Your CLI is up-to-date.
2024-07-16T09:27:05.8633844Z [2024-07-16T09:27:05.8503400Z T: 139856026943744] WARN  : Identity: AzureCliCredential !!! aaa AZURE_CONFIG_DIR !!! not set
2024-07-16T09:27:06.3019008Z [2024-07-16T09:27:06.3014580Z T: 139856026943744] WARN  : Identity: AzureCliCredential !!! AZ account show !!! {
2024-07-16T09:27:06.3020615Z   "environmentName": "AzureCloud",
2024-07-16T09:27:06.3022042Z   "homeTenantId": "***",
2024-07-16T09:27:06.3023213Z   "id": "***",
2024-07-16T09:27:06.3024036Z   "isDefault": true,
2024-07-16T09:27:06.3024611Z   "managedByTenants": [],
2024-07-16T09:27:06.3025264Z   "name": "***",
2024-07-16T09:27:06.3025818Z   "state": "Enabled",
2024-07-16T09:27:06.3045806Z   "tenantId": "***",
2024-07-16T09:27:06.3046595Z   "user": {
2024-07-16T09:27:06.3047443Z     "name": "***",
2024-07-16T09:27:06.3048078Z     "type": "servicePrincipal"
2024-07-16T09:27:06.3048674Z   }
2024-07-16T09:27:06.3049213Z }
2024-07-16T09:27:06.4963360Z DEBUG: cli.knack.cli: Command arguments: ['account', 'list', '--debug']
2024-07-16T09:27:06.4965078Z DEBUG: cli.knack.cli: __init__ debug log:
2024-07-16T09:27:06.4966112Z Cannot enable color.
2024-07-16T09:27:06.4966879Z DEBUG: cli.knack.cli: Event: Cli.PreExecute []
2024-07-16T09:27:06.4967904Z DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f7cb689c040>, <function OutputProducer.on_global_arguments at 0x7f7cb683e200>, <function CLIQuery.on_global_arguments at 0x7f7cb687bce0>]
2024-07-16T09:27:06.4976380Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
2024-07-16T09:27:06.4982585Z DEBUG: cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource']
2024-07-16T09:27:06.4983873Z DEBUG: cli.azure.cli.core: Loading command modules:
2024-07-16T09:27:06.4984668Z DEBUG: cli.azure.cli.core: Name                  Load Time    Groups  Commands
2024-07-16T09:27:06.5001510Z DEBUG: cli.azure.cli.core: profile                   0.002         2         8
2024-07-16T09:27:06.5985452Z DEBUG: cli.azure.cli.core: resource                  0.098        51       231
2024-07-16T09:27:06.5986985Z DEBUG: cli.azure.cli.core: Total (2)                 0.100        53       239
2024-07-16T09:27:06.5987846Z DEBUG: cli.azure.cli.core: Loaded 52 groups, 239 commands.
2024-07-16T09:27:06.5988613Z DEBUG: cli.azure.cli.core: Found a match in the command table.
2024-07-16T09:27:06.5989324Z DEBUG: cli.azure.cli.core: Raw command  : account list
2024-07-16T09:27:06.5990069Z DEBUG: cli.azure.cli.core: Command table: account list
2024-07-16T09:27:06.5991038Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f7cb5936980>]
2024-07-16T09:27:06.5993346Z DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/cloudtest/.azure/commands/2024-07-16.09-27-06.account_list.16551.log'.
2024-07-16T09:27:06.5994577Z INFO: az_command_data_logger: command args: account list --debug
2024-07-16T09:27:06.5995616Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f7cb596f9c0>]
2024-07-16T09:27:06.6007124Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
2024-07-16T09:27:06.6008304Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f7cb5982c00>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f7cb5982d40>]
2024-07-16T09:27:06.6016400Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
2024-07-16T09:27:06.6017344Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
2024-07-16T09:27:06.6021592Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f7cb683e2a0>, <function CLIQuery.handle_query_parameter at 0x7f7cb687bd80>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f7cb5982ca0>]
2024-07-16T09:27:06.6027739Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x7f7cb596fe20>, <function _x509_from_base64_to_hex_transform at 0x7f7cb596fec0>]
2024-07-16T09:27:06.6030629Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnFilterResult []
2024-07-16T09:27:06.6034654Z DEBUG: cli.knack.cli: Event: Cli.SuccessfulExecute []
2024-07-16T09:27:06.6035634Z DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f7cb5936c00>]
2024-07-16T09:27:06.6036520Z INFO: az_command_data_logger: exit code: 0
2024-07-16T09:27:06.6037799Z INFO: cli.__main__: Command ran in 0.281 seconds (init: 0.174, invoke: 0.108)
2024-07-16T09:27:06.6799098Z INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
2024-07-16T09:27:06.6800324Z INFO: telemetry.client: Accumulated 0 events. Flush the clients.
2024-07-16T09:27:06.6801235Z INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
2024-07-16T09:27:06.6802169Z INFO: telemetry.save: Save telemetry record of length 3610 in cache
2024-07-16T09:27:06.6803300Z INFO: telemetry.main: Begin creating telemetry upload process.
2024-07-16T09:27:06.6804920Z INFO: telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /home/cloudtest/.azure"
2024-07-16T09:27:06.6814543Z INFO: telemetry.process: Return from creating process
2024-07-16T09:27:06.6815475Z INFO: telemetry.main: Finish creating telemetry upload process.
2024-07-16T09:27:06.7577468Z [2024-07-16T09:27:06.7526205Z T: 139856026943744] WARN  : Identity: AzureCliCredential !!! AZ account list !!! [
2024-07-16T09:27:06.7578760Z   {
2024-07-16T09:27:06.7579352Z     "cloudName": "AzureCloud",
2024-07-16T09:27:06.7638362Z     "homeTenantId": "***",
2024-07-16T09:27:06.7639188Z     "id": "***",
2024-07-16T09:27:06.7639772Z     "isDefault": ***,
2024-07-16T09:27:06.7640272Z     "managedByTenants": [],
2024-07-16T09:27:06.7640812Z     "name": "Storage Zonal DNS Testing",
2024-07-16T09:27:06.7641592Z     "state": "Enabled",
2024-07-16T09:27:06.7642291Z     "tenantId": "***",
2024-07-16T09:27:06.7642804Z     "user": {
2024-07-16T09:27:06.7643468Z       "name": "***",
2024-07-16T09:27:06.7643991Z       "type": "servicePrincipal"
2024-07-16T09:27:06.7644493Z     }
...
...
2024-07-16T09:27:06.7764520Z   {
2024-07-16T09:27:06.7765036Z     "cloudName": "AzureCloud",
2024-07-16T09:27:06.7765816Z     "homeTenantId": "***",
2024-07-16T09:27:06.7766550Z     "id": "***",
2024-07-16T09:27:06.7767197Z     "isDefault": ***,
2024-07-16T09:27:06.7767761Z     "managedByTenants": [],
2024-07-16T09:27:06.7768480Z     "name": "AML - Experiences - Build",
2024-07-16T09:27:06.7769117Z     "state": "Enabled",
2024-07-16T09:27:06.7769936Z     "tenantId": "***",
2024-07-16T09:27:06.7770486Z     "user": {
2024-07-16T09:27:06.7771387Z       "name": "***",
2024-07-16T09:27:06.7771944Z       "type": "servicePrincipal"
2024-07-16T09:27:06.7772501Z     }
2024-07-16T09:27:06.7772998Z   }
2024-07-16T09:27:06.7773725Z ]
2024-07-16T09:27:06.7774904Z [2024-07-16T09:27:06.7526601Z T: 139856026943744] WARN  : Identity: AzureCliCredential !!! AZURE_CONFIG_DIR !!! not set
2024-07-16T09:27:06.9303718Z DEBUG: cli.knack.cli: Command arguments: ['account', 'get-access-token', '--debug', '--verbose', '--output', 'json', '--scope', '***']
2024-07-16T09:27:06.9305107Z DEBUG: cli.knack.cli: __init__ debug log:
2024-07-16T09:27:06.9305896Z Cannot enable color.
2024-07-16T09:27:06.9307057Z DEBUG: cli.knack.cli: Event: Cli.PreExecute []
2024-07-16T09:27:06.9308203Z DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fdb86d4c040>, <function OutputProducer.on_global_arguments at 0x7fdb86cf2200>, <function CLIQuery.on_global_arguments at 0x7fdb86b07ce0>]
2024-07-16T09:27:06.9313914Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
2024-07-16T09:27:06.9319807Z DEBUG: cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource']
2024-07-16T09:27:06.9320723Z DEBUG: cli.azure.cli.core: Loading command modules:
2024-07-16T09:27:06.9321462Z DEBUG: cli.azure.cli.core: Name                  Load Time    Groups  Commands
2024-07-16T09:27:06.9337798Z DEBUG: cli.azure.cli.core: profile                   0.002         2         8
2024-07-16T09:27:07.0296498Z DEBUG: cli.azure.cli.core: resource                  0.096        51       231
2024-07-16T09:27:07.0297706Z DEBUG: cli.azure.cli.core: Total (2)                 0.097        53       239
2024-07-16T09:27:07.0298701Z DEBUG: cli.azure.cli.core: Loaded 52 groups, 239 commands.
2024-07-16T09:27:07.0299460Z DEBUG: cli.azure.cli.core: Found a match in the command table.
2024-07-16T09:27:07.0300455Z DEBUG: cli.azure.cli.core: Raw command  : account get-access-token
2024-07-16T09:27:07.0301358Z DEBUG: cli.azure.cli.core: Command table: account get-access-token
2024-07-16T09:27:07.0302226Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fdb85dea980>]
2024-07-16T09:27:07.0303528Z DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/cloudtest/.azure/commands/2024-07-16.09-27-07.account_get-access-token.16561.log'.
2024-07-16T09:27:07.0304696Z INFO: az_command_data_logger: command args: account get-access-token --debug --verbose --output {} --scope {}
2024-07-16T09:27:07.0305700Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fdb85e1f9c0>]
2024-07-16T09:27:07.0319595Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
2024-07-16T09:27:07.0320745Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fdb85e36c00>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fdb85e36d40>]
2024-07-16T09:27:07.0329278Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
2024-07-16T09:27:07.0330065Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
2024-07-16T09:27:07.0336247Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fdb86cf22a0>, <function CLIQuery.handle_query_parameter at 0x7fdb86b07d80>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fdb85e36ca0>]
2024-07-16T09:27:07.0410290Z DEBUG: cli.azure.cli.core.auth.persistence: build_persistence: location='/home/cloudtest/.azure/service_principal_entries.json', encrypt=False
2024-07-16T09:27:07.0411847Z DEBUG: cli.azure.cli.core.auth.persistence: build_persistence: location='/home/cloudtest/.azure/msal_token_cache.json', encrypt=False
2024-07-16T09:27:07.0415691Z DEBUG: cli.azure.cli.core.auth.binary_cache: load: /home/cloudtest/.azure/msal_http_cache.bin
2024-07-16T09:27:07.0419007Z DEBUG: urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
2024-07-16T09:27:07.0420524Z INFO: msal.authority: Initializing with Entra authority: ***/***
2024-07-16T09:27:07.0430328Z DEBUG: msal.authority: openid_config("***/***/v2.0/.well-known/openid-configuration") = {'token_endpoint': '***/***/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': '***/***/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': '***/***/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': '***/***/oauth2/v2.0/authorize', 'device_authorization_endpoint': '***/***/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': '***/***/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': '***/***/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
2024-07-16T09:27:07.0432407Z DEBUG: msal.application: Broker enabled? None
2024-07-16T09:27:07.0433108Z DEBUG: cli.azure.cli.core.auth.msal_authentication: ServicePrincipalCredential.get_token: scopes=('***',), kwargs={}
2024-07-16T09:27:07.0433761Z DEBUG: msal.telemetry: Generate or reuse correlation_id: ***
2024-07-16T09:27:07.0440854Z DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): ***:443
2024-07-16T09:27:07.4581524Z DEBUG: urllib3.connectionpool: ***:443 "POST /***/oauth2/v2.0/token HTTP/1.1" 200 1456
2024-07-16T09:27:07.4595342Z DEBUG: msal.token_cache: event={
2024-07-16T09:27:07.4596328Z     "client_id": "***",
2024-07-16T09:27:07.4597368Z     "data": {
2024-07-16T09:27:07.4598066Z         "claims": "{\"access_token\": {\"xms_cc\": {\"values\": [\"CP1\"]}}}",
2024-07-16T09:27:07.4598706Z         "scope": [
2024-07-16T09:27:07.4599121Z             "***"
2024-07-16T09:27:07.4600795Z         ]
2024-07-16T09:27:07.4601428Z     },
2024-07-16T09:27:07.4603422Z     "environment": "***",
2024-07-16T09:27:07.4604310Z     "grant_type": "client_credentials",
2024-07-16T09:27:07.4605021Z     "params": null,
2024-07-16T09:27:07.4605591Z     "response": {
2024-07-16T09:27:07.4606272Z         "access_token": "********",
2024-07-16T09:27:07.4606959Z         "expires_in": 86399,
2024-07-16T09:27:07.4607650Z         "ext_expires_in": 86399,
2024-07-16T09:27:07.4608363Z         "refresh_in": 43199,
2024-07-16T09:27:07.4609099Z         "token_type": "Bearer"
2024-07-16T09:27:07.4609779Z     },
2024-07-16T09:27:07.4610312Z     "scope": [
2024-07-16T09:27:07.4610818Z         "***"
2024-07-16T09:27:07.4611271Z     ],
2024-07-16T09:27:07.4611984Z     "token_endpoint": "***/***/oauth2/v2.0/token"
2024-07-16T09:27:07.4612491Z }
2024-07-16T09:27:07.4613325Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x7fdb85e1fe20>, <function _x509_from_base64_to_hex_transform at 0x7fdb85e1fec0>]
2024-07-16T09:27:07.4614171Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnFilterResult []
2024-07-16T09:27:07.4614738Z DEBUG: cli.knack.cli: Event: Cli.SuccessfulExecute []
2024-07-16T09:27:07.4615335Z DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fdb85deac00>]
2024-07-16T09:27:07.4615925Z INFO: az_command_data_logger: exit code: 0
2024-07-16T09:27:07.4616470Z INFO: cli.__main__: Command ran in 0.683 seconds (init: 0.151, invoke: 0.531)
2024-07-16T09:27:07.5471634Z INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
2024-07-16T09:27:07.5472818Z INFO: telemetry.client: Accumulated 0 events. Flush the clients.
2024-07-16T09:27:07.5473726Z INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
2024-07-16T09:27:07.5474605Z INFO: telemetry.save: Save telemetry record of length 3659 in cache
2024-07-16T09:27:07.5476486Z INFO: telemetry.main: Begin creating telemetry upload process.
2024-07-16T09:27:07.5478230Z INFO: telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/__init__.py /home/cloudtest/.azure"
2024-07-16T09:27:07.5484834Z INFO: telemetry.process: Return from creating process
2024-07-16T09:27:07.5485814Z INFO: telemetry.main: Finish creating telemetry upload process.
2024-07-16T09:27:07.6053958Z [2024-07-16T09:27:07.6046737Z T: 139856026943744] INFO  : HTTP Request : POST ***keys/CloudRsaKey1a44d3b8-ab39-4715-b450-08a9b3fa7a7b/create?api-version=7.5
2024-07-16T09:27:07.6055990Z authorization : REDACTED
2024-07-16T09:27:07.6057094Z content-type : application/json
2024-07-16T09:27:07.6058196Z user-agent : azsdk-cpp-keyvault-keys/4.5.0-beta.3 (Linux 5.15.0-1068-azure x86_64 #77~20.04.1-Ubuntu SMP Fri Jun 21 22:05:38 UTC 2024)
...
...
2024-07-16T09:27:12.3868583Z [2024-07-16T09:27:12.3852398Z T: 139856026943744] INFO  : HTTP Request : DELETE ***deletedkeys/CloudRsaKey1a44d3b8-ab39-4715-b450-08a9b3fa7a7b?api-version=7.5
2024-07-16T09:27:12.3869246Z authorization : REDACTED
2024-07-16T09:27:12.3870005Z user-agent : azsdk-cpp-keyvault-keys/4.5.0-beta.3 (Linux 5.15.0-1068-azure x86_64 #77~20.04.1-Ubuntu SMP Fri Jun 21 22:05:38 UTC 2024)
2024-07-16T09:27:12.3870750Z x-ms-client-request-id : c21ff832-3172-449b-97d6-e07bfa401db4
2024-07-16T09:27:12.3871500Z [2024-07-16T09:27:12.3852803Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: Creating a new session.
2024-07-16T09:27:12.3872344Z [2024-07-16T09:27:12.3853437Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: Re-using connection from the pool.
2024-07-16T09:27:12.3873160Z [2024-07-16T09:27:12.3853879Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: No Host in request headers. Adding it
2024-07-16T09:27:12.3873953Z [2024-07-16T09:27:12.3854254Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: Send request without payload
2024-07-16T09:27:12.3874998Z [2024-07-16T09:27:12.3855067Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: Parse server response
2024-07-16T09:27:12.4826060Z [2024-07-16T09:27:12.4822961Z T: 139856026943744] DEBUG : [CURL Transport Adapter]: Request completed. Moving response out of session and session to response.
2024-07-16T09:27:12.4827794Z [2024-07-16T09:27:12.4823462Z T: 139856026943744] DEBUG : Moving connection to pool...
2024-07-16T09:27:12.4829369Z [2024-07-16T09:27:12.4823799Z T: 139856026943744] DEBUG : Clean thread running. Won't start a new one.
2024-07-16T09:27:12.4830685Z [2024-07-16T09:27:12.4824248Z T: 139856026943744] INFO  : HTTP/1.1 Response (97ms) : 204 No Content
2024-07-16T09:27:12.4831618Z cache-control : no-cache
2024-07-16T09:27:12.4832315Z date : Tue, 16 Jul 2024 09:27:12 GMT
2024-07-16T09:27:12.4832940Z expires : -1
2024-07-16T09:27:12.4833557Z pragma : no-cache
2024-07-16T09:27:12.4834322Z strict-transport-security : REDACTED
2024-07-16T09:27:12.4834990Z x-content-type-options : REDACTED
2024-07-16T09:27:12.4835761Z x-ms-client-request-id : c21ff832-3172-449b-97d6-e07bfa401db4
2024-07-16T09:27:12.4836478Z x-ms-keyvault-network-info : REDACTED
2024-07-16T09:27:12.4837138Z x-ms-keyvault-region : REDACTED
2024-07-16T09:27:12.4837820Z x-ms-keyvault-service-version : REDACTED
2024-07-16T09:27:12.4838594Z x-ms-request-id : 2234ae72-544e-4000-b6ed-06eb923af9ef
2024-07-16T09:27:12.4839522Z [2024-07-16T09:27:12.4824667Z T: 139856026943744] INFO  : HTTP status code 204 won't be retried.
2024-07-16T09:27:12.4866038Z **********Sample completed

Actual 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-071e8e1abea9

2024-07-16T09:42:47.4639749Z **********Running sample: D:/a/_work/1/s/build/sdk/keyvault/azure-security-keyvault-keys/samples/sample1-hello-world/Release/sample1-hello-world.exe
2024-07-16T09:42:47.4739361Z [2024-07-16T09:42:47.4734829Z T: 5644] INFO  : Identity: AzureCliCredential created.
2024-07-16T09:42:47.4741271Z Successful creation does not guarantee further successful token retrieval.
2024-07-16T09:42:49.3058137Z [2024-07-16T09:42:49.3053995Z T: 5644] WARN  : Identity: AzureCliCredential !!! AZ VERSION !!! WARNING: You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'
2024-07-16T09:42:49.3059723Z 
2024-07-16T09:42:49.3060858Z azure-cli                         2.61.0 *
2024-07-16T09:42:49.3061535Z 
2024-07-16T09:42:49.3063187Z 
2024-07-16T09:42:49.3063837Z 
2024-07-16T09:42:49.3065059Z core                              2.61.0 *
2024-07-16T09:42:49.3065789Z 
2024-07-16T09:42:49.3066774Z telemetry                          1.1.0
2024-07-16T09:42:49.3067190Z 
2024-07-16T09:42:49.3067497Z 
2024-07-16T09:42:49.3067760Z 
2024-07-16T09:42:49.3068325Z Dependencies:
2024-07-16T09:42:49.3068652Z 
2024-07-16T09:42:49.3069227Z msal                              1.28.0
2024-07-16T09:42:49.3069550Z 
2024-07-16T09:42:49.3070115Z azure-mgmt-resource               23.1.1
2024-07-16T09:42:49.3070438Z 
2024-07-16T09:42:49.3070692Z 
2024-07-16T09:42:49.3070937Z 
2024-07-16T09:42:49.3071580Z Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
2024-07-16T09:42:49.3071970Z 
2024-07-16T09:42:49.3072827Z Extensions directory 'C:\Users\cloudtest\.azure\cliextensions'
2024-07-16T09:42:49.3073232Z 
2024-07-16T09:42:49.3073494Z 
2024-07-16T09:42:49.3073784Z 
2024-07-16T09:42:49.3074494Z Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb  6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]
2024-07-16T09:42:49.3074947Z 
2024-07-16T09:42:49.3075194Z 
2024-07-16T09:42:49.3075493Z 
2024-07-16T09:42:49.3076137Z Legal docs and information: aka.ms/AzureCliLegal
2024-07-16T09:42:49.3076623Z 
2024-07-16T09:42:49.3076894Z 
2024-07-16T09:42:49.3077151Z 
2024-07-16T09:42:49.3077412Z 
2024-07-16T09:42:49.3077676Z 
2024-07-16T09:42:49.3078439Z [2024-07-16T09:42:49.3054911Z T: 5644] WARN  : Identity: AzureCliCredential !!! aaa AZURE_CONFIG_DIR !!! not set
2024-07-16T09:43:23.3620603Z [2024-07-16T09:43:23.3616140Z T: 5644] WARN  : Identity: AzureCliCredential !!! AZ account show !!! ERROR: Please run 'az login' to setup account.
2024-07-16T09:43:23.3628069Z 
2024-07-16T09:43:23.7304283Z [2024-07-16T09:43:23.7299483Z T: 5644] WARN  : Identity: AzureCliCredential !!! AZ account list !!! DEBUG: cli.knack.cli: Command arguments: ['account', 'list', '--debug']
2024-07-16T09:43:23.7305648Z 
2024-07-16T09:43:23.7306571Z [2024-07-16T09:43:23.7300464Z T: 5644] WARN  : Identity: AzureCliCredential !!! AZURE_CONFIG_DIR !!! not set
2024-07-16T09:43:24.3693274Z [2024-07-16T09:43:24.3687551Z T: 5644] DEBUG : Identity: TokenCredentialImpl::ParseToken(): Cannot parse the string 'DEBUG: cli.knack.cli: Command arguments: ['account', 'get-access-token', '--debug', '--verbose', '--output', 'json', '--scope', '***']
2024-07-16T09:43:24.3694465Z 
2024-07-16T09:43:24.3695311Z DEBUG: cli.knack.cli: __init__ debug log:
2024-07-16T09:43:24.3695696Z 
2024-07-16T09:43:24.3696359Z Cannot enable color.
2024-07-16T09:43:24.3698306Z 
2024-07-16T09:43:24.3699272Z DEBUG: cli.knack.cli: Event: Cli.PreExecute []
2024-07-16T09:43:24.3699664Z 
2024-07-16T09:43:24.3700617Z DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x000001AE784DB880>, <function OutputProducer.on_global_arguments at 0x000001AE786660C0>, <function CLIQuery.on_global_arguments at 0x000001AE78693C40>]
2024-07-16T09:43:24.3701356Z 
2024-07-16T09:43:24.3702038Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
2024-07-16T09:43:24.3702432Z 
2024-07-16T09:43:24.3703239Z DEBUG: cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource']
2024-07-16T09:43:24.3703815Z 
2024-07-16T09:43:24.3704495Z DEBUG: cli.azure.cli.core: Loading command modules:
2024-07-16T09:43:24.3704875Z 
2024-07-16T09:43:24.3705542Z DEBUG: cli.azure.cli.core: Name                  Load Time    Groups  Commands
2024-07-16T09:43:24.3705934Z 
2024-07-16T09:43:24.3706586Z DEBUG: cli.azure.cli.core: profile                   0.002         2         8
2024-07-16T09:43:24.3706953Z 
2024-07-16T09:43:24.3707527Z DEBUG: cli.azure.cli.core: resource                  0.109        51       231
2024-07-16T09:43:24.3708176Z 
2024-07-16T09:43:24.3709179Z DEBUG: cli.azure.cli.core: Total (2)                 0.112        53       239
2024-07-16T09:43:24.3709683Z 
2024-07-16T09:43:24.3710438Z DEBUG: cli.azure.cli.core: Loaded 52 groups, 239 commands.
2024-07-16T09:43:24.3710857Z 
2024-07-16T09:43:24.3711603Z DEBUG: cli.azure.cli.core: Found a match in the command table.
2024-07-16T09:43:24.3712079Z 
2024-07-16T09:43:24.3712814Z DEBUG: cli.azure.cli.core: Raw command  : account get-access-token
2024-07-16T09:43:24.3713227Z 
2024-07-16T09:43:24.3713899Z DEBUG: cli.azure.cli.core: Command table: account get-access-token
2024-07-16T09:43:24.3714311Z 
2024-07-16T09:43:24.3715076Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001AE7A256340>]
2024-07-16T09:43:24.3715641Z 
2024-07-16T09:43:24.3716537Z DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\cloudtest\.azure\commands\2024-07-16.09-43-24.account_get-access-token.5152.log'.
2024-07-16T09:43:24.3717373Z 
2024-07-16T09:43:24.3718188Z INFO: az_command_data_logger: command args: account get-access-token --debug --verbose --output {} --scope {}
2024-07-16T09:43:24.3718708Z 
2024-07-16T09:43:24.3719583Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x000001AE7A2927A0>]
2024-07-16T09:43:24.3720339Z 
2024-07-16T09:43:24.3721056Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
2024-07-16T09:43:24.3721502Z 
2024-07-16T09:43:24.3722458Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x000001AE7A2BC7C0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x000001AE7A2BC900>]
2024-07-16T09:43:24.3723216Z 
2024-07-16T09:43:24.3723974Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
2024-07-16T09:43:24.3724457Z 
2024-07-16T09:43:24.3725192Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
2024-07-16T09:43:24.3725644Z 
2024-07-16T09:43:24.3726713Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001AE78666160>, <function CLIQuery.handle_query_parameter at 0x000001AE78693CE0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x000001AE7A2BC860>]
2024-07-16T09:43:24.3727555Z 
2024-07-16T09:43:24.3728326Z DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
2024-07-16T09:43:24.3728793Z 
2024-07-16T09:43:24.3729601Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
2024-07-16T09:43:24.3730142Z 
2024-07-16T09:43:24.3730979Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 664, in execute
2024-07-16T09:43:24.3731549Z 
2024-07-16T09:43:24.3732411Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
2024-07-16T09:43:24.3733044Z 
2024-07-16T09:43:24.3733893Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 701, in _run_job
2024-07-16T09:43:24.3734480Z 
2024-07-16T09:43:24.3735238Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 334, in __call__
2024-07-16T09:43:24.3735837Z 
2024-07-16T09:43:24.3736760Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
2024-07-16T09:43:24.3737428Z 
2024-07-16T09:43:24.3738352Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/profile/custom.py", line 78, in get_access_token
2024-07-16T09:43:24.3738883Z 
2024-07-16T09:43:24.3739556Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 385, in get_raw_token
2024-07-16T09:43:24.3740033Z 
2024-07-16T09:43:24.3740726Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 569, in get_subscription
2024-07-16T09:43:24.3741193Z 
2024-07-16T09:43:24.3741840Z knack.util.CLIError: Please run 'az login' to setup account.
2024-07-16T09:43:24.3742225Z 
2024-07-16T09:43:24.3742487Z 
2024-07-16T09:43:24.3742738Z 
2024-07-16T09:43:24.3743403Z ERROR: cli.azure.cli.core.azclierror: Please run 'az login' to setup account.
2024-07-16T09:43:24.3743803Z 
2024-07-16T09:43:24.3744459Z ERROR: az_command_data_logger: Please run 'az login' to setup account.
2024-07-16T09:43:24.3744850Z 
2024-07-16T09:43:24.3745583Z DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001AE7A2565C0>]
2024-07-16T09:43:24.3746207Z 
2024-07-16T09:43:24.3746737Z INFO: az_command_data_logger: exit code: 1
2024-07-16T09:43:24.3747092Z 
2024-07-16T09:43:24.3747664Z INFO: cli.__main__: Command ran in 0.485 seconds (init: 0.299, invoke: 0.185)
2024-07-16T09:43:24.3748058Z 
2024-07-16T09:43:24.3748610Z INFO: cli.azure.cli.core.decorators: Suppress exception:
2024-07-16T09:43:24.3748979Z 
2024-07-16T09:43:24.3749469Z Traceback (most recent call last):
2024-07-16T09:43:24.3749908Z 
2024-07-16T09:43:24.3750541Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/__main__.py", line 62, in <module>
2024-07-16T09:43:24.3750993Z 
2024-07-16T09:43:24.3751618Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/__main__.py", line 55, in <module>
2024-07-16T09:43:24.3752068Z 
2024-07-16T09:43:24.3752525Z SystemExit: 1
2024-07-16T09:43:24.3752824Z 
2024-07-16T09:43:24.3752993Z 
2024-07-16T09:43:24.3753248Z 
2024-07-16T09:43:24.3753895Z During handling of the above exception, another exception occurred:
2024-07-16T09:43:24.3754292Z 
2024-07-16T09:43:24.3754555Z 
2024-07-16T09:43:24.3754804Z 
2024-07-16T09:43:24.3755381Z Traceback (most recent call last):
2024-07-16T09:43:24.3755709Z 
2024-07-16T09:43:24.3756445Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/decorators.py", line 79, in _wrapped_func
2024-07-16T09:43:24.3756923Z 
2024-07-16T09:43:24.3757662Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 112, in generate_payload
2024-07-16T09:43:24.3758136Z 
2024-07-16T09:43:24.3758883Z   File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/telemetry.py", line 159, in _get_base_properties
2024-07-16T09:43:24.3759367Z 
2024-07-16T09:43:24.3760009Z AttributeError: 'NoneType' object has no attribute 'isatty'
2024-07-16T09:43:24.3760321Z 
2024-07-16T09:43:24.3760632Z 
2024-07-16T09:43:24.3760953Z 
2024-07-16T09:43:24.3761675Z INFO: telemetry.main: Split cli events and extra events failure: the JSON object must be str, bytes or bytearray, not NoneType
2024-07-16T09:43:24.3762044Z 
2024-07-16T09:43:24.3762649Z ' as JSON.
2024-07-16T09:43:24.3763235Z Authentication Exception happened:
2024-07-16T09:43:24.3764037Z AzureCliCredential didn't get the token: "DEBUG: cli.knack.cli: Command arguments: ['account', 'get-access-token', '--debug', '--verbose', '--output', 'json', '--scope', '***']
2024-07-16T09:43:24.3764490Z 
2024-07-16T09:43:24.3765133Z DEBUG: cli.knack.cli: __init__ debug log:
2024-07-16T09:43:24.3765433Z 
2024-07-16T09:43:24.3766034Z Cannot enable color.
2024-07-16T09:43:24.3766311Z 
2024-07-16T09:43:24.3766898Z DEBUG: cli.knack.cli"
2024-07-16T09:43:24.3767735Z [2024-07-16T09:43:24.3689090Z T: 5644] WARN  : Identity: AzureCliCredential didn't get the token: "DEBUG: cli.knack.cli: Command arguments: ['account', 'get-access-token', '--debug', '--verbose', '--output', 'json', '--scope', '***']
2024-07-16T09:43:24.3768291Z 
2024-07-16T09:43:24.3768952Z DEBUG: cli.knack.cli: __init__ debug log:
2024-07-16T09:43:24.3769247Z 
2024-07-16T09:43:24.3769842Z Cannot enable color.
2024-07-16T09:43:24.3770114Z 
2024-07-16T09:43:24.3770706Z DEBUG: cli.knack.cli"
2024-07-16T09:43:24.3771267Z Sample failed with exit code 1
2024-07-16T09:43:24.3786368Z 
2024-07-16T09:43:24.4074145Z ##[error]Script failed with exit code: 1
2024-07-16T09:43:24.4272049Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" account clear"
2024-07-16T09:43:25.6952529Z ##[section]Finishing: Run Samples with AzureCli for : keyvault

Repro steps

https://github.com/ahsonkhan/azure-sdk-for-cpp/blob/4f087568210ba32878d58e26a7dbb7b9eebdb2b7/eng/pipelines/templates/jobs/live.tests.yml#L247C5-L287C49

- task: AzureCLI@2
      displayName: "Run Samples with AzureCli for : ${{ parameters.ServiceDirectory }}"
      condition: and(succeeded(), eq(variables['RunSamples'], '1'))
      inputs:
        azureSubscription: ${{ parameters.CloudConfig.ServiceConnection }}
        scriptType: 'pscore'
        scriptLocation: 'inlineScript'
        inlineScript: |
          Write-Host "Where is az CLI located"
          (Get-Command az).Path
          Write-Host "Check az CLI version"
          az --version
          Write-Host "Run az account show"
          az account show
          Write-Host "Run az account list --debug"
          az account list --debug
          Write-Host "Run az account get-access-token --output none --debug --verbose"
          az account get-access-token --output none --debug --verbose
          Write-Host "Run env:AZURE_CONFIG_DIR"
          $env:AZURE_CONFIG_DIR
          Write-Host "Remove env:AZURE_CONFIG_DIR"
          $env:AZURE_CONFIG_DIR=''
          Write-Host "Run Get-ChildItem env:"
          Get-ChildItem env:
          if (Test-Path -Path "${{ parameters.ServiceDirectory }}-samples.txt") {
            $samples = Get-Content "${{ parameters.ServiceDirectory }}-samples.txt"
            foreach ($sample in $samples) {
              Write-Host "**********Running sample: $sample"
              & "$sample"
              if ($LASTEXITCODE) {
                Write-Host "Sample failed with exit code $LASTEXITCODE"
                exit 1
              }
              Write-Host "**********Sample completed"
            }
          }
        workingDirectory: build
        useGlobalConfig: true
      env:
        # SYSTEM_ACCESSTOKEN: $(System.AccessToken)
        ${{ insert }}: ${{ parameters.EnvVars }}
ijunaidm commented 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.

ijunaidm commented 1 month ago

@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"

ijunaidm commented 1 month ago

@ahsonkhan - Can you please update us if you have tried the above steps.

ijunaidm commented 1 month ago

@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.