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

Restore-AzureRmRecoveryServicesBackupItem command failing for azureVM

Open siddharth7 opened this issue 8 years ago • 11 comments

Description

Script/Steps for Reproduction

 Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $rp[0] -StorageAccountName 'sisisa' -StorageAccountResourceGroupName 'sisi-RSV'

Module Version

Get-Module -ListAvailable

6.12

Environment Data

$PSVersionTable

Name Value


PSVersion 5.1.17763.1 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.1 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Debug Output

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.RecoveryServices/vaults/sisi-RSV-29-6/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;sisi-rsv;sisi-vm/protectedItems/VM;iaasvmcontainerv2;sisi-rsv;sisi-vm/recoveryPoints/359635127204933/restore?api-version=2016
-12-01

Headers:
x-ms-client-request-id        : e49b211b-3495-4b82-bc45-ac743a9042ed
accept-language               : en-US

Body:
{
  "properties": {
    "objectType": "IaasVMRestoreRequest",
    "recoveryPointId": "359635127204933",
    "recoveryType": "RestoreDisks",
    "sourceResourceId": "/subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.Compute/virtualMachines/sisi-vm",
    "storageAccountId": "/subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.Storage/storageAccounts/sisisa",
    "createNewCloudService": false,
    "originalStorageAccountOption": false
  }
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
Accepted

Headers:
Pragma                        : no-cache
Retry-After                   : 60
Azure-AsyncOperation          :
https://management.azure.com/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.RecoveryServices/vaults/sisi-RSV-29-6/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;sisi-rsv;sisi-vm/protectedItems/VM;iaasvmcontainerv2;sisi-rsv;sisi-vm/operationsStatus/f02d35f2-7088-4d6e-b218-70527022ae81?a
pi-version=2016-12-01
X-Content-Type-Options        : nosniff
x-ms-request-id               : 42a29504-b354-492d-b8c0-c794c1b2bd45
x-ms-client-request-id        : 5f98b932-fdba-4935-abbe-d0dd9fa841c0-PS,5f98b932-fdba-4935-abbe-d0dd9fa841c0-PS
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id   : 42a29504-b354-492d-b8c0-c794c1b2bd45
x-ms-routing-request-id       : WESTINDIA:20181114T133935Z:42a29504-b354-492d-b8c0-c794c1b2bd45
Cache-Control                 : no-cache
Date                          : Wed, 14 Nov 2018 13:39:35 GMT
Location                      :
https://management.azure.com/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.RecoveryServices/vaults/sisi-RSV-29-6/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;sisi-rsv;sisi-vm/protectedItems/VM;iaasvmcontainerv2;sisi-rsv;sisi-vm/operationResults/f02d35f2-7088-4d6e-b218-70527022ae81?a
pi-version=2016-12-01
X-Powered-By                  : ASP.NET

Body:


DEBUG: Restore submitted
DEBUG: Tracking operation status URL for
completion:https://management.azure.com/Subscriptions/da364f0f-307b-41c9-9d47-b7413ec45535/resourceGroups/sisi-RSV/providers/Microsoft.RecoveryServices/vaults/sisi-RSV-29-6/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;sisi-rsv;sisi-vm/protectedItems/VM;iaasvmcontainerv2;sisi-rsv;sisi-vm/operationsStatus/f02d35f2-7088-4d6e-b218-705
27022ae81?api-version=2016-12-01

siddharth7 avatar Nov 14 '18 13:11 siddharth7

Issue

The region parameter in the restore request object is not able to get vault location when using the Set-AzureRmRecoveryServicesVaultContext cmdlet.

Workaround

There’s a workaround to solve this issue using a vault object.

$vault = Get-AzureRmRecoveryServicesVault -ResourceGroupName -Name $restorejob = Restore-AzureRmRecoveryServicesBackupItem -VaultID $vault.ID -VaultLocation $vault.Location -RecoveryPoint $rp[0] -StorageAccountName "DestAccount" -StorageAccountResourceGroupName "DestRG"

siddharth7 avatar Nov 14 '18 13:11 siddharth7

Hi, is this fixed? I am still facing this issue.

rupanter avatar Dec 13 '18 10:12 rupanter

Hi, this has been fixed. Try using the lastest version https://www.powershellgallery.com/packages/AzureRM.RecoveryServices.Backup/4.5.2

siddharth7 avatar Dec 13 '18 10:12 siddharth7

I am still facing the same issue :

$restorejob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $rp[0] -StorageAccountName $StorageAccountName -StorageAccountResourceGroupName $StorageAccountResourceGroup -Verbose

Restore-AzureRmRecoveryServicesBackupItem : Restore Azure Backup Item Operation failed. Error Code: CloudInvalidInputError. Error Message: The current operation failed due to an internal service error "Invalid input error". Please retry the operation after some time. At line:43 char:23

  • ... estorejob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Restore-AzureRm...vicesBackupItem], Exception
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.RestoreAzureRmRecoveryServicesBackupItem

Get-AzureRmRecoveryServicesBackupJob : Cannot validate argument on parameter 'Job'. The argument is null. Provide a valid value for the argument, and then try running the command again. At line:46 char:57

  • ... JOBID = (Get-AzureRmRecoveryServicesBackupJob -Job $restorejob).JobId
  •                                                    ~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Get-AzureRmRecoveryServicesBackupJob], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupJob

PS C:\WINDOWS\system32> Get-Module AzureRM.RecoveryServices.Backup

ModuleType Version Name ExportedCommands


Script 4.5.2 AzureRM.RecoveryServices.Backup {Backup-AzureRmRecoveryServicesBackupItem, Disable-AzureRmRecoveryServicesBackupProtection, Disable-AzureRmRecoveryServicesBackupRPMo...

rupanter avatar Dec 13 '18 17:12 rupanter

Mistake on my end. This fix went in the 2018-04-12 release and there were no AzureRM modules, only Az. You can either upgrade to Az module but you will have to update your existing scripts or you can keep using the same module and use work around by passing vault location and vault Id in the parameters as mentioned above.

siddharth7 avatar Dec 13 '18 18:12 siddharth7

I tried your workaround steps. I am getting the following error

Restore-AzureRmRecoveryServicesBackupItem : Cannot validate argument on parameter 'VaultId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:1 char:66

  • ... Restore-AzureRmRecoveryServicesBackupItem -vaultID $vault.ID -VaultL ...
  •                                                     ~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Restore-AzureRm...vicesBackupItem], ParameterBindingValidati onException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.RecoveryServices.Bac kup.Cmdlets.RestoreAzureRmRecoveryServicesBackupItem

Also upgrading the module didn't help. Any other suggestions ?

Phoenix0610 avatar Jan 11 '19 06:01 Phoenix0610

@SidFallenAngel Looking at the error, it seems like you are passing an empty object in -VaultId parameter. You need to get the vault object using $vault = Get-AzureRmRecoveryServicesVault -Name -ResourceGroupName . And pass the vault id i.e. $vault.ID

siddharth7 avatar Jan 11 '19 07:01 siddharth7

@siddharth7 Hi Sid. I tried the same. I did pass the parameter values. However when I just ran $vault to print its value, no value is getting printed. That's weird.

Phoenix0610 avatar Jan 18 '19 04:01 Phoenix0610

@SidFallenAngel Since the $vault is empty, it points to the fact that you are passing wrong params to the get-vault cmdlet. Please run $vault = Get-AzureRmRecoveryServicesVault . It will return all the vaults in your subscription. Check the $vault variable if it contains the vault you are looking for.

siddharth7 avatar Jan 21 '19 10:01 siddharth7

#customer-response-expected

pvrk avatar May 23 '19 15:05 pvrk

Since explanation was provided and the fix is provided, closing the issue.

pvrk avatar May 27 '19 18:05 pvrk