Azure / Azure/azure-cli-extensions
[costmanagement] `az costmanagement export create` requires storage account access keys to be enabled
- Dominant language
- Python
- Stars
- 454
- Forks
- 1.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 64
Description
Source: https://github.com/Azure/azure-cli/issues/32912 (by @AdamSharif-MSFT)
Affected extension: `costmanagement` (`src/costmanagement/`)
---
<<>>
# Issue #32912 (by @AdamSharif-MSFT)
## Title
`az costmanagement export create` requires storage account access keys to be enabled
## Body
### Describe the bug
When calling the command `az costmanagement export create` with a configured storage account, the following error is returned:
'''
# Create the custom cost management exports
az costmanagement export create \
--name "$EXPORT_NAME" --type "Usage" \
--dataset-configuration columns="Date" columns="MeterId" columns="ResourceLocation" columns="CostInUSD" columns="ResourceId" columns="PricingModel" \
--timeframe "MonthToDate" \
--storage-container="$STORAGE_CONTAINER_NAME" \
--storage-account-id="$STORAGE_ACCOUNT_ID" \
--storage-directory="ad-hoc" \
--recurrence "Daily" \
--recurrence-period from="2026-03-05T14:00:00Z" to="2027-03-05T13:20:00Z" \
--schedule-status "Active" \
--scope "subscriptions/$SUBSCRIPTION"
(400) Key-based authentication is currently disabled on this storage account. To proceed, please enable "Allow storage account key access". For instructions on how to change this setting, please visit https://aka.ms/sharedkey. (Request ID: [redacted] )
Code: 400
'''
The problem is firstly I can't enable access keys on my storage account, and secondly this is an anti-pattern for storage account security.
### Related command
'''
az costmanagement export create \
--name "$EXPORT_NAME" --type "Usage" \
--dataset-configuration columns="Date" columns="MeterId" columns="ResourceLocation" columns="CostInUSD" columns="ResourceId" columns="PricingModel" \
--timeframe "MonthToDate" \
--storage-container="$STORAGE_CONTAINER_NAME" \
--storage-account-id="$STORAGE_ACCOUNT_ID" \
--storage-directory="ad-hoc" \
--recurrence "Daily" \
--recurrence-period from="2026-03-05T14:00:00Z" to="2027-03-05T13:20:00Z" \
--schedule-status "Active" \
--scope "subscriptions/$SUBSCRIPTION"
'''
### Errors
''' (400) Key-based authentication is currently disabled on this storage account. To proceed, please enable "Allow storage account key access". For instructions on how to change this setting, please visit https://aka.ms/sharedkey. (Request ID: [redacted] ) Code: 400'''
### Issue script & Debug output
'''
cli.knack.cli: Command arguments: ['costmanagement', 'export', 'create', '--name', 'TestExport', '--type', 'Usage', '--dataset-configuration', 'columns=Date', 'columns=MeterId', 'columns=ResourceLocation', 'columns=CostInUSD', 'columns=ResourceId', 'columns=PricingModel', '--timeframe', 'MonthToDate', '--storage-container=cost-management-exports', '--storage-account-id=/subscriptions/[redacted]/resourceGroups/rg-cost-management-demo/providers/Microsoft.Storage/storageAccounts/stacccostmgmtgkrxez5x', '--storage-directory=ad-hoc', '--recurrence', 'Daily', '--recurrence-period', 'from=2026-03-05T14:00:00Z', 'to=2027-03-05T13:20:00Z', '--schedule-status', 'Active', '--scope', 'subscriptions/[redacted]', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'costmanagement': ['azext_costmanagement']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Loaded command modules in parallel:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: costmanagement 0.118 2 6 /home/[redacted]/.azure/cliextensions/costmanagement
cli.azure.cli.core: Total (1) 0.118 2 6
cli.azure.cli.core: Loaded 2 groups, 6 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : costmanagement export create
cli.azure.cli.core: Command table: costmanagement export create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/[redacted]/.azure/commands/2026-03-05.14-13-18.costmanagement_export_create.5547.log'.
az_command_data_logger: command args: costmanagement export create --name {} --type {} --dataset-configuration {} {} {} {} {} {} --timeframe {} --storage-container={} --storage-account-id={} --storage-directory={} --recurrence {} --recurrence-period {} {} --schedule-status {} --scope {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7502d5770e00>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7502d5773100>, .add_cache_arguments at 0x7502d57732e0>, .update_breaking_change_info at 0x7502d5773380>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7502d57731a0>]
az_command_data_logger: extension name: costmanagement
az_command_data_logger: extension version: 1.0.0
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=CostManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/[redacted]/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/[redacted]/.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/16b3c013-d300-468d-ac64-7eda0820b6d3/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/16b3c013-d300-468d-ac64-7eda0820b6d3/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic', 'self_signed_tls_client_auth'], 'jwks_uri': 'https://login.microsoftonline.com/16b3c013-d300-468d-ac64-7eda0820b6d3/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'], 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/16b3c013-d300-468d-ac64-7eda0820b6d3/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/16b3c013-d300-468d-ac64-7eda0820b6d3/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/16b3c013-d300-468d-ac64-7eda0820b6d3/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://lo
... [truncated, original was 17317 chars]
## Comments
### Comment by @yonzhan
Thank you for opening this issue, we will look into it.
### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ms-premp, @ramaganesan-rg.
<<>>
Contributor guide
Assessment
This issue has not been assessed yet.