azure-cli: "az container delete" fails due to 'ContainerGroupsOperations' object has no attribute 'delete'
Describe the bug
Since docker image azure-cli:2.28.0
I get the following error when executing
az container delete --resource-group any-rg --name any-name
The same command works fine if it’s running with azure-cli:2.27.2
.
Command Name
az container delete
Errors:
The command failed with an unexpected error. Here is the traceback:
'ContainerGroupsOperations' object has no attribute 'delete'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
raise ex
File "/usr/local/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/local/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
result = cmd_copy(params)
File "/usr/local/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
return self.handler(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/usr/local/lib/python3.9/site-packages/azure/cli/command_modules/container/custom.py", line 66, in delete_container
return client.delete(resource_group_name, name)
AttributeError: 'ContainerGroupsOperations' object has no attribute 'delete'
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Put any pre-requisite steps here…
az container delete --resource-group {} --name {}
Expected Behavior
Environment Summary
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with, Alpine Linux v3.14
Python 3.9.6
Installer: DOCKER
azure-cli 2.28.0
Additional Context
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 17 (2 by maintainers)
This issue will be fixed in version 2.29.0, which should be available by October 12th. You can find manual upgrade instructions here.
ADO AzureCLI task is locked into this latest version and causing issues elsewhere.
This appears to have been updated over the weekend in the GitHub Actions Windows 2019 image. Until this is fixed, all of our CI builds will fail and leave dangling docker images.
Where possible we replaced the cli command
az container delete
with PowerShellRemove-AzContainerGroup
as a temporary workaround.Ref. https://docs.microsoft.com/en-us/powershell/module/az.containerinstance/remove-azcontainergroup?view=azps-6.4.0
Better workaround (relies on Docker) that is cross-platform:
Use the 2.27.2 Azure CLI Docker container
Now proceed to run whatever you wanted to run
If you installed with
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
per here, then workaround with:Then find your
2.72.2
version with:Then install with, e.g:
Worked for me ✅