Repository: Azure/azure-cli

Issue:
[DNS] Deleting a record requires a confirmation prompt
Deleting a record set is a potentially catastrophic operation.

For this reason, in the Portal, PowerShell, and CLI1.0, the operation has a confirmation prompt.

We need to add a similar confirmation prompt in CLI2.0. This applies to both `az network dns record-set <type> delete` and `az network dns record-set <type> remove-record`.

The prompt should be suppressible for scripting purposes (e.g. via `--yes -y` same as `az network dns zone delete`)

Discussion:

Patch:
diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py
index 0e5118830..3b6e72876 100644
--- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py
+++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/commands.py
@@ -418,7 +418,7 @@ dns_record_set_path = 'azure.mgmt.dns.operations.record_sets_operations#RecordSe
 cli_command(__name__, 'network dns record-set list', custom_path.format('list_dns_record_set'), cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output)
 for record in ['a', 'aaaa', 'mx', 'ns', 'ptr', 'srv', 'txt']:
     cli_command(__name__, 'network dns record-set {} show'.format(record), dns_record_set_path + 'get', cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output, exception_handler=empty_on_404)
-    cli_command(__name__, 'network dns record-set {} delete'.format(record), dns_record_set_path + 'delete', cf_dns_mgmt_record_sets)
+    cli_command(__name__, 'network dns record-set {} delete'.format(record), dns_record_set_path + 'delete', cf_dns_mgmt_record_sets, confirmation=True)
     cli_command(__name__, 'network dns record-set {} list'.format(record), custom_path.format('list_dns_record_set'), cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output, table_transformer=transform_dns_record_set_table_output)
     cli_command(__name__, 'network dns record-set {} create'.format(record), custom_path.format('create_dns_record_set'), transform=transform_dns_record_set_output)
     cli_command(__name__, 'network dns record-set {} add-record'.format(record), custom_path.format('add_dns_{}_record'.format(record)), transform=transform_dns_record_set_output)


Test patch:
diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/tests/test_network_commands.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/tests/test_network_commands.py
index c7c490fd5..1b0d4e81d 100644
--- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/tests/test_network_commands.py
+++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/tests/test_network_commands.py
@@ -1268,7 +1268,7 @@ class NetworkDnsScenarioTest(ResourceGroupVCRTestBase):
         self.cmd('network dns record-set {0} show -n myrs{0} -g {1} --zone-name {2}'.format('a', rg, zone_name),
             checks=NoneCheck())
 
-        self.cmd('network dns record-set {0} delete -n myrs{0} -g {1} --zone-name {2}'
+        self.cmd('network dns record-set {0} delete -n myrs{0} -g {1} --zone-name {2} -y'
                  .format('a', rg, zone_name))
         self.cmd('network dns record-set {0} show -n myrs{0} -g {1} --zone-name {2}'
                  .format('a', rg, zone_name), allowed_exceptions='does not exist in resource group')