Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

az eventgrid system-topic update: Request body is empty when using --mi-user-assigned or --mi-system-assigned parameter #27108

Open ivanrvf-msft opened 1 year ago

ivanrvf-msft commented 1 year ago

Describe the bug

The request body is empty to update EventGrid system topic with user assigned identity or system assigned identity. This issue is only reproducible in Azure CLI cmdlet. The REST API is working as expected.

The CLI command is - https://learn.microsoft.com/en-us/cli/azure/eventgrid/system-topic?view=azure-cli-latest#az-eventgrid-system-topic-update-examples.

az eventgrid system-topic update -g Storage --name --mi-user-assigned /subscriptions//resourcegroups/tmpresources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/egst-identity

Both the parameter are in preview and not really sending any request body to update the system topic. parameters: --mi-user-assigned

--mi-system-assigned

Please help resolve this issue.

Related command

az eventgrid system-topic update -g Storage --name adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c --mi-user-assigned /subscriptions//resourcegroups/tmpresources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/egst-identity --debug

Errors

The request body is empty when you attempt to update the Event Grid system topic with user assigned identity. See Debug output in "Issue script & Debug output" section below.

Issue script & Debug output

az eventgrid system-topic update -g Storage --name adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c --mi-user-assigned /subscriptions//resourcegroups/tmpresources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/egst-identity --debug
cli.knack.cli: Command arguments: ['eventgrid', 'system-topic', 'update', '-g', 'Storage', '--name', 'adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c', '--mi-user-assigned', '/subscriptions//resourcegroups/tmpresources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/egst-identity', '','', '--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 0x7fd3ee50d1f0>, <function OutputProducer.on_global_arguments at 0x7fd3ee425d30>, <function CLIQuery.on_global_arguments at 0x7fd3ee3be310>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'eventgrid': ['azure.cli.command_modules.eventgrid'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: eventgrid 0.019 25 96 cli.azure.cli.core: Total (1) 0.019 25 96 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.125 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples cli.azure.cli.core: Total (1) 0.125 1 1
cli.azure.cli.core: Loaded 26 groups, 97 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : eventgrid system-topic update cli.azure.cli.core: Command table: eventgrid system-topic update cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fd3ed862430>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/ivan/.azure/commands/2023-08-07.16-26-12.eventgrid_system-topic_update.622.log'. az_command_data_logger: command args: eventgrid system-topic update -g {} --name {} --mi-user-assigned {} {} {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7fd3ed7df040>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7fd3ed7df310>, <function register_cache_arguments..add_cache_arguments at 0x7fd3ed7eeee0>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] msrest.serialization: principalId is not a known attribute of class <class 'azure.mgmt.eventgrid.models._models_py3.UserIdentityProperties'> and will be ignored msrest.serialization: clientId is not a known attribute of class <class 'azure.mgmt.eventgrid.models._models_py3.UserIdentityProperties'> and will be ignored cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fd3ee425dc0>, <function CLIQuery.handle_query_parameter at 0x7fd3ee3be3a0>, <function register_ids_argument..parse_ids_arguments at 0x7fd3ed7eee50>] Argument '--mi-user-assigned' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus cli.azure.cli.core.commands.client_factory: Getting management service client client_type=EventGridManagementClient urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342 urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2417 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: 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 2417 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: '1691426645' -> 1691426645 cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/82435244-8fc9-4176-bc75-0580b93de975/resourceGroups/Storage/providers/Microsoft.EventGrid/systemTopics/adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c?api-version=2021-10-15-preview' cli.azure.cli.core.sdk.policies: Request method: 'PATCH' 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': '2' cli.azure.cli.core.sdk.policies: 'Accept': 'application/json' cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '1f9af71c-353f-11ee-bbbf-bad6fe77bd74' cli.azure.cli.core.sdk.policies: 'CommandName': 'eventgrid system-topic update' cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g --name --mi-user-assigned --debug' cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.51.0 (RPM) azsdk-python-mgmt-eventgrid/10.2.0b2 Python/3.9.14 (Linux-5.4.0-1109-azure-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: {}

urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443 urllib3.connectionpool: https://management.azure.com:443 "PATCH /subscriptions//resourceGroups/Storage/providers/Microsoft.EventGrid/systemTopics/adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c?api-version=2021-10-15-preview HTTP/1.1" 200 None 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: 'Transfer-Encoding': 'chunked' cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8' cli.azure.cli.core.sdk.policies: 'Content-Encoding': 'gzip' cli.azure.cli.core.sdk.policies: 'Expires': '-1' cli.azure.cli.core.sdk.policies: 'Vary': 'Accept-Encoding' cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'a7375130-07a1-45b1-8e35-2442befd4140' cli.azure.cli.core.sdk.policies: 'Server': 'Microsoft-HTTPAPI/2.0' cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '1199' cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '43f3919f-8ae6-4241-8916-883df9d5f45a' cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTUS:20230807T162613Z:43f3919f-8ae6-4241-8916-883df9d5f45a' cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff' cli.azure.cli.core.sdk.policies: 'Date': 'Mon, 07 Aug 2023 16:26:12 GMT' cli.azure.cli.core.sdk.policies: Response content: cli.azure.cli.core.sdk.policies: {"properties":{"provisioningState":"Succeeded","source":"/subscriptions//resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/adlsdemos","topicType":"microsoft.storage.storageaccounts","metricResourceId":"fe203f41-83b4-4273-8129-5a7d3c2c733e"},"systemData":null,"identity":{"type":"None","principalId":null,"tenantId":null,"userAssignedIdentities":null},"location":"centralus","tags":{"Dept":"IT"},"id":"/subscriptions//resourceGroups/Storage/providers/Microsoft.EventGrid/systemTopics/adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c","name":"adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c","type":"Microsoft.EventGrid/systemTopics"} cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x7fd3ed82d310>, <function _x509_from_base64_to_hex_transform at 0x7fd3ed82d3a0>] cli.knack.cli: Event: CommandInvoker.OnFilterResult [] { "id": "/subscriptions//resourceGroups/Storage/providers/Microsoft.EventGrid/systemTopics/adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c", "identity": { "principalId": null, "tenantId": null, "type": "None", "userAssignedIdentities": null }, "location": "centralus", "metricResourceId": "fe203f41-83b4-4273-8129-5a7d3c2c733e", "name": "adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c", "provisioningState": "Succeeded", "resourceGroup": "Storage", "source": "/subscriptions//resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/adlsdemos", "systemData": null, "tags": { "Dept": "IT" }, "topicType": "microsoft.storage.storageaccounts", "type": "Microsoft.EventGrid/systemTopics" } cli.knack.cli: Event: Cli.SuccessfulExecute [] cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fd3ed862670>] az_command_data_logger: exit code: 0 cli.main: Command ran in 1.125 seconds (init: 0.138, invoke: 0.988) 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 3481 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/ivan/.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.

Expected behavior

The Event Grid system topic should be updated with user assigned managed identity using the following command:

az eventgrid system-topic update -g Storage --name adlsdemos-e83fb0a9-193a-4c4a-81e3-431a71327a5c --mi-user-assigned /subscriptions//resourcegroups/tmpresources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/egst-identity

The same expected result for system assigned managed identity.

Environment Summary

azure-cli 2.51.0

core 2.51.0 telemetry 1.1.0

Extensions: ai-examples 0.2.5 ml 2.19.1 ssh 2.0.1

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

Python location '/usr/bin/python3.9' Extensions directory '/home/ivan/.azure/cliextensions' Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.14 (main, Feb 8 2023, 03:39:52) [GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 year ago

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

microsoft-github-policy-service[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

SaurabhSharma-MSFT commented 1 year ago

@ivanrvf-msft I am able to reproduce this and currently investigating further for the root cause. I will update you with my findings. thanks.

microsoft-github-policy-service[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jfggdl.