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

Get-AzureRmRecoveryServicesBackupContainer fails if parameter value is in different case

Open blueelvis opened this issue 8 years ago • 3 comments

Description

The Get-AzureRmRecoveryServicesBackupContainer commandlet fails if the value passed to BackupManagementType is not equal to "AzureVM". This means that if I pass in "AzureVm", the commandlet fails and returns the following -

Get-AzureRmRecoveryServicesBackupContainer : BackupManagementType provider for ContainerType AzureVM is incorrect.
At line:9 char:24
+ ... Container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-AzureRmReco...BackupContainer], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupContainer
 

If I pass in AzureVM, the commandlet works. This is not the issue with the ContainerType parameter. It accepts value in any case.

Script/Steps for Reproduction

$rsvVault = Get-AzureRmRecoveryServicesVault -ResourceGroupName "DevEnv" -Name "rsvcault"
Write-Verbose "[Info]:: Fetched the ASR Vault -- "
Write-Verbose ($rsvVault | Out-String)
Write-Verbose "[Info]:: Setting Current Vault Context"
Set-AzureRmRecoveryServicesVaultContext -Vault $rsvVault
Write-Verbose "[Info]:: Getting Backup Vault Container"
Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -BackupManagementType AzureVM
Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -BackupManagementType AzureVm

Module Version

PS C:\Users\Pranav> Get-Module -Name AzureRM -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                           
---------- -------    ----                                ----------------                                                           
Script     5.7.0      AzureRM                                                                                                        


Environment Data

PS C:\Users\Pranav> $PSVersionTable

Name                           Value                                                                                                 
----                           -----                                                                                                 
PSVersion                      5.1.17134.165                                                                                         
PSEdition                      Desktop                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                               
BuildVersion                   10.0.17134.165                                                                                        
CLRVersion                     4.0.30319.42000                                                                                       
WSManStackVersion              3.0                                                                                                   
PSRemotingProtocolVersion      2.3                                                                                                   
SerializationVersion           1.1.0.1                                                                                               

Debug Output

PS C:\Users\Pranav>  Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -BackupManagementType AzureVm -Debug
DEBUG: 01:21:26 - GetAzureRmRecoveryServicesBackupContainer begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 01:21:28 - using account id '[email protected]'...
DEBUG: Inside Restore. Going to create ResourceClient.
DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '2dfc6
a32-d03c-4504-8d69-f08da326f294'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - AcquireTokenHandlerBase: === Token Acquisition started:
	Authority: https://login.microsoftonline.com/2dfc6a32-d03c-4504-8d69-f08da326f294/
	Resource: https://management.core.windows.net/
	ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
	CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (7 items)
	Authentication Target: User
	

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/19/2018 19:51:28:  - TokenCache: Deserialized 7 items to token cache.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - TokenCache: An item matching the requested resource was found in th
e cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - TokenCache: 48.2289142183333 minutes left until token in cache expi
res

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - TokenCache: A matching item (access token or refresh token or both)
 was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 07/19/2018 19:51:28: e0445695-88e5-48e3-8a0e-ee9b72bb6621 - AcquireTokenHandlerBase: === Token Acquisition finished successfull
y. An access token was retuned:
	Access Token Hash: S+aaaa/AOs+EDK+oFcaM0kbGsOvmnYg=
	Refresh Token Hash: aaaa+Tp+aJQc=
	Expiration Time: 07/19/2018 20:39:42 +00:00
	User Hash: aaaa+nMs9cFQb/7j7XmTr72ZzC9Sw=
	

DEBUG: Client Created successfully
DEBUG: Caught exception, type: System.ArgumentException
DEBUG: Received ArgumentException
Get-AzureRmRecoveryServicesBackupContainer : BackupManagementType provider for ContainerType AzureVM is incorrect.
At line:1 char:2
+  Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -B ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-AzureRmReco...BackupContainer], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupContainer
 
DEBUG: AzureQoSEvent: CommandName - Get-AzureRmRecoveryServicesBackupContainer; IsSuccess - False; Duration - 00:00:05.0901627; Except
ion - System.ArgumentException: BackupManagementType provider for ContainerType AzureVM is incorrect.
   at Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel.PsBackupProviderManager.GetProviderInstance(ContainerType
 containerType, Nullable`1 backupManagementType)
   at Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupContainer.<ExecuteCmdlet>b__24_0()
   at Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.RecoveryServicesBackupCmdletBase.ExecutionBlock(Action action, Boolean 
shouldProcess);
DEBUG: Finish sending metric.
DEBUG: 01:21:32 - GetAzureRmRecoveryServicesBackupContainer end processing.
DEBUG: 01:21:32 - GetAzureRmRecoveryServicesBackupContainer end processing.

blueelvis avatar Jul 19 '18 19:07 blueelvis

@dragonfly91 Can you take a look at this issue?

maddieclayton avatar Jul 19 '18 20:07 maddieclayton

This is by design. There are a limited set of backup management types that you can use and we expect a single format for them.

siddharth7 avatar May 28 '19 09:05 siddharth7

@siddharth7 - I don't see why this is expected? I have never seen an Azure PowerShell commandlet which accepts predefined set of parameters in a case sensitive fashion. Please reopen this issue.

blueelvis avatar Jun 04 '19 05:06 blueelvis