Azure / azure-cli

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

az network private-dns link vnet create not idempotent #28936

Open tssdavey opened 6 months ago

tssdavey commented 6 months ago

Describe the bug

Run this command twice az network private-dns link vnet create -g MyResourceGroup -n MyLinkName -z www.mysite.com -v MyVirtualNetworkId -e False

Related command

az network private-dns link vnet create

Errors

The second run errors with ERROR: (PreconditionFailed) The Virtual Network link MyLinkName for the Private DNS zone www.mysite.com exists already and hence cannot be created again. Code: PreconditionFailed

Issue script & Debug output

cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/core/polling/base_polling.py", line 517, in run self._poll() File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/core/polling/base_polling.py", line 557, in _poll raise OperationFailed("Operation failed or canceled") azure.core.polling.base_polling.OperationFailed: Operation failed or canceled

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 45, in run super().run() File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/core/polling/base_polling.py", line 535, in run raise HttpResponseError( azure.core.exceptions.HttpResponseError: (PreconditionFailed) The Virtual Network link [my link name] for the Private DNS zone [my zone name] exists already and hence cannot be created again. Code: PreconditionFailed Message: The Virtual Network link [my link name] for the Private DNS zone [my zone name] exists already and hence cannot be created again.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.60.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.60.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.60.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.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 708, in _run_job result = LongRunningOperation(cmd_copy.cli_ctx, 'Starting {}'.format(cmd_copy.name))(result) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 1013, in call raise exception File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 1000, in call result = poller.result() ^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 108, in result self.wait(timeout) File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 130, in wait raise self._exception File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 94, in _start raise error File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 86, in _start self._polling_method.run() File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 50, in run self._http_response_error_callback(err.response) File "/opt/homebrew/Cellar/azure-cli/2.60.0/libexec/lib/python3.11/site-packages/azure/cli/core/aaz/_operation.py", line 332, in on_error raise HttpResponseError(response=response, error_format=error_format) azure.core.exceptions.HttpResponseError: (PreconditionFailed) The Virtual Network link [my link name] for the Private DNS zone [my zone name] exists already and hence cannot be created again. Code: PreconditionFailed Message: The Virtual Network link [my link name] for the Private DNS zone [my zone name] exists already and hence cannot be created again.

Expected behavior

Expect the command to be idempotent and not throw an error if the resource already exists.

Environment Summary

azure-cli 2.60.0

core 2.60.0 telemetry 1.1.0

Extensions: azure-devops 1.0.0

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3' Extensions directory '/opt/az/azcliextensions'

Python (Linux) 3.11.8 (main, Apr 24 2024, 04:15:18) [GCC 9.4.0]

Additional context

No response

yonzhan commented 6 months ago

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

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

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