New issue checklist
Task name
AzureCLI
Task version
2
Issue Description
From Azure/azure-sdk-for-cpp#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.
- 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.
- 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.
|
private static setConfigDirectory(): void { |
|
if (tl.getBoolInput("useGlobalConfig")) { |
|
return; |
|
} |
|
|
|
if (!!tl.getVariable('Agent.TempDirectory')) { |
|
var azCliConfigPath = path.join(tl.getVariable('Agent.TempDirectory'), ".azclitask"); |
|
console.log(tl.loc('SettingAzureConfigDir', azCliConfigPath)); |
|
process.env['AZURE_CONFIG_DIR'] = azCliConfigPath; |
|
} else { |
|
console.warn(tl.loc('GlobalCliConfigAgentVersionWarning')); |
|
} |
|
} |
- 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
Environment type (Please select at least one enviroment where you face this issue)
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
Version: 20240707.1.0
Operation system
Windows 2019, Windows 2022, Ubuntu 20.04
Relevant log output
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
Full task logs with system.debug enabled
No response
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 }}
Related issue: actions/runner-images#10246
New issue checklist
Task name
AzureCLI
Task version
2
Issue Description
From Azure/azure-sdk-for-cpp#5800
The az cli and AzureCliCredential work as expected on Ubuntu, but the same sample and
az account get-access-tokencommand 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 showandaz account listalso 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)
useGlobalConfigis 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_DIRenv var to a temp directory.azure-pipelines-tasks/Tasks/AzureCLIV2/azureclitask.ts
Lines 247 to 259 in 1e374b1
useGlobalConfig:true(which results inAZURE_CONFIG_DIRnot being present at all). On Windows, whetheruseGlobalConfigis 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.
C:\azureCliD:\a\_work\_temp\.azclitaskmnt/vss/_work/_temp/.azclitaskOnly when
useGlobalConfig:truedoes 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_DIRis 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:trueflag on Windows. I also don’t know how to unset theAZURE_CONFIG_DIRprior to theAzureCLI@2task 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
Environment type (Please select at least one enviroment where you face this issue)
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
Version: 20240707.1.0
Operation system
Windows 2019, Windows 2022, Ubuntu 20.04
Relevant log output
Full task logs with system.debug enabled
No response
Repro steps
Related issue: actions/runner-images#10246