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

Get-AzureRmRecoveryServicesBackupContainer Name parameter actually filters on FriendlyName property

Open anyasabo opened this issue 10 years ago • 4 comments

Related to https://github.com/Azure/azure-powershell/issues/2251

I noticed that the Name parameter filters solely on the FriendlyName property of the container and not the Name property like you may expect given the...name.

But using Get-AzureRmRecoveryServicesBackupContainer without a Name parameter prints out the Name property without the FriendlyName property. This can be really confusing when you list out all containers in a resource group, then copy and paste the name returned into the -Name parameter and you get no results.

It's exacerbated too because the name field is all lowercase, but as described in this initial issue the FriendlyName field is mixed case. So even if you copy and paste out the last bit of the canonical name, it still returns no results.

Example follows, sorry for the formatting:

Get-AzureRmRecoveryServicesBackupContainer  -ContainerType AzureVM –Status Registered -ResourceGroupName Resource-Group1

Name                                     ResourceGroupName                        Status               ContainerType       
----                                     -----------------                        ------               -------------       
iaasvmcontainerv2;resource-group1;gp-template Resource-Group1                              Registered           AzureVM             
...

Get-AzureRmRecoveryServicesBackupContainer  -ContainerType AzureVM –Status Registered -ResourceGroupName Resource-Group1 -Name gp-template
[no results]

Get-AzureRmRecoveryServicesBackupContainer  -ContainerType AzureVM –Status Registered -ResourceGroupName Resource-Group1 -Name "iaasvmcontainerv2;resource-group1;gp-template"
[no results]

Get-AzureRmRecoveryServicesBackupContainer  -ContainerType AzureVM –Status Registered -ResourceGroupName Resource-Group1 -Name GP-Template

Name                                     ResourceGroupName                        Status               ContainerType       
----                                     -----------------                        ------               -------------       
iaasvmcontainerv2;resource-group1;gp-template Resource-Group1                              Registered           AzureVM             

My hint was using the -Debug option and I noticed that the filter in the URI Absolute Uri: https://management.azure.com/Subscriptions/redacted/resourceGroups/Resource-Group1/providers/Microsoft.RecoveryServices/vaults/redacted/backupProtectionContainers?api-version=2016-05-01&$filt er=backupManagementType eq 'AzureIaasVM' and status eq 'Registered' and friendlyName eq 'gp-template'

I feel like there are a few potential improvements to be made:

  • Improving the docs so that it is clear that the FriendlyName is required by the Name parameter, and that it is case sensitive
  • Potentially altering the behavior of the -Name parameter to accept either the friendly name or full name.
  • Straighten out the case incompatibility with the Name and FriendlyName properties

anyasabo avatar Jun 27 '16 17:06 anyasabo

@pragrawa can you take a look?

markcowl avatar Jun 28 '16 20:06 markcowl

@jonsabo Thanks for pointing out this issue. In the upcoming powershell release, we are deprecating Name parameter and adding FriendlyName parameter. So this will avoid confusion. Also, FriendlyName will be case sensitive due to backend limitation. We will update the doc for this commandlet.

pragrawa avatar Jun 30 '16 22:06 pragrawa

Oh great I'm glad to hear it, thanks @pragrawa

anyasabo avatar Jul 01 '16 19:07 anyasabo

This fix was done quite a while ago. Closing this issue.

dragonfly91 avatar Oct 31 '17 08:10 dragonfly91