Azure-cli: `az acr repository delete` fails with exception

Created on 22 Sep 2017  路  5Comments  路  Source: Azure/azure-cli

Description

Outline the issue here:

I am executing ac acr repository delete and the command is failing with the following exception:

$ az acr repository delete -n myRegistry -u myUser -p myPass --repository myorg/myrepo

'NoneType' object has no attribute 'tier'
Traceback (most recent call last):
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 626, in _execute_command
    reraise(*sys.exc_info())
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 603, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/command_modules/acr/repository.py", line 281, in acr_repository_delete
    registry_name, resource_group_name, DELETE_NOT_SUPPORTED)
  File "/usr/lib64/az/lib/python2.7/site-packages/azure/cli/command_modules/acr/_utils.py", line 286, in managed_registry_validation
    if arm_resource.sku.tier == SkuTier.basic.value:
AttributeError: 'NoneType' object has no attribute 'tier'

NOTE that the SKU of the registry is "Classic" -- it was created a while ago.


Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: rpm on Fedora 26

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here:

az --version
azure-cli (2.0.17)

acr (2.0.11)
acs (2.0.15)
appservice (0.1.16)
batch (3.1.3)
billing (0.1.4)
cdn (0.0.8)
cloud (2.0.7)
cognitiveservices (0.1.7)
command-modules-nspkg (2.0.1)
component (2.0.7)
configure (2.0.10)
consumption (0.1.4)
container (0.1.10)
core (2.0.16)
cosmosdb (0.1.12)
dla (0.0.11)
dls (0.0.13)
eventgrid (0.1.3)
extension (0.0.2)
feedback (2.0.6)
find (0.2.6)
interactive (0.3.9)
iot (0.1.11)
keyvault (2.0.10)
lab (0.0.10)
monitor (0.0.9)
network (2.0.14)
nspkg (3.0.1)
profile (2.0.12)
rdbms (0.0.6)
redis (0.2.8)
resource (2.0.14)
role (2.0.11)
servicefabric (0.0.3)
sf (1.0.8)
sql (2.0.11)
storage (2.0.15)
vm (2.0.14)

Python location '/usr/lib64/az/bin/python'
Extensions directory '/home/raman/.azure/cliextensions'

Python (Linux) 2.7.13 (default, Sep  5 2017, 08:53:59) 
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]

Legal docs and information: aka.ms/AzureCliLegal

OS Version: What OS and version are you using?
Answer here: Fedora 26

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: fish (bash also doesn't work)

Container Registry Service Attention bug

Most helpful comment

@rocketraman Since you mentioned Classic, did you create the registry from Azure Portal? In this case ARM didn't return the SKU properly. Do you mind sharing your registry name or login URI so we can investigate? My email is [email protected] if you would like to send it privately. Thank you.

Also Classic/Basic registries don't support deleting repositories or images, which is the exact intent of this check.

/cc @SajayAntony

All 5 comments

@rocketraman Since you mentioned Classic, did you create the registry from Azure Portal? In this case ARM didn't return the SKU properly. Do you mind sharing your registry name or login URI so we can investigate? My email is [email protected] if you would like to send it privately. Thank you.

Also Classic/Basic registries don't support deleting repositories or images, which is the exact intent of this check.

/cc @SajayAntony

@djyou Yup, I figured that out afterwards, but it took a little bit of digging since I didn't get a nice error message from the CLI. I did create it from the portal. Sent you the information privately.

That error message definitely can indicate this.
/cc @yuwaMSFT2

Registries created with the old api-version doesn't have SKU. ACR service can still return SKU properly when querying with the current api-version. For perf reason, this specific case queried resources from ARM, which doesn't have the SKU information, so the validation couldn't proceed.

This will be fixed by treating empty SKU as Basic/Classic SKU. The proper error message has been implemented as Delete is not supported for registries in Classic/Basic SKU.

@rocketraman Thank you for raising this issue.

@djyou since this is a solvable issue, I will assign this to the next milestone. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmetb picture ahmetb  路  3Comments

amarzavery picture amarzavery  路  3Comments

dhermans picture dhermans  路  3Comments

derekbekoe picture derekbekoe  路  3Comments

binderjoe picture binderjoe  路  3Comments