If I call the REST API and only pass in the subscriptionId property I am able to successfully create an alias for the existing subscription. Below is the curl request that I was able to use (minus the auth header).
curl --location --request PUT 'https://management.azure.com/providers/Microsoft.Subscription/aliases/2ab056d4-e9e4-4147-afa5-2eb522318e39?api-version=2021-10-01' \
--header 'Content-Type: application/json' \
--data '{
"properties": {
"subscriptionId": "---existing sub id---"
}
}'
Describe the bug
When running the command
az account alias create --name (Random GUID) --subscription-id (Existing sub ID)
I get the errorIf I add the
--display-name
parameter, I get the following outputIt seems as though the command doesn't allow you to create an alias for an existing subscription.
Related command
az account alias create
Errors
(MissingParameter) Required parameter DisplayName not provided. Code: MissingParameter Message: Required parameter DisplayName not provided.
Issue script & Debug output
cli.knack.cli: Command arguments: ['account', 'alias', 'create', '--name', '2ab056d4-e9e4-4147-afa5-2eb522318e39', '--subscription-id', '--existing sub id---', '--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 0x105cb00e0>, <function OutputProducer.on_global_arguments at 0x105d4b240>, <function CLIQuery.on_global_arguments at 0x105d9cd60>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource', 'azext_account'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: profile 0.002 2 8 cli.azure.cli.core: resource 0.058 51 228 cli.azure.cli.core: Total (2) 0.060 53 236 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: account 0.002 4 13 /Users/joe.fecht/.azure/cliextensions/account cli.azure.cli.core: Total (1) 0.002 4 13 cli.azure.cli.core: Loaded 55 groups, 249 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : account alias create cli.azure.cli.core: Command table: account alias create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x1069b02c0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/joe.fecht/.azure/commands/2023-11-22.07-17-50.account_alias_create.34126.log'. az_command_data_logger: command args: account alias create --name {} --subscription-id {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x106a04fe0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x106a05080>, <function register_cache_arguments..add_cache_arguments at 0x106a051c0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x105d4b2e0>, <function CLIQuery.handle_query_parameter at 0x105d9ce00>, <function register_ids_argument..parse_ids_arguments at 0x106a05120>]
az_command_data_logger: extension name: account
az_command_data_logger: extension version: 0.2.5
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=SubscriptionClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/joe.fecht/.azure/service_principal_entries.json', encrypt=False
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/joe.fecht/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/joe.fecht/.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: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/--tenant id---/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/--tenant id---/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/--tenant id---/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/--tenant id---/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/--tenant id---/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/--tenant id---/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/--tenant id---/kerberos', 'tenant_region_scope': 'NA', '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? False
msal.application: Region to be used: None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: ServicePrincipalCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 6f5a1262-aae6-4b99-b9ca-2ffe4097a4f9
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/providers/Microsoft.Subscription/aliases/2ab056d4-e9e4-4147-afa5-2eb522318e39?api-version=2021-10-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '73'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '892ef252-8939-11ee-bd4b-56a0f070cf77'
cli.azure.cli.core.sdk.policies: 'CommandName': 'account alias create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--name --subscription-id --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.54.0 (HOMEBREW) azsdk-python-mgmt-subscription/3.1.1 Python/3.11.6 (macOS-13.6-arm64-arm-64bit)'
cli.azure.cli.core.sdk.policies: 'Authorization': '**'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"properties": {"subscriptionId": "--existing sub id---"}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /providers/Microsoft.Subscription/aliases/2ab056d4-e9e4-4147-afa5-2eb522318e39?api-version=2021-10-01 HTTP/1.1" 400 177
cli.azure.cli.core.sdk.policies: Response status: 400
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': '177'
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: 'mise-correlation-id': '0ae3ec62-d198-4caa-a0e4-a0205e07020d'
cli.azure.cli.core.sdk.policies: 'MS-CV': 'lksbAL7+oUueRfJ7QnDFlA.0'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '069a062d-d5b5-475a-9d32-36bdc3fb733c'
cli.azure.cli.core.sdk.policies: 'Request-Id': '069a062d-d5b5-475a-9d32-36bdc3fb733c'
cli.azure.cli.core.sdk.policies: 'x-gsm': '1.0.0.0'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'Server': 'Microsoft-IIS/10.0'
cli.azure.cli.core.sdk.policies: 'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.sdk.policies: 'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-tenant-writes': '1199'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '069a062d-d5b5-475a-9d32-36bdc3fb733c'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'CENTRALUS:20231122T131751Z:069a062d-d5b5-475a-9d32-36bdc3fb733c'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 22 Nov 2023 13:17:50 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"MissingParameter","message":"Required parameter DisplayName not provided."},"code":"MissingParameter","message":"Required parameter DisplayName not provided."}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(command_args)
^^^^^^^^^^^^^^^^^^
File "/Users/joe.fecht/.azure/cliextensions/account/azext_account/manual/custom.py", line 37, in account_alias_create
return sdk_no_wait(no_wait,
^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/cli/core/util.py", line 710, in sdk_no_wait
return func(*args, *kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.54.0/libexec/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
return func(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/joe.fecht/.azure/cliextensions/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py", line 308, in begin_create
raw_result = self._create_initial( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/joe.fecht/.azure/cliextensions/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py", line 194, in _create_initial
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (MissingParameter) Required parameter DisplayName not provided.
Code: MissingParameter
Message: Required parameter DisplayName not provided.
cli.azure.cli.core.azclierror: (MissingParameter) Required parameter DisplayName not provided. Code: MissingParameter Message: Required parameter DisplayName not provided. az_command_data_logger: (MissingParameter) Required parameter DisplayName not provided. Code: MissingParameter Message: Required parameter DisplayName not provided. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x1069b0540>] az_command_data_logger: exit code: 1 cli.main: Command ran in 0.946 seconds (init: 0.086, invoke: 0.860) 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: Fail to create telemetry cache directory for /Users/joe.fecht/.azure/telemetry/cache. Reason [Errno 13] Permission denied: '/Users/joe.fecht/.azure/telemetry/cache'.
Expected behavior
Create a subscription alias for an existing subscription.
Environment Summary
azure-cli 2.54.0
core 2.54.0 telemetry 1.1.0
Extensions: account 0.2.5 azure-devops 0.26.0 log-analytics-solution 1.0.0 resource-graph 2.1.0
Dependencies: msal 1.24.0b2 azure-mgmt-resource 23.1.0b2
Additional context
If I call the REST API and only pass in the
subscriptionId
property I am able to successfully create an alias for the existing subscription. Below is the curl request that I was able to use (minus the auth header).