Reputation: 31
I run the following "az container delete" on old cli version successfully. However, when I upgraded to 2.28.0, it failed with error
az container delete --subscription xx --resource-group xx --name xx
Errors:
The command failed with an unexpected error. Here is the traceback:
'ContainerGroupsOperations' object has no attribute 'delete'
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 66, in delete_container
AttributeError: 'ContainerGroupsOperations' object has no attribute 'delete
Upvotes: 3
Views: 913
Reputation: 292
This is a known issue introduced by Microsoft updating Az CLI to version 2.28.0.
There is no solution other that downgrade at the moment but MS is acknowledged. You can track the track their responses in the official repo: https://github.com/Azure/azure-cli/issues/19475
Still, there are some workarounds to address it.
Using REST API:
RESOURCE_GROUP=my-rg
ACI_CONTAINER_NAME=containername
SUBSCRIPTION_ID="xxxxxxxxxxxxxxxxxxxxxxxx"
az rest --method delete \
--uri "/subscriptions/{subscriptionId}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.ContainerInstance/containerGroups/${ACI_CONTAINER_NAME}?api-version=2019-12-01" \
--subscription ${SUBSCRIPTION_ID}
Using PowerShell:
Remove-AzContainerGroup -Name ${var.resourceName} -ResourceGroupName ${var.resourceGroup} -Confirm:$False
Upvotes: 2
Reputation: 1
Got the same error at DevOps jobs, week ago everything was successful. Didn't find any possibilities how to change az
version from UI.
https://developercommunity.visualstudio.com/t/set-up-fixed-az-cli-version-in-my-pipeline/960733
Upvotes: 0