0

我能够部署 VM,但是当我尝试使用备份库(位于不同的资源组中)时,我收到以下错误

“找不到资源组 'rg-hub-centralus' 下的资源 'Microsoft.RecoveryServices/vaults/rsv-hub-centralus'。”

在 Json 模板中,这里是代码

        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'))]"
  }
}
  ]

在 Powershell 中,我正在调用 json 文件

$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

“protectionContainer”和“protectionItem”中的resourceGroup().name - 是VM 的资源组还是RSV?

4

1 回答 1

0

在我看来,它是虚拟机的资源组。查看有关protectedItemId的模板属性。所以我认为 protectedItem 是您要备份的虚拟机。还有一个关于备份的示例模板,请参阅recovery services backup vm。以确切资源类型命名的变量。

于 2018-11-29T07:04:05.480 回答