我正在尝试通过循环构建一组虚拟机,我想添加这些虚拟机的恢复服务库和备份策略,这适用于单个虚拟机,但是添加时出现以下错误copyIndex(1)
到friendlyName。
恢复服务部分如下:
{
"apiVersion": "2017-05-10",
"name": "[concat(parameters('VMNames'),copyIndex(1),'recoveryServicesVault')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('recoveryServicesVaultResourceGroup')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('VMNames'),copyIndex(1))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "[concat(parameters('recoveryServicesVaultName'), '/', 'Azure', '/', variables('rsvV2vm'), resourceGroup().name, ';', parameters('VMNames'), copyIndex(1))]",
"apiVersion": "2017-07-01",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/backupProtectionIntent",
"properties": {
"friendlyName": "[concat(parameters('VMNames'), copyIndex(1), 'BackupIntent')]",
"protectionIntentItemType": "AzureResourceItem",
"policyId": "[resourceId(parameters('recoveryServicesVaultResourceGroup'), 'Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryServicesVaultName'), parameters('recoveryServicesVaultBackupPolicyName'))]",
"sourceResourceId": "[resourceId(resourceGroup().name, 'Microsoft.Compute/virtualMachines', parameters('VMNames'))]"
}
}
]
}
}
}
完整代码位于: https://pastebin.com/embed_iframe/7LSB7Lkb
这可以通过循环完成吗?
答案 0 :(得分:1)
我不确定,但是您的name
备份似乎无效:
"[concat(variables('vaultName'), '/', variables('backupFabric'), '/', variables('protectionContainer'), '/', variables('protectedItem'))]",
此示例包含4个部分,只有3个部分。
https://github.com/Azure/azure-quickstart-templates/blob/master/101-recovery-services-create-vm-and-configure-backup/azuredeploy.json#L210
这也可能会有所帮助:Azure ARM JSON template - Add VM to Recovery Services Vault in different Resource Group