# Buggy code
def _parameters(
    registry_name,
    location,
    sku,
    admin_user_enabled,
    storage_account_name=None,
    storage_account_resource_group=None,
    registry_api_version=None,
):
    """Returns a dict of deployment parameters.
    :param str registry_name: The name of container registry
    :param str location: The name of location
    :param str sku: The SKU of the container registry
    :param bool admin_user_enabled: Enable admin user
    :param str storage_account_name: The name of storage account
    :param str storage_account_resource_group: The resource group of storage account
    :param str registry_api_version: The API version of the container registry
    """
    parameters = {
        "registryName": {"value": registry_name},
        "registryLocation": {"value": location},
        "registrySku": {"value": sku},
        "adminUserEnabled": {"value": admin_user_enabled},
    }
    if registry_api_version:
        parameters["registryApiVersion"] = {"value": registry_api_version}
    if storage_account_name:
        parameters["storageAccountName"] = {"value": storage_account_name}
        if storage_account_resource_group:
            parameters["storageAccountResourceGroup"] = {
                "value": storage_account_resource_group
            }
    return parameters


# Traceback (AttributeError)
$ 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'

# Fixed code
def _parameters(
    registry_name,
    location,
    sku,
    admin_user_enabled,
    storage_account_name=None,
    storage_account_id=None,
    registry_api_version=None,
):
    """Returns a dict of deployment parameters.
    :param str registry_name: The name of container registry
    :param str location: The name of location
    :param str sku: The SKU of the container registry
    :param bool admin_user_enabled: Enable admin user
    :param str storage_account_name: The name of storage account
    :param str storage_account_id: The resource ID of storage account
    :param str registry_api_version: The API version of the container registry
    """
    parameters = {
        "registryName": {"value": registry_name},
        "registryLocation": {"value": location},
        "registrySku": {"value": sku},
        "adminUserEnabled": {"value": admin_user_enabled},
    }
    if registry_api_version:
        parameters["registryApiVersion"] = {"value": registry_api_version}
    if storage_account_name:
        parameters["storageAccountName"] = {"value": storage_account_name}
    if storage_account_id:
        parameters["storageAccountId"] = {"value": storage_account_id}

    return parameters