Set-AzRecoveryServicesAsrReplicationProtectedItem System.NullReferenceException on GetValueFromArmId
Description
Running Set-AzRecoveryServicesAsrReplicationProtectedItem on a ASR Vault using Managed Disks, for a Vmware->Azure DR solution, yields "Object reference not set to an instance of an object"
Steps to reproduce
...
Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $pitem -Name "TESTVM" `
-LicenseType WindowsServer -Size Standard_F2s_v2 -UseManagedDisk $True `
-RecoveryResourceGroupId $pitem.RecoveryResourceGroupId `
-RecoveryNetworkId $pitem.NicDetailsList[0].RecoveryVMNetworkId `
-RecoveryNicSubnetName $pitem.NicDetailsList[0].RecoveryVMSubnetName `
-PrimaryNic $pitem.NicDetailsList[0].NicId -Debug
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.590
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.590
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
Get-Module -Name Az.* -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.0 Az.Accounts {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection, En...
Script 1.0.1 Az.Aks {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredential...}
Script 1.0.2 Az.AnalysisServices {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServer, Get-AzAnalysi...
Script 1.0.0 Az.ApiManagement {Add-AzApiManagementRegion, Get-AzApiManagementSsoToken, New-AzApiManagementCusto...
Script 1.0.0 Az.ApplicationInsights {Get-AzApplicationInsights, New-AzApplicationInsights, Remove-AzApplicationInsigh...
Script 1.1.2 Az.Automation {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWorkerGroup, Get-AzA...
Script 1.0.0 Az.Batch {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAccountKeys, New-AzBatchAc...
Script 1.0.0 Az.Billing {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollmentAccount, Get-AzConsum...
Script 1.1.0 Az.Cdn {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile, Remove-AzCdnProfile...}
Script 1.0.1 Az.CognitiveServices {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAccountKey, Get-AzCogniti...
Script 1.5.0 Az.Compute {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabilitySet, Update-A...
Script 1.0.0 Az.ContainerInstance {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzContainerGroup, Get-AzConta...
Script 1.0.1 Az.ContainerRegistry {New-AzContainerRegistry, Get-AzContainerRegistry, Update-AzContainerRegistry, Re...
Script 1.0.2 Az.DataFactory {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFactoryV2, Remove-AzDataF...
Script 1.0.0 Az.DataLakeAnalytics {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalyticsCatalogCredential, Rem...
Script 1.1.0 Az.DataLakeStore {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreTrustedIdProvider, R...
Script 1.0.0 Az.DevTestLabs {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolicy, Get-AzDtlAutoStartPo...
Script 1.0.0 Az.Dns {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRecordSet, Set-AzDnsRecor...
Script 1.1.0 Az.EventGrid {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGridTopic, New-AzEventGri...
Script 1.0.1 Az.EventHub {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHubNamespace, Remov...
Script 1.0.0 Az.HDInsight {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wait-AzHDInsightJob, New-...
Script 1.0.2 Az.IotHub {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-AzIotHubConnectionString...
Script 1.0.2 Az.KeyVault {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-AzKeyVaultCertific...
Script 1.2.1 Az.LogicApp {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountAssembly, Get-AzInteg...
Script 1.0.0 Az.MachineLearning {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssociation, Get-AzMlCommitmen...
Script 1.0.0 Az.MarketplaceOrdering {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script 1.0.0 Az.Media {Sync-AzMediaServiceStorageKeys, Set-AzMediaServiceKey, Get-AzMediaServiceKeys, G...
Script 1.0.1 Az.Monitor {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-AzLogProfile...}
Script 1.4.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplicationGatewayAuthe...
Script 1.3.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplicationGatewayAuthe...
Script 1.0.0 Az.NotificationHubs {Get-AzNotificationHub, Get-AzNotificationHubAuthorizationRules, Get-AzNotificati...
Script 1.1.0 Az.OperationalInsights {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOperationalInsightsCu...
Script 1.0.0 Az.PolicyInsights {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSummary, Get-AzPolicyReme...
Script 1.0.0 Az.PowerBIEmbedded {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspaceCollection, Get-AzPow...
Script 1.1.0 Az.RecoveryServices {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVault, Get-AzRecover...
Script 1.0.0 Az.RedisCache {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheScheduleEntry, Get-AzRedisCach...
Script 1.0.0 Az.Relay {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNamespace, Remove-AzRelay...
Script 1.2.0 Az.Resources {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, New-AzRo...
Script 1.0.0 Az.ServiceBus {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set-AzServiceBusNamespace,...
Script 1.0.1 Az.ServiceFabric {Add-AzServiceFabricApplicationCertificate, Add-AzServiceFabricClientCertificate,...
Script 1.0.2 Az.SignalR {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSignalRKey...}
Script 1.5.0 Az.Sql {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTransparentDataEncr...
Script 1.0.3 Az.Storage {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAccount, New-AzStora...
Script 1.0.0 Az.StreamAnalytics {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefaultFunctionDefinition, N...
Script 1.0.1 Az.TrafficManager {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTrafficManagerCustomHeaderF...
Script 1.1.1 Az.Websites {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan, Remove-AzAppSe...
Debug output
…
Set-AzureRmRecoveryServicesAsrReplicationProtectedItem : Operation failed.
ClientRequestId: 29605ad7-12a0-40f4-98da-14ad03e9ce9f-2019-03-22 11:06:03Z-Ps
Object reference not set to an instance of an object.
At line:2 char:1
+ Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzRecoveryS...onProtectedItem], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrReplicationProtectedItem
DEBUG: AzureQoSEvent: CommandName - Set-AzRecoveryServicesAsrReplicationProtectedItem; IsSuccess - False; Duration - 00:00:01.0298070; Exceptio
n - System.Exception: Operation failed.
ClientRequestId: 29605ad7-12a0-40f4-98da-14ad03e9ce9f-2019-03-22 11:06:03Z-Ps
Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.Utilities.GetValueFromArmId(String armId, String key)
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrReplicationProtectedItem.ExecuteSiteRecoveryCmdlet()
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
--- End of inner exception stack trace ---
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.HandleException(Exception ex)
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 11:06:05 - SetAzureRmRecoveryServicesAsrReplicationProtectedItem end processing.
DEBUG: 11:06:05 - SetAzureRmRecoveryServicesAsrReplicationProtectedItem end processing.
Error output
HistoryId: 17
Message : Operation failed.
ClientRequestId: 29605ad7-12a0-40f4-98da-14ad03e9ce9f-2019-03-22 11:06:03Z-Ps
Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.HandleException(Exception ex)
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.Exception
InvocationInfo : {Set-AzRecoveryServicesAsrReplicationProtectedItem}
Line : Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $pitem -Name "TESTVM" `
Position : At line:2 char:1
+ Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 17
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.Utilities.GetValueFromArmId(String armId, String key)
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrReplicationProtectedItem.ExecuteSit
eRecoveryCmdlet()
at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
Exception : System.NullReferenceException
InvocationInfo : {Set-AzRecoveryServicesAsrReplicationProtectedItem}
Line : Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $pitem -Name "TESTVM" `
Position : At line:2 char:1
+ Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 17
...
@siddharth7 Could you take a look?
I'm also experiencing this same error (with the same stacktrace) when using the Update-AzureRmRecoveryServicesAsrProtectionDirection cmdlet for AzureToAzure replication
This is owned by ASR team, adding @viverm
@viverm - Any progress? I'm using Az module 2.2.0 and it's still broken.
Is it VMware to Azure replicating to managed disk scenario ? With current powershell version it is not supported.
we have active PR to https://github.com/Azure/azure-powershell/pull/9304 to the ASR preview module. Changes will be available soon in public preview module.
Yes, VMware to Azure using ASR. This cmdlet has worked in the past and now I have no way of setting ASR recovered VM settings except via the web portal at this point.
@jlouie1 cmdlet would work fine for non managed disk scenario. Can you add the stack trace [run the cmdlet with -debug] for the issue, it will help in checking the issue is same or not. we are working on this soon the support will be available. [within ~1 week]
Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -InputObject $vminfo01 -LicenseType WindowsServer -NicSelectionType SelectedByUser -PrimaryNic $vminfo01.NicDetailsList.NicId
-RecoveryNetworkId /subscriptions/0c4b908f-4c31-4c3e-a3bf-50fdad9a7647/resourceGroups/RG-CRP01-DR01-SCUS-MasterRG/providers/Microsoft.Network/virtualNetworks/VN-DR01-SCUS
-RecoveryNicStaticIPAddress $vmIP -RecoveryNicSubnetName $vmSubnet -UseManagedDisk True -Debug
Set-AzureRmRecoveryServicesAsrReplicationProtectedItem : Operation failed. ClientRequestId: 5463d9a7-34c1-4ad0-8012-506f0c9886f6-2019-06-11 13:35:01Z-Ps Object reference not set to an instance of an object. At line:7 char:9
-
Set-AzureRmRecoveryServicesAsrReplicationProtectedItem -Input ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : CloseError: (:) [Set-AzRecoveryS...onProtectedItem], Exception
- FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrReplicationProtectedItem
DEBUG: AzureQoSEvent: CommandName - Set-AzRecoveryServicesAsrReplicationProtectedItem; IsSuccess - False; Duration - 00:00:26.0334291; Exception - System.Exception: Operation failed. ClientRequestId: 5463d9a7-34c1-4ad0-8012-506f0c9886f6-2019-06-11 13:35:01Z-Ps Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.Utilities.GetValueFromArmId(String armId, String key) at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrReplicationProtectedItem.ExecuteSiteRecoveryCmdlet() at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet() --- End of inner exception stack trace --- at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.HandleException(Exception ex) at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DEBUG: Finish sending metric. DEBUG: 9:35:09 AM - SetAzureRmRecoveryServicesAsrReplicationProtectedItem end processing. DEBUG: 9:35:09 AM - SetAzureRmRecoveryServicesAsrReplicationProtectedItem end processing.
Hi @viverm any news on a fix?
It works again in latest modules. Thanks!
Get-installedModule -Name Az 2.4.0 Az
Get-installedModule -Name Az.recoveryservices 1.4.2 Az.RecoveryServices
Install-Module -Name Az.RecoveryServices -AllowPrerelease
Az.RecoveryServices 2.0.0-preview is released.
I'm getting this when I try to update to 2.0.0 preview:
Install-Module : A parameter cannot be found that matches parameter name 'AllowPrerelease'.
Already running Az.RecoveryServices 1.4.2. `Version Name Repository Description
1.4.2 Az.RecoveryServices PSGallery Microsoft Azure PowerShell - Recovery Services c...`
Any ideas what's going on?
I had to update PowerShellGet: Install-Module –Name PowerShellGet –Force
I tried that, as well as updating PackageManagement as suggested here: https://github.com/MicrosoftDocs/azure-docs/issues/29999
Still no luck.
After updating to az.recoveryservices to 2.0.0-preview the "Object reference not set to an instance of an object." is gone, but I get the following "WARNING: Please provide both Source Nic and Recovery Target to update" all parameters seem to be present:
PS C:\asr\> Set-AzRecoveryServicesAsrReplicationProtectedItem
-InputObject $protecteditems[0]
-PrimaryNic $protecteditems[0].NicDetailsList.NicId
-RecoveryNicStaticIPAddress "10.22.14.250"
-RecoveryNetworkId '/subscriptions/<subscriptionid>/resourceGroups/<resource group>/providers/Microsoft.Network/virtualNetworks/vnet01'
-RecoveryNicSubnetName "Servers"
-Name $protecteditems[0].friendlyName
-RecoveryResourceGroupId "/subscriptions/<subscriptionid>/resourceGroups/rg01"
-Size standard_a2
-LicenseType WindowsServer
-UseManagedDisk True
use property update nic instead of primary nic . Breaking changes for 2.0.0
PS C:\asr> Set-AzRecoveryServicesAsrReplicationProtectedItem -InputObject $protecteditems[0]
-updateNic
$protecteditems[0].NicDetailsList.NicId -RecoveryNicStaticIPAddress "10.22.14.250" -RecoveryNetworkId '/subscriptions/