azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

'az network dns record-set txt add-record' is not idempotent

Open jurjenoskam opened this issue 7 years ago • 17 comments

(azure-cli 2.0.72, did not try earlier versions) The command:

$ az network dns record-set txt add-record -g resourcegroup -z dns-zone-name.example.com -n example-record -v example-value

runs fine the first time, but subsequent invocations result in the following error:

Operation failed with status: 'Bad Request'. Details: The list of record sets of type 'TXT' may not contain multiple entries with the same 'value'.

In the spirit of https://github.com/Azure/azure-cli/blob/dev/doc/command_guidelines.md#standard-command-types I believe the subsequent operations should not result in an error, but should be a no-op instead (making this command idempotent).

jurjenoskam avatar Sep 07 '19 08:09 jurjenoskam

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

ghost avatar Sep 08 '19 05:09 ghost

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

ghost avatar Sep 08 '19 05:09 ghost

@jurjenoskam Hello. I will double check the logic for this command.

mmyyrroonn avatar Sep 08 '19 06:09 mmyyrroonn

Any update on this? Thanks!

tbennett0 avatar Mar 27 '20 21:03 tbennett0

add to S168

yonzhan avatar Mar 28 '20 01:03 yonzhan

@jurjenoskam, @tbennett0,

  • I think this is by design and aligned with Azure portal and you can find the doc: A record set cannot contain two identical records.
  • Below is the http log from this command and you can see the error is from backend service.

image

jsntcy avatar May 14 '20 09:05 jsntcy

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

ghost avatar May 15 '20 09:05 ghost

@jsntcy I am aware that there can't be two identical records in a record set, and I am aware the backend service returns an error if you try (although you could argue that the backend service PUT call should itself be idempotent, but that's another subject)

The point is that it would be very useful if Azure CLI commands were idempotent, as described in the command guidelines mentioned above.

If the Azure CLI command for adding a DNS record would be idempotent, it would only return an error when the end result is that the record is different from what is specified in the command. This allows my scripts to become much simpler: I only have to handle the situation when the record does not contain what I want it to contain. As it is now, I have to insert logic to check whether the data I'm trying to add is already there, and skip adding it if it is.

jurjenoskam avatar May 15 '20 09:05 jurjenoskam

@jurjenoskam, thanks for sharing your thoughts. We'll discuss internally about this issue to come up with a general guideline for such scenarios as this should be a general issue for all services.

jsntcy avatar May 22 '20 06:05 jsntcy

We will look into how other azure resources handle this scenario

karravi-msft avatar Jul 23 '20 21:07 karravi-msft

Hi, any update to this?

nc-ruth avatar Aug 24 '20 12:08 nc-ruth

I've had the same issue. Running the exact build script twice causes this error. azure-cli version is 2.9.1

az network private-dns record-set a add-record  --resource-group  ria-poc-rg  --zone-name       privatelink.azurecr.io   --record-set-name zahrpocriaacr  --ipv4-address    10.214.11.36
Operation failed with status: 'Bad Request'. Details: The list of record sets of type 'A' may not contain multiple entries with the same 'ipv4Address'.

hectoralicea avatar Oct 14 '20 16:10 hectoralicea

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

ghost avatar Oct 14 '20 16:10 ghost

Any news on this?

vdias avatar Aug 03 '21 14:08 vdias

@karravi-msft, any update on this issue?

jsntcy avatar Aug 04 '21 01:08 jsntcy

Will fix in Azure CLi this sprint and release the fix in 09/07

jsntcy avatar Aug 05 '21 03:08 jsntcy

@00Kai0, Remove duplicate items in record-set before calling "create_or_update".

jsntcy avatar Aug 10 '21 03:08 jsntcy