我能够部署 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?