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

--ids not working for az backup item set-policy command

Open dragonfly91 opened this issue 8 years ago • 3 comments

This command needs vault_name, container_name and item_name and my plan is to fetch all these 3 from the --ids parameter. I've declared the params like so:

    with self.argument_context('backup item') as c:
        c.argument('vault_name', vault_name_type, id_part='name')
        c.argument('container_name', container_name_type)

    with self.argument_context('backup item show') as c:
        c.argument('name', item_name_type, options_list=['--name', '-n'], help='Name of the backed up item. You can use the backup item list command to get the name of a backed up item.')

    with self.argument_context('backup item set-policy') as c:
        c.argument('vault_name', vault_name_type, id_part='child_name_3')
        c.argument('container_name', container_name_type, id_part='child_name_1')
        c.argument('item_name', item_name_type, options_list=['--name', '-n'], id_part='name', help='Name of the backed up item. You can use the backup item list command to get the name of a backed up item.')
        c.argument('policy_name', policy_name_type, help='Name of the Backup policy. You can use the backup policy list command to get the name of a backup policy.')

When I run the command, I get the following error:

(env) d:\MabOneSdk\cli>az backup item set-policy --ids "/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/vsarg-sea-RS-1606/providers/Microsoft.RecoveryServices/vaults/vsarg-sea-RS-1606/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainer;canarytestvm1;vsarg-1705-li/protectedItems/VM;iaasvmcontainer;canarytestvm1;vsarg-1705-li" -p DefaultPolicy -debug
az backup item set-policy: error: argument --ids: invalid ResourceId value: '/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/vsarg-sea-RS-1606/providers/Microsoft.RecoveryServices/vaults/vsarg-sea-RS-1606/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainer;canarytestvm1;vsarg-1705-li/protectedItems/VM;iaasvmcontainer;canarytestvm1;vsarg-1705-li'

Environment summary

Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)

Install Method: dev_setup.py
CLI Version: azure-cli (2.0.29)
OS Version: Windows 10 Enterprise
Shell Type: cmd.exe

dragonfly91 avatar Mar 13 '18 13:03 dragonfly91

There are a couple issues here:

  1. It looks like the is_valid_resource_id method (which is now in msrestazure.tools) does not recognize your ID format. You would want to open an issue there.

  2. However, even if it did you might run into another problem. You can create a dummy parameter to test this. Just call parse_resource_id on that ID. If it works, it would likely parse your container name as "IaasVMContainer;iaasvmcontainer;canarytestvm1;vsarg-1705-li" and your item name as "VM;iaasvmcontainer;canarytestvm1;vsarg-1705-li". However, per issue #4502 the command will not accept the namely formatted name.

tjprescott avatar Mar 13 '18 16:03 tjprescott

@tjprescott : is this issue fixed with merge mentioned above?

pvrk avatar Jul 30 '19 15:07 pvrk

Closing this issue since I didn't receive a response. Can be re-opened if the issue still persists.

pvrk avatar Oct 10 '19 13:10 pvrk