Azure / azure-cli

Azure Command-Line Interface
MIT License
3.93k stars 2.9k forks source link

Unable to delete non current API Revision using AZ CLI #27603

Open PratikModi93 opened 9 months ago

PratikModi93 commented 9 months ago

Describe the bug

We have an API which has 2 revisions and we are trying to delete the non-current revision of the API using AZ CLI command. The command executes without error but doesn't delete anything.

Command that we are running: az apim api delete --api-id 'apiname;rev=2' --resource-group --service-name --yes

Input to the command is the api-id with 'apiname;rev=2'

Same command when we run with passing apiname as api-id (without the ;rev=2), the command deletes both the versions(current and non-current).

So not sure what is causing this behaviour.

Related command

az apim api delete --api-id 'apiname;rev=2' --resource-group --service-name --yes

Errors

No errors, command runs but doesn't perform the action it seems.

Issue script & Debug output

2023-10-16T13:13:20.3917476Z DEBUG: cli.knack.cli: Command arguments: ['apim', 'api', 'delete', '--api-id', '**;rev=2', '--resource-group', '', '--service-name', '*', '--yes', '--debug'] 2023-10-16T13:13:20.3918810Z DEBUG: cli.knack.cli: init debug log: 2023-10-16T13:13:20.3919259Z Cannot enable color. 2023-10-16T13:13:20.3919650Z DEBUG: cli.knack.cli: Event: Cli.PreExecute [] 2023-10-16T13:13:20.3921296Z DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x0000023C92AB1480>, <function OutputProducer.on_global_arguments at 0x0000023C92E28160>, <function CLIQuery.on_global_arguments at 0x0000023C92E4D480>] 2023-10-16T13:13:20.3939747Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] 2023-10-16T13:13:20.3948880Z DEBUG: cli.azure.cli.core: Modules found from index for 'apim': ['azure.cli.command_modules.apim'] 2023-10-16T13:13:20.3949683Z DEBUG: cli.azure.cli.core: Loading command modules: 2023-10-16T13:13:20.3950315Z DEBUG: cli.azure.cli.core: Name Load Time Groups Commands 2023-10-16T13:13:20.4019905Z DEBUG: cli.azure.cli.core: apim 0.007 14 68 2023-10-16T13:13:20.4020634Z DEBUG: cli.azure.cli.core: Total (1) 0.007 14 68 2023-10-16T13:13:20.4029936Z DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] 2023-10-16T13:13:20.4031556Z DEBUG: cli.azure.cli.core: Loading extensions: 2023-10-16T13:13:20.4032197Z DEBUG: cli.azure.cli.core: Name Load Time Groups Commands Directory 2023-10-16T13:13:20.4032919Z DEBUG: cli.azure.cli.core: Total (0) 0.000 0 0
2023-10-16T13:13:20.4033519Z DEBUG: cli.azure.cli.core: Loaded 14 groups, 68 commands. 2023-10-16T13:13:20.4034079Z DEBUG: cli.azure.cli.core: Found a match in the command table. 2023-10-16T13:13:20.4035403Z DEBUG: cli.azure.cli.core: Raw command : apim api delete 2023-10-16T13:13:20.4036581Z DEBUG: cli.azure.cli.core: Command table: apim api delete 2023-10-16T13:13:20.4037565Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0000023C954E05E0>] 2023-10-16T13:13:20.4039173Z DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'D:\a_temp.azclitask\commands\2023-10-16.13-13-20.apim_api_delete.3900.log'. 2023-10-16T13:13:20.4040662Z INFO: az_command_data_logger: command args: apim api delete --api-id {} --resource-group {} --service-name {} --yes --debug 2023-10-16T13:13:20.4041984Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x0000023C954E3250>] 2023-10-16T13:13:20.5461839Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] 2023-10-16T13:13:20.5463707Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0000023C95535240>, <function register_cache_arguments..add_cache_arguments at 0x0000023C95535360>] 2023-10-16T13:13:20.5474735Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] 2023-10-16T13:13:20.5475515Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] 2023-10-16T13:13:20.5481345Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x0000023C92E281F0>, <function CLIQuery.handle_query_parameter at 0x0000023C92E4D510>, <function register_ids_argument..parse_ids_arguments at 0x0000023C955352D0>] 2023-10-16T13:13:20.5485104Z DEBUG: cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ApiManagementClient 2023-10-16T13:13:20.5628054Z DEBUG: cli.azure.cli.core.auth.persistence: build_persistence: location='D:\a\_temp\.azclitask\service_principal_entries.bin', encrypt=True 2023-10-16T13:13:20.5680782Z DEBUG: cli.azure.cli.core.auth.persistence: build_persistence: location='D:\a\_temp\.azclitask\msal_token_cache.bin', encrypt=True 2023-10-16T13:13:20.5686931Z DEBUG: cli.azure.cli.core.auth.binary_cache: load: D:\a_temp.azclitask\msal_http_cache.bin 2023-10-16T13:13:20.6370961Z DEBUG: urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None) 2023-10-16T13:13:20.6384078Z DEBUG: msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/**
/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/******/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/******/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/******/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/******/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/******/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/******/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'} 2023-10-16T13:13:20.6393148Z DEBUG: msal.application: Broker enabled? False 2023-10-16T13:13:20.6393616Z DEBUG: msal.application: Region to be used: None 2023-10-16T13:13:20.6502185Z DEBUG: cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={} 2023-10-16T13:13:20.6503914Z DEBUG: cli.azure.cli.core.auth.msal_authentication: ServicePrincipalCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={} 2023-10-16T13:13:20.6510522Z DEBUG: msal.application: Cache hit an AT 2023-10-16T13:13:20.6515360Z DEBUG: msal.telemetry: Generate or reuse correlation_id: bd1b473c-e11f-45cf-96fb-2bd146db64b2 2023-10-16T13:13:20.6517995Z DEBUG: cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/******/resourceGroups/******rg/providers/Microsoft.ApiManagement/service/******apim01/apis/GlobalAccountTransactionAPI-v2%3Brev%3D2?deleteRevisions=false&api-version=2022-08-01' 2023-10-16T13:13:20.6520337Z DEBUG: cli.azure.cli.core.sdk.policies: Request method: 'DELETE' 2023-10-16T13:13:20.6520933Z DEBUG: cli.azure.cli.core.sdk.policies: Request headers: 2023-10-16T13:13:20.6521583Z DEBUG: cli.azure.cli.core.sdk.policies: 'If-Match': '*' 2023-10-16T13:13:20.6522306Z DEBUG: cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' 2023-10-16T13:13:20.6523300Z DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'c7083056-6c25-11ee-a039-000d3a2037ac' 2023-10-16T13:13:20.6524269Z DEBUG: cli.azure.cli.core.sdk.policies: 'CommandName': 'apim api delete' 2023-10-16T13:13:20.6525284Z DEBUG: cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--api-id --resource-group --service-name --yes --debug' 2023-10-16T13:13:20.6527116Z DEBUG: cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.53.0 (MSI) azsdk-python-mgmt-apimanagement/4.0.0 Python/3.10.10 (Windows-10-10.0.20348-SP0) VSTS_06e2de9d-0560-4fd5-8c72-c3d0e7d69fa6_build_27546_0' 2023-10-16T13:13:20.6528576Z DEBUG: cli.azure.cli.core.sdk.policies: 'Authorization': '*' 2023-10-16T13:13:20.6529296Z DEBUG: cli.azure.cli.core.sdk.policies: Request body: 2023-10-16T13:13:20.6529877Z DEBUG: cli.azure.cli.core.sdk.policies: This request has no body 2023-10-16T13:13:20.6538590Z DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443 2023-10-16T13:13:21.3423785Z DEBUG: urllib3.connectionpool: https://management.azure.com:443 "DELETE /subscriptions//resourceGroups/*
/providers/Microsoft.ApiManagement/service/*****/apis/GlobalAccountTransactionAPI-v2%3Brev%3D2?deleteRevisions=false&api-version=2022-08-01 HTTP/1.1" 204 0 2023-10-16T13:13:21.3431880Z DEBUG: cli.azure.cli.core.sdk.policies: Response status: 204 2023-10-16T13:13:21.3432615Z DEBUG: cli.azure.cli.core.sdk.policies: Response headers: 2023-10-16T13:13:21.3434117Z DEBUG: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache' 2023-10-16T13:13:21.3435805Z DEBUG: cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache' 2023-10-16T13:13:21.3436475Z DEBUG: cli.azure.cli.core.sdk.policies: 'Expires': '-1' 2023-10-16T13:13:21.3437348Z DEBUG: cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' 2023-10-16T13:13:21.3438291Z DEBUG: cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff' 2023-10-16T13:13:21.3439207Z DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '5fb00f9c-93b5-49bb-826e-139aec830be7' 2023-10-16T13:13:21.3440096Z DEBUG: cli.azure.cli.core.sdk.policies: 'Server': 'Microsoft-HTTPAPI/2.0' 2023-10-16T13:13:21.3440989Z DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-deletes': '14999' 2023-10-16T13:13:21.3442069Z DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '5fb00f9c-93b5-49bb-826e-139aec830be7' 2023-10-16T13:13:21.3443348Z DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTEUROPE:20231016T131321Z:5fb00f9c-93b5-49bb-826e-139aec830be7' 2023-10-16T13:13:21.3444447Z DEBUG: cli.azure.cli.core.sdk.policies: 'Date': 'Mon, 16 Oct 2023 13:13:20 GMT' 2023-10-16T13:13:21.3445096Z DEBUG: cli.azure.cli.core.sdk.policies: Response content: 2023-10-16T13:13:21.3445552Z DEBUG: cli.azure.cli.core.sdk.policies: 2023-10-16T13:13:21.3446645Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x0000023C95512680>, <function _x509_from_base64_to_hex_transform at 0x0000023C95512710>] 2023-10-16T13:13:21.3453257Z DEBUG: cli.knack.cli: Event: CommandInvoker.OnFilterResult [] 2023-10-16T13:13:21.3453902Z DEBUG: cli.knack.cli: Event: Cli.SuccessfulExecute [] 2023-10-16T13:13:21.3454700Z DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0000023C954E0820>] 2023-10-16T13:13:21.3455462Z INFO: az_command_data_logger: exit code: 0 2023-10-16T13:13:21.3455993Z INFO: cli.main: Command ran in 1.271 seconds (init: 0.316, invoke: 0.954) 2023-10-16T13:13:21.3823204Z INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1 2023-10-16T13:13:21.3824206Z INFO: telemetry.client: Accumulated 0 events. Flush the clients. 2023-10-16T13:13:21.3824890Z INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1 2023-10-16T13:13:21.3829304Z INFO: telemetry.save: Save telemetry record of length 3295 in cache 2023-10-16T13:13:21.3830596Z INFO: telemetry.main: Begin creating telemetry upload process. 2023-10-16T13:13:21.3834638Z INFO: telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry__init__.pyc D:\a_temp.azclitask" 2023-10-16T13:13:21.3871080Z INFO: telemetry.process: Return from creating process 2023-10-16T13:13:21.3927397Z INFO: telemetry.main: Finish creating telemetry upload process. 2023-10-16T13:13:21.4609305Z Deleted Revisions. 2023-10-16T13:13:21.4654033Z -------------------

Expected behavior

Expect that revision 2 which is the non-current revision, gets deleted.

Environment Summary

azure-cli 2.53.0

core 2.53.0 telemetry 1.1.0

Extensions: azure-devops 0.26.0

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

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Program Files\Common Files\AzureCliExtensionDirectory'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]

Additional context

No response

azure-client-tools-bot-prd[bot] commented 9 months ago
Hi @PratikModi93 Find similar issue https://github.com/Azure/azure-cli/issues/18758.
Issue title az apim product api delete - revision is ignored
Create time 2021-07-07
Comment number 3

Please confirm if this resolves your issue.

yonzhan commented 9 months ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 9 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @solankisamir, @mikebudzynski, @KedarJoshi, @yingru97.

microsoft-github-policy-service[bot] commented 9 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @solankisamir, @mikebudzynski, @KedarJoshi, @yingru97.