Skip to content

az storage blob generate-sas ValueError exception #31187

@kohtala

Description

@kohtala

Describe the bug

I can get an SAS token URL signed with Account key from the Azure Portal for a blob and was trying to find how I can do the same on azure cli.

I would expect az login would give equal access to create the SAS token signed with an account key as on the portal regardless how you authenticate to the API.

#13012 tells --as-user is required for --auth-mode login, but I fail to see why the login authentication to REST API could no fetch the key and sign the SAS token with that key.

For some reason it also asks for --account-name even when the --blob-url is given.

Related command

az storage blob generate-sas --permissions r --https-only --expiry $(date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ') --blob-url "https://[REDACTED].file.core.windows.net/[REDACTED]" --account-name [REDACTED] --full-uri

Errors

There are no credentials provided in your command and environment, we will query for account key for your storage account.
It is recommended to provide --connection-string, --account-key or --sas-token in your command as credentials.

You also can add `--auth-mode login` in your command to use Azure Active Directory (Azure AD) for authorization if your login account is assigned required RBAC roles.
For more information about RBAC roles in storage, visit https://learn.microsoft.com/azure/storage/common/storage-auth-aad-rbac-cli.

In addition, setting the corresponding environment variables can avoid inputting credentials in your command. Please use --help to get more information about environment variable usage.
The command failed with an unexpected error. Here is the traceback:
Unable to determine account name for shared key credential.
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 430, in new_handler
    first(ex)
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 429, in new_handler
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 853, in generate_sas_blob_uri
    blob_client = t_blob_client.from_blob_url(blob_url=blob_url, credential=credential, snapshot=snapshot)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 289, in from_blob_url
    return cls(
           ^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 186, in __init__
    super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 92, in __init__
    self.credential = _format_shared_key_credential(self.account_name, credential)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 347, in _format_shared_key_credential
    raise ValueError("Unable to determine account name for shared key credential.")
ValueError: Unable to determine account name for shared key credential.
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

cli.knack.cli: Command arguments: ['storage', 'blob', 'generate-sas', '--permissions', 'r', '--https-only', '--expiry', '2025-04-03T07:58Z', '--blob-url', 'https://[REDACTED].file.core.windows.net/[REDACTED]', '--account-name', '[REDACTED]', '--full-uri', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fd9d382b7e0>, <function OutputProducer.on_global_arguments at 0x7fd9d357a7a0>, <function CLIQuery.on_global_arguments at 0x7fd9d35bfce0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'storage': ['azure.cli.command_modules.storage']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: storage                   0.186        60       275
cli.azure.cli.core: Total (1)                 0.186        60       275
cli.azure.cli.core: Loaded 60 groups, 275 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : storage blob generate-sas
cli.azure.cli.core: Command table: storage blob generate-sas
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fd9d27fc220>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/kohtala/.azure/commands/2025-04-03.10-28-23.storage_blob_generate-sas.24886.log'.
az_command_data_logger: command args: storage blob generate-sas --permissions {} --https-only --expiry {} --blob-url {} --account-name {} --full-uri --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fd9d2858720>]
cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 657, in _get_attr
    op = getattr(op, part)
         ^^^^^^^^^^^^^^^^^
AttributeError: module 'azure.mgmt.storage.v2024_01_01.models' has no attribute 'ActiveDirectoryPropertiesAccountType'

cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 657, in _get_attr
    op = getattr(op, part)
         ^^^^^^^^^^^^^^^^^
AttributeError: module 'azure.mgmt.storage.v2024_01_01.models' has no attribute 'ListKeyExpand'

cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 657, in _get_attr
    op = getattr(op, part)
         ^^^^^^^^^^^^^^^^^
AttributeError: module 'azure.mgmt.storage.v2024_01_01.models' has no attribute 'CorsRuleAllowedMethodsItem'

cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fd9d285af20>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fd9d285b060>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x7fd9d285b100>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fd9d357a840>, <function CLIQuery.handle_query_parameter at 0x7fd9d35bfd80>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fd9d285afc0>]
cli.azure.cli.command_modules.storage._validators: Try to get storage auth_mode value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage connection_string value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage key value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators: Try to get storage sas_token value from environment variables or config file.
cli.azure.cli.command_modules.storage._validators:
There are no credentials provided in your command and environment, we will query for account key for your storage account.
It is recommended to provide --connection-string, --account-key or --sas-token in your command as credentials.

You also can add `--auth-mode login` in your command to use Azure Active Directory (Azure AD) for authorization if your login account is assigned required RBAC roles.
For more information about RBAC roles in storage, visit https://learn.microsoft.com/azure/storage/common/storage-auth-aad-rbac-cli.

In addition, setting the corresponding environment variables can avoid inputting credentials in your command. Please use --help to get more information about environment variable usage.
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=StorageManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/kohtala/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/kohtala/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/[REDACTED]
msal.authority: openid_config("https://login.microsoftonline.com/[REDACTED]/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/[REDACTED]/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/[REDACTED]/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/[REDACTED]/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/[REDACTED]/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/[REDACTED]/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/[REDACTED]/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/[REDACTED]/kerberos', 'tenant_region_scope': 'EU', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token_info: scopes=('https://management.core.windows.net//.default',), options={}
cli.azure.cli.core.auth.msal_credentials: UserCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], claims_challenge=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: ab8d26c8-89a5-4eb3-88c2-91ddd910f234
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/[REDACTED]/providers/Microsoft.Storage/storageAccounts?api-version=2024-01-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': '39e3d5a8-105d-11f0-abab-877c49f4fc79'
cli.azure.cli.core.sdk.policies:     'CommandName': 'storage blob generate-sas'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--permissions --https-only --expiry --blob-url --account-name --full-uri --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.71.0 (DEB) azsdk-python-core/1.31.0 Python/3.12.8 (Linux-5.15.0-136-generic-x86_64-with-glibc2.35)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/[REDACTED]/providers/Microsoft.Storage/storageAccounts?api-version=2024-01-01 HTTP/1.1" 200 22037
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '22037'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'x-ms-original-request-ids': 'e26abdd0-d7fd-4a02-8c6e-1d2528e95c66, 7d15f3d0-96cf-4b70-ba80-a96421e81dd8'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-reads': '249'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-global-reads': '3749'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '678af0ff-3b8e-465b-8931-14f005bd7219'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '678af0ff-3b8e-465b-8931-14f005bd7219'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'SWITZERLANDWEST:20250403T072825Z:678af0ff-3b8e-465b-8931-14f005bd7219'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies:     'X-MSEdge-Ref': 'Ref A: D27784751AED43BA9A7BC877FEE1E92F Ref B: FRA231050415049 Ref C: 2025-04-03T07:28:24Z'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 03 Apr 2025 07:28:25 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"value":[REDACTED], {
            "sku": {
                "name": "Standard_RAGRS",
                "tier": "Standard"
            },
            "kind": "StorageV2",
            "id": "/subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Storage/storageAccounts/[REDACTED]",
            "name": "[REDACTED]",
            "type": "Microsoft.Storage/storageAccounts",
            "location": "northeurope",
            "tags": {[REDACTED]},
            "properties": {
                "dnsEndpointType": "Standard",
                "defaultToOAuthAuthentication": false,
                "publicNetworkAccess": "Enabled",
                "keyCreationTime": {
                    "key1": "2025-02-26T13:33:26.5785698Z",
                    "key2": "2025-02-26T13:33:26.5785698Z"
                },
                "allowCrossTenantReplication": false,
                "privateEndpointConnections": [],
                "minimumTlsVersion": "TLS1_2",
                "allowBlobPublicAccess": false,
                "allowSharedKeyAccess": true,
                "largeFileSharesState": "Enabled",
                "networkAcls": {
                    "ipv6Rules": [],
                    "bypass": "AzureServices",
                    "virtualNetworkRules": [],
                    "ipRules": [],
                    "defaultAction": "Allow"
                },
                "supportsHttpsTrafficOnly": true,
                "encryption": {
                    "requireInfrastructureEncryption": false,
                    "services": {
                        "file": {
                            "keyType": "Account",
                            "enabled": true,
                            "lastEnabledTime": "2025-02-26T13:33:26.8598163Z"
                        },
                        "blob": {
                            "keyType": "Account",
                            "enabled": true,
                            "lastEnabledTime": "2025-02-26T13:33:26.8598163Z"
                        }
                    },
                    "keySource": "Microsoft.Storage"
                },
                "accessTier": "Hot",
                "provisioningState": "Succeeded",
                "creationTime": "2025-02-26T13:33:26.4691949Z",
                "primaryEndpoints": {
                    "dfs": "https://[REDACTED].dfs.core.windows.net/",
                    "web": "https://[REDACTED].z16.web.core.windows.net/",
                    "blob": "https://[REDACTED].blob.core.windows.net/",
                    "queue": "https://[REDACTED].queue.core.windows.net/",
                    "table": "https://[REDACTED].table.core.windows.net/",
                    "file": "https://[REDACTED].file.core.windows.net/"
                },
                "primaryLocation": "northeurope",
                "statusOfPrimary": "available",
                "secondaryLocation": "westeurope",
                "statusOfSecondary": "available",
                "secondaryEndpoints": {
                    "dfs": "https://[REDACTED]-secondary.dfs.core.windows.net/",
                    "web": "https://[REDACTED]-secondary.z16.web.core.windows.net/",
                    "blob": "https://[REDACTED]-secondary.blob.core.windows.net/",
                    "queue": "https://[REDACTED]-secondary.queue.core.windows.net/",
                    "table": "https://[REDACTED]-secondary.table.core.windows.net/"
                }
            }
        }]}
cli.azure.cli.core.profiles._shared: Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 653, in _get_attr
    op = import_module(full_mod_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'azure.mgmt.storage.v2024_01_01.models.storage_account_keys'

cli.azure.cli.command_modules.storage._validators: Disable HTTP logging to avoid having storage keys in debug logs
urllib3.connectionpool: https://management.azure.com:443 "POST /subscriptions/[REDACTED]/resourceGroups/[REDACTED]/providers/Microsoft.Storage/storageAccounts/[REDACTED]/listKeys?api-version=2024-01-01&$expand=kerb HTTP/1.1" 200 380
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 430, in new_handler
    first(ex)
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 429, in new_handler
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 853, in generate_sas_blob_uri
    blob_client = t_blob_client.from_blob_url(blob_url=blob_url, credential=credential, snapshot=snapshot)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 289, in from_blob_url
    return cls(
           ^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 186, in __init__
    super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 92, in __init__
    self.credential = _format_shared_key_credential(self.account_name, credential)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 347, in _format_shared_key_credential
    raise ValueError("Unable to determine account name for shared key credential.")
ValueError: Unable to determine account name for shared key credential.

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: Unable to determine account name for shared key credential.
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 430, in new_handler
    first(ex)
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 429, in new_handler
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 853, in generate_sas_blob_uri
    blob_client = t_blob_client.from_blob_url(blob_url=blob_url, credential=credential, snapshot=snapshot)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 289, in from_blob_url
    return cls(
           ^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 186, in __init__
    super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 92, in __init__
    self.credential = _format_shared_key_credential(self.account_name, credential)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 347, in _format_shared_key_credential
    raise ValueError("Unable to determine account name for shared key credential.")
ValueError: Unable to determine account name for shared key credential.
az_command_data_logger: Unable to determine account name for shared key credential.
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 430, in new_handler
    first(ex)
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/__init__.py", line 429, in new_handler
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 853, in generate_sas_blob_uri
    blob_client = t_blob_client.from_blob_url(blob_url=blob_url, credential=credential, snapshot=snapshot)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 289, in from_blob_url
    return cls(
           ^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_blob_client.py", line 186, in __init__
    super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 92, in __init__
    self.credential = _format_shared_key_credential(self.account_name, credential)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/multiapi/storagev2/blob/v2022_11_02/_shared/base_client.py", line 347, in _format_shared_key_credential
    raise ValueError("Unable to determine account name for shared key credential.")
ValueError: Unable to determine account name for shared key credential.
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fd9d27fc4a0>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 2.037 seconds (init: 0.122, invoke: 1.916)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 8272 in cache file under /home/kohtala/.azure/telemetry/20250403102825765
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.12/site-packages/azure/cli/telemetry/__init__.py /home/kohtala/.azure /home/kohtala/.azure/telemetry/20250403102825765"
telemetry.process: Return from creating process 24891
telemetry.main: Finish creating telemetry upload process.

Expected behavior

That it would output the URL I can share to enable download of the blob.

Environment Summary

azure-cli 2.71.0

core 2.71.0
telemetry 1.1.0

Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'
Config directory '/home/kohtala/.azure'
Extensions directory '/home/kohtala/.azure/cliextensions'

Python (Linux) 3.12.8 (main, Mar 25 2025, 10:54:53) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamStorageaz storageact-codegen-extensibility-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions