azure-cli: `az container create` fails with `AttributeError: 'ResourcesOperations' object has no attribute 'create_or_update'`

Describe the bug

Command Name az container create

Errors:

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'ResourcesOperations' object has no attribute 'create_or_update'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/custom.py", line 113, in create_container
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/container/custom.py", line 407, in _create_update_from_file
AttributeError: 'ResourcesOperations' object has no attribute 'create_or_update'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

- task: AzureCLI@2
  inputs:
    azureSubscription: ...
    scriptType: pscore
    scriptLocation: inlineScript
    inlineScript: |
	  az group create --location LOCATION --name RG_NAME
	  az container create -g RG_NAME -n ACI_NAME -f aci.yml

Expected Behavior

Environment Summary

Azure DevOps hosted agent: windows-2019

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

core                              2.24.0
telemetry                          1.0.6

Extensions:
azure-devops                      0.18.0

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

Python (Windows) 3.8.9 (tags/v3.8.9:a743f81, Apr  6 2021, 13:22:56) [MSC v.1928 32 bit (Intel)]

Additional Context

This was working on 2021-05-27 with 2.23.0, and started failing on 2021-05-28 with 2.24.0

Note that I started getting an error with az container exec a few days ago, but now I’m not even getting that far, and it’s failing on az container create instead.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Ubuntu hosted agents were updated to azure-cli 2.24.0 today. You can add the following bash script to your DevOps release pipeline to install 2.24.2 with the above hotfix:

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Its a bug in version 2.24.0 that is fixed in 2.24.2. and since you cant upgrade the Azure CLI yourself… only options, is to wait for ms to upgrade the Azure cli version or to deploy the container from a remote machine. What i did to get arround the bug was to.:

1.) Download/Installe the Az module on a local machin with powershell installed : https://aka.ms/installazurecliwindows 2.) From Powershell do a .: [PS] az login 3,) Followin that, and having the .yml file locally you can deploy the container : (i use a command like below) [PS] az container create --resource-group RG_ABC --file deploy.yml

(maybe this can help someone)

@zhoxing-ms Thank you! We have tried it and it works!

@gpatkos This release has completed in CloudShell, please have a try~

@gpatkos OK, it will be released over the weekend if there are no issues