0

I am able to deploy VM, but when i try to use the backup vault (which is in different resource group) i am getting the following error

"The Resource 'Microsoft.RecoveryServices/vaults/rsv-hub-centralus' under resource group 'rg-hub-centralus' was not found."

In Json template here are the code

        parameters:{
        "recoveryServiceVaultName" :{
              "type" :"string",
              "metadata": {
                "description": "Existing Recovery Service Vault Name in the Subscription"
              }
            },
        }


 "variables": {
       "backupFabric": "Azure",
"backupPolicyName": "RA-standard-daily-11pm-centralus",
"v2VmType": "Microsoft.Compute/virtualMachines",
"v2VmContainer": "iaasvmcontainer;iaasvmcontainerv2;",
"v2Vm": "vm;iaasvmcontainerv2;"
      },
"resources": [
    {
  "name": "[concat(parameters('recoveryServiceVaultName'), '/', variables('backupFabric'), '/', variables('v2VmContainer'), concat(resourcegroup().name,';',parameters('vmName')), '/', variables('v2Vm'), concat(resourcegroup().name,';',parameters('vmName')))]",
  "apiVersion": "2016-06-01",
  "location": "[parameters('location')]",
  "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
  "properties": {
    "protectedItemType": "[variables('v2VmType')]",
    "policyId": "[resourceId(parameters('vaultResourceGroup'),'Microsoft.RecoveryServices/vaults/backupPolicies',parameters('recoveryServiceVaultName'),variables('backupPolicyName'))]",
    "sourceResourceId": "[resourceId(resourcegroup().name,'Microsoft.Compute/virtualMachines',parameters('vmName'))]"
  }
}
  ]

In Powershell i am calling the json file

$recoveryServiceVault = Get-AzureRmRecoveryServicesVault -ResourceGroupName "rg-hubb-recoveryservice-centralus"

$recoveryServiceVaultName = $recoveryServiceVault.Name

# Assemble template parameters
$templateParameters = @{}
$templateParameters.Add("recoveryServiceVaultName", $recoveryServiceVaultName)


New-AzureRmResourceGroup -ResourceGroupName $resourceGroupName -Location $location -Force
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile "azuredeploy.json" -TemplateParameterObject $templateParameters

resourceGroup().name in "protectionContainer" and "protectionItem" - is the resourcegroup of VM or the RSV?

raptor85
  • 125
  • 2
  • 4
  • 12

1 Answers1

0

In my opinion, it's the resourgroup of the VM. Take a look at the template property about the protectedItemId. So I think the protectedItem is the VM which you want to backup. And there is also a sample template about backup, see recovery services backup vm. The variables named with the exact resource type.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • i have used the same arm template which you have provided for recovery service backup vm i still have the same error. I have updated my variables and resource code – raptor85 Nov 29 '18 at 17:18
  • Maybe you can provide your whole template. It will be more helpful to figure out the solution. – Charles Xu Nov 30 '18 at 00:50