Get-AzureRmRecoveryServicesBackupProtectionPolicy not working in automation runbook
Hi,
I am facing below issue when I am trying to run Get-AzureRmRecoveryServicesBackupProtectionPolicy through automation runbook.(This works fine when I run on poershell ISE)
Get-AzureRmRecoveryServicesBackupProtectionPolicy : Method not found: 'Newtonsoft.Json.Serialization.IAttributeProvider Newtonsoft.Json.Serialization.JsonProperty.get_AttributeProvider()'. At line:7 char:11
- $policy = Get-AzureRmRecoveryServicesBackupProtectionPolicy -AzureRmC ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [Get-AzureRmReco...rotectionPolicy], MissingMethodException
- FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupProtectionPolicy
here is the code that I am trying to run
$context = Get-AzureRmContext $recoveryServiceVault = Get-AzureRmRecoveryServicesVault -Name 'recoveryservicevaultname' -AzureRmContext $context Set-AzureRmRecoveryServicesVaultContext -Vault $recoveryServiceVault -AzureRmContext $context $policy = Get-AzureRmRecoveryServicesBackupProtectionPolicy -AzureRmContext $context $policy
@chaheti29 this appears to be a similar issue to https://github.com/Azure/azure-powershell/issues/5977, so I will close this issue in favor of that one to track the progress of the fix there.
Quick question, was this script working previously for you in Azure Automation? If so, do you remember which version of AzureRM.RecoveryServices.Backup that you used?
@cormacpayne thanks for quick reply. The current version I am using for AzureRM.RecoveryServices.Backup is 4.1.2. I have same versions on azure and local. Local seems to work fine but azure automation is not working