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

(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).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@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.