Azure / Azure/azure-cli

az apim api create --api-id MyApi // generates a warning saying api_id is not a known attribute

Open
#27,978 10 comments 0 reactions 0 assignees View on GitHub
act-observability-squad API Management Auto-Assign bug customer-reported Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

When creating a new api from the az cli, I get a warning saying the api_id field is not a known attribute. If I omit the api-id from the command line (expecting an id to auto generate) then I get an error `the following arguments are required: --api-id`

The command does appear to actually create the api despite the warning. However my bash script sees this as an error and fails the step.

### Related command

az apim api create --api-id MyApi --display-name 'My API' --path '/myapi' --resource-group MyResourceGroup --service-name MyApim --service-url {service-url}

### Errors

api_id is not a known attribute of class and will be ignored

### Issue script & Debug output

az apim api create --service-name MyApim -g MyResourceGroup --api-id MyApi --path '/myapi' --display-name 'My API' --debug
cli.knack.cli: Command arguments: ['apim', 'api', 'create', '--service-name', 'MyApim', '-g', 'MyResourceGroup', '--api-id', 'MyApi', '--path', '/myapi', '--display-name', 'My API', '--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 'apim': ['azure.cli.command_modules.apim']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: apim 0.006 14 68
cli.azure.cli.core: Total (1) 0.006 14 68
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: ai-examples 0.133 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: Total (1) 0.133 1 1
cli.azure.cli.core: Loaded 15 groups, 69 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : apim api create
cli.azure.cli.core: Command table: apim api create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/stephen/.azure/commands/2023-12-06.20-48-27.apim_api_create.963.log'.
az_command_data_logger: command args: apim api create --service-name {} -g {} --api-id {} --path {} --display-name {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7f71529b0f70>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7f71529e6040>, .add_cache_arguments at 0x7f71529ede50>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7f71529eddc0>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ApiManagementClient
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 3526
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
azure.mgmt.apimanagement._serialization: api_id is not a known attribute of class and will be ignored
cli.azure.cli.core.auth.adal_authentication: MSIAuthenticationWrapper.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 3526
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: Normalize expires_on: '1701899359' -> 1701899359
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/*****/resourceGroups/MyResourceGroup/providers/Microsoft.ApiManagement/service/MyApim/apis/MyApi?api-version=2022-08-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': '130'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'ce2019b4-9478-11ee-97e1-00155dccccba'
cli.azure.cli.core.sdk.policies: 'CommandName': 'apim api create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--service-name -g --api-id --path --display-name --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.55.0 (RPM) azsdk-python-mgmt-apimanagement/4.0.0 Python/3.9.14 (Linux-5.10.102.2-microsoft-standard-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"properties": {"type": "http", "subscriptionRequired": false, "displayName": "My API", "path": "/myapi", "protocols": ["https"]}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/******/resourceGroups/MyResourceGroup/providers/Microsoft.ApiManagement/service/MyApim/apis/MyApi?api-version=2022-08-01 HTTP/1.1" 404 107
cli.azure.cli.core.sdk.policies: Response status: 404
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': '107'
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-failure-cause': 'gateway'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'ff9a62f6-520d-4cd6-a18d-da2fb2598201'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'ff9a62f6-520d-4cd6-a18d-da2fb2598201'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'NORTHCENTRALUS:20231206T204828Z:ff9a62f6-520d-4cd6-a18d-da2fb2598201'
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: 7C3B8AD16CBB4D8B8B522756BE001E0B Ref B: MNZ221060610049 Ref C: 2023-12-06T20:48:27Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 06 Dec 2023 20:48:27 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"ResourceGroupNotFound","message":"Resource group 'MyResourceGroup' could not be found."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/apim/custom.py", line 337, in apim_api_create
return sdk_no_wait(no_wait, client.api.begin_create_or_update,
File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/util.py", line 710, in sdk_no_wait
return func(*args, **kwargs)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
return func(*args, **kwargs)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/apimanagement/operations/_api_operations.py", line 890, in begin_create_or_update
raw_result = self._create_or_update_initial(
File "/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/apimanagement/operations/_api_operations.py", line 725, in _create_or_update_initial
map_error(status_code=response.status_code, response=response, error_map=error_map)
File "/usr/lib64/az/lib/python3.9/site-packages/azure/core/exceptions.py", line 107, in map_error
raise error
azure.core.exceptions.ResourceNotFoundError: (ResourceGroupNotFound) Resource group 'MyResourceGroup' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'MyResourceGroup' could not be found.

cli.azure.cli.core.azclierror: (ResourceGroupNotFound) Resource group 'MyResourceGroup' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'MyResourceGroup' could not be found.
az_command_data_logger: (ResourceGroupNotFound) Resource group 'MyResourceGroup' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'MyResourceGroup' could not be found.
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 3
cli.__main__: Command ran in 1.391 seconds (init: 0.142, invoke: 1.249)
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 3679 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/__init__.py /home/stephen/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

### Expected behavior

Given api-id is a legitimate field to be passed in (and in fact required), then I would expect no warning message.

### Environment Summary

az --version
azure-cli 2.55.0

core 2.55.0
telemetry 1.1.0

Extensions:
ai-examples 0.2.5
ml 2.22.0
ssh 2.0.2

Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.