Get-AzureRmRecoveryServicesBackupContainer Name parameter actually filters on FriendlyName property
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
FriendlyNameis required by theNameparameter, and that it is case sensitive - Potentially altering the behavior of the
-Nameparameter to accept either the friendly name or full name. - Straighten out the case incompatibility with the
NameandFriendlyNameproperties
@pragrawa can you take a look?
@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.
Oh great I'm glad to hear it, thanks @pragrawa
This fix was done quite a while ago. Closing this issue.