azure-cli
azure-cli copied to clipboard
Not able to run azure cli tasks in ADO jobs
Hi, Since last 3 hours, I was not able to run any azure-cli tasks using build pipelines. All were failing with the below issue:
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" login --identity
##[error]Error Code: [1] ##[error]Error: Azure login failed using Managed Service Identity ##[error]Script failed with error: UnexpectedError: The command failed with an unexpected error. Here is the traceback:
However, I was able to run the same commands directly by logging into the azure cloud shell.
Please let me know any resolution for this issue:
Error Log:
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" login --identity" UnexpectedError: The command failed with an unexpected error. Here is the traceback:
Traceback (most recent call last): File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-tuw8_17y\knack\cli.py", line 215, in invoke File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init_.py", line 654, in execute File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init_.py", line 718, in run_jobs_serially File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 711, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-cpn0gwyu\six.py", line 703, in reraise File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 688, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 325, in call File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core_init_.py", line 784, in default_command_handler File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-s56abhv8\azure\cli\command_modules\profile\custom.py", line 136, in login File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core_profile.py", line 346, in find_subscriptions_in_vm_with_msi File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 592, in init File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 600, in set_token File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 649, in get_token File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 704, in _retrieve_token_from_imds_with_retry requests.exceptions.HTTPError To open an issue, please run: 'az feedback' ##[error]Error Code: [1] ##[error]Error: Azure login failed using Managed Service Identity ##[error]Script failed with error: UnexpectedError: The command failed with an unexpected error. Here is the traceback:
Traceback (most recent call last): File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-tuw8_17y\knack\cli.py", line 215, in invoke File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init_.py", line 654, in execute File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init_.py", line 718, in run_jobs_serially File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 711, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-cpn0gwyu\six.py", line 703, in reraise File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 688, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core\commands_init.py", line 325, in call File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core_init_.py", line 784, in default_command_handler File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-s56abhv8\azure\cli\command_modules\profile\custom.py", line 136, in login File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-v8nptj_b\azure\cli\core_profile.py", line 346, in find_subscriptions_in_vm_with_msi File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 592, in init File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 600, in set_token File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 649, in get_token File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-unpacked-wheel-x2czgqpp\msrestazure\azure_active_directory.py", line 704, in _retrieve_token_from_imds_with_retry requests.exceptions.HTTPError To open an issue, please run: 'az feedback'
Finishing: Install Custom Extension
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.
devops
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.
Any update on this? I still see all my builds failing with the same error as above.
Same here, trying to use the Azure CLI task in combination with a service connection that uses a managed identity on subscription level. I've set up the service connection as a user with the "Contributor" role, so I don't have write access on the active directory. Is this relevant?
Have encountered same issue:
Setting AZURE_CONFIG_DIR env variable to: /home/vsts/work/_temp/.azclitask
Setting active cloud to: AzureCloud
/usr/bin/az cloud set -n AzureCloud
/usr/bin/az login --identity
ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.
Get Token request returned http error: 400, reason: Bad Request
##[error]Error Code: [1]
##[error]Error: Azure login failed using Managed Service Identity
##[error]Script failed with error: ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.
Get Token request returned http error: 400, reason: Bad Request
The pipeline code:
- task: AzureCLI@2
displayName: 'Push Docker Image to ACR'
inputs:
azureSubscription: XXX
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az acr login --name abc
docker push abc.azurecr.io/xyz:1.33.0
E,xactly what I am getting. Has anyone found the root cause of this?
/usr/bin/az login --identity -u '<my id>'
ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.
Get Token request returned http error: 400, reason: Bad Request
##[error]Error Code: [1]
##[error]Error: Azure login failed using Managed Service Identity
##[error]Script failed with error: ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.
Get Token request returned http error: 400, reason: Bad Request