Azure / Azure/azure-cli

az network private-dns link vnet create not idempotent

Open
#28,936 3 comments 0 reactions 1 assignee Claimed by @necusjz View on GitHub
act-quality-productivity-squad Auto-Assign customer-reported Network question Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### 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_

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.