Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
384 stars 1.24k forks source link

Broken idempotency for az webapp config access-restriction add --service-tag #8271

Open gabbsmo opened 22 hours ago

gabbsmo commented 22 hours ago

Describe the bug

When running a command for adding a app service restriction for a service tag twice, there will be an error.

Related command

az webapp config access-restriction add -g ResourceGroup -n AppServiceName --priority 100 --scm-site --service-tag AzureCloud

Errors

Service Tag: AzureCloud already exists. Cannot add duplicate Service Tag values.

Issue script & Debug output

DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last): File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 654, in execute File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/invocation.py", line 113, in _validation File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 921, in _validate_arg_level File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/_validators.py", line 334, in validate_service_tag File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/_validators.py", line 375, in _validate_service_tag_existence azure.cli.core.azclierror.ArgumentUsageError: Service Tag: AzureCloud already exists. Cannot add duplicate Service Tag values.

ERROR: cli.azure.cli.core.azclierror: Service Tag: AzureCloud already exists. Cannot add duplicate Service Tag values. ERROR: az_command_data_logger: Service Tag: AzureCloud already exists. Cannot add duplicate Service Tag values. DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001E020259BC0>] INFO: az_command_data_logger: exit code: 1 INFO: cli.main: Command ran in 8.079 seconds (init: 0.410, invoke: 7.669) INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1 INFO: telemetry.client: Accumulated 0 events. Flush the clients. INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1 INFO: telemetry.save: Save telemetry record of length 3917 in cache file under C:\Users\user.azure\telemetry\20241113135510233 INFO: telemetry.main: Begin creating telemetry upload process. 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 C:\Users\user.azure C:\Users\user.azure\telemetry\20241113135510233" INFO: telemetry.process: Return from creating process 9200 INFO: telemetry.main: Finish creating telemetry upload process.

Expected behavior

The command should be idempotent and not generate errors.

Environment Summary

azure-cli 2.66.0

core 2.66.0 telemetry 1.1.0

Dependencies: msal 1.31.0 azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\user.azure\cliextensions'

Python (Windows) 3.12.7 (tags/v3.12.7:0b05ead, Oct 1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 22 hours ago

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