actions / runner-images

GitHub Actions runner images
MIT License
10.02k stars 3.03k forks source link

Windows 2022 - cannot run az cli tasks - "az.cmd" cloud set -n AzureCloud fails #10178

Closed rzand closed 3 months ago

rzand commented 3 months ago

Description

The windows 2022 image cannot complete a task that uses az cli to create a resource group. This error is similar to the one mentioned at https://github.com/actions/runner-images/issues/2329

Output from an Azure DevOps agent running on the July 1 windows 2022 image:

C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" --version" azure-cli 2.61.0

core 2.61.0 telemetry 1.1.0

Extensions: azure-devops Unknown

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Program Files\Common Files\AzureCliExtensionDirectory'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date. Setting AZURE_CONFIG_DIR env variable to: C:\a_temp.azclitask Setting active cloud to: AzureCloud C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" cloud set -n AzureCloud" ERROR: The command failed with an unexpected error. Here is the traceback:

[error]Error Code: [1]

ERROR: [WinError 5] Access is denied: 'C:\Program Files\Common Files\AzureCliExtensionDirectory\azure-devops\azure_devops-1.0.1.dist-info' Traceback (most recent call last):

[error]Script failed with error: ERROR: The command failed with an unexpected error. Here is the traceback:

ERROR: [WinError 5] Access is denied: 'C:\Program Files\Common Files\AzureCliExtensionDirectory\azure-devops\azure_devops-1.0.1.dist-info' Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 518, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/init.py", line 479, in load_command_table File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/init.py", line 336, in _update_command_table_from_extensions File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/extension/init.py", line 157, in get_metadata File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\pkginfo/wheel.py", line 16, in init File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\pkginfo/distribution.py", line 115, in extractMetadata File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\pkginfo/wheel.py", line 33, in read PermissionError: [WinError 5] Access is denied: 'C:\Program Files\Common Files\AzureCliExtensionDirectory\azure-devops\azure_devops-1.0.1.dist-info' To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Platforms affected

Runner images affected

Image version and build link

Azure DevOps windows 2022 July 1 image

Is it regression?

no

Expected behavior

execute the az cloud set -n AzureCloud command without errors

Actual behavior

Receiving the error: C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" cloud set -n AzureCloud" ERROR: The command failed with an unexpected error. Here is the traceback:

[error]Error Code: [1]

ERROR: [WinError 5] Access is denied: 'C:\Program Files\Common Files\AzureCliExtensionDirectory\azure-devops\azure_devops-1.0.1.dist-info' Traceback (most recent call last):

[error]Script failed with error: ERROR: The command failed with an unexpected error. Here is the traceback:

ERROR: [WinError 5] Access is denied: 'C:\Program Files\Common Files\AzureCliExtensionDirectory\azure-devops\azure_devops-1.0.1.dist-info' Traceback (most recent call last):

Repro steps

Create and run the image via pipeline on a private subnet:

            packer build -var "subscription_id=$(SubscriptionId)" `
              -var "tenant_id=$(TenantId)" `
              -var "client_id=$(ClientId)" `
              -var "client_secret=$(ClientSecret)" `
              -var "install_password=$(InstallPassword)" `
              -var "build_resource_group_name=$(ImageBuildResourceGroupName)" `
              -var "managed_image_name=$(ImageName)" `
              -var "managed_image_resource_group_name=$(ImageResourceGroupName)" `
              -var "virtual_network_resource_group_name=$(VNET_RG_NAME)" `
              -var "virtual_network_name=$(VNET_NAME)" `
              -var "virtual_network_subnet_name=$(SUBNET_NAME)" `
              -var 'azure_tags={"Application":"ado-agents","ManagedWith":"terraform","SupportedBy":"itops"}' `
              -on-error="abort" `
              $(TemplatePath)
RaviAkshintala commented 3 months ago

@rzand Thank you for bringing this issue to us. We are looking into this issue and will update you on this issue after investigating.

rzand commented 3 months ago

I solved this problem by unticking the agent pool setting named "Configure VMs to run interactive tests" as per https://github.com/actions/runner-images/issues/1682