@@ -443,11 +443,13 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
443
443
string targetVNetResourceGroup = ( string ) ProviderData [ RestoreVMBackupItemParams . TargetVNetResourceGroup ] ;
444
444
string targetSubnetName = ( string ) ProviderData [ RestoreVMBackupItemParams . TargetSubnetName ] ;
445
445
string targetSubscriptionId = ( string ) ProviderData [ RestoreVMBackupItemParams . TargetSubscriptionId ] ;
446
-
446
+
447
447
Dictionary < UriEnums , string > uriDict = HelperUtils . ParseUri ( rp . Id ) ;
448
448
string containerUri = HelperUtils . GetContainerUri ( uriDict , rp . Id ) ;
449
449
450
- GenericResource storageAccountResource = ServiceClientAdapter . GetStorageAccountResource ( storageAccountName ) ;
450
+ if ( targetSubscriptionId == null || targetSubscriptionId == "" ) targetSubscriptionId = ServiceClientAdapter . SubscriptionId ;
451
+
452
+ GenericResource storageAccountResource = ServiceClientAdapter . GetStorageAccountResource ( storageAccountName , targetSubscriptionId ) ;
451
453
452
454
var useOsa = ShouldUseOsa ( rp , osaOption ) ;
453
455
@@ -496,7 +498,7 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
496
498
{
497
499
identityInfo = new IdentityInfo ( ) ;
498
500
if ( useSystemAssignedIdentity )
499
- {
501
+ {
500
502
identityInfo . IsSystemAssignedIdentity = true ;
501
503
}
502
504
else
@@ -511,12 +513,10 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
511
513
}
512
514
else
513
515
{
514
- throw new NotSupportedException ( Resources . MSIRestoreNotSupportedForUnmanagedVM ) ;
516
+ throw new NotSupportedException ( Resources . MSIRestoreNotSupportedForUnmanagedVM ) ;
515
517
}
516
518
}
517
-
518
- string targetSubscription = ( targetSubscriptionId != null && targetSubscriptionId != "" ) ? targetSubscriptionId : ServiceClientAdapter . SubscriptionId ;
519
-
519
+
520
520
IaasVMRestoreRequest restoreRequest = new IaasVMRestoreRequest ( )
521
521
{
522
522
CreateNewCloudService = false ,
@@ -525,7 +525,7 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
525
525
Region = vaultLocation ?? ServiceClientAdapter . BmsAdapter . GetResourceLocation ( ) ,
526
526
StorageAccountId = storageAccountResource . Id ,
527
527
SourceResourceId = rp . SourceResourceId ,
528
- TargetResourceGroupId = targetResourceGroupName != null ? "/subscriptions/" + targetSubscription + "/resourceGroups/" + targetResourceGroupName : null ,
528
+ TargetResourceGroupId = targetResourceGroupName != null ? "/subscriptions/" + targetSubscriptionId + "/resourceGroups/" + targetResourceGroupName : null ,
529
529
OriginalStorageAccountOption = useOsa ,
530
530
RestoreDiskLunList = restoreDiskLUNS ,
531
531
DiskEncryptionSetId = DiskEncryptionSetId ,
@@ -562,8 +562,8 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
562
562
}
563
563
564
564
restoreRequest . RecoveryType = RecoveryType . AlternateLocation ;
565
- restoreRequest . TargetVirtualMachineId = "/subscriptions/" + targetSubscription + "/resourceGroups/" + targetResourceGroupName + "/providers/Microsoft.Compute/virtualMachines/" + targetVMName ;
566
- restoreRequest . VirtualNetworkId = "/subscriptions/" + targetSubscription + "/resourceGroups/" + targetVNetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + targetVNetName ;
565
+ restoreRequest . TargetVirtualMachineId = "/subscriptions/" + targetSubscriptionId + "/resourceGroups/" + targetResourceGroupName + "/providers/Microsoft.Compute/virtualMachines/" + targetVMName ;
566
+ restoreRequest . VirtualNetworkId = "/subscriptions/" + targetSubscriptionId + "/resourceGroups/" + targetVNetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + targetVNetName ;
567
567
restoreRequest . SubnetId = restoreRequest . VirtualNetworkId + "/subnets/" + targetSubnetName ;
568
568
}
569
569
0 commit comments