Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "apiVersion": "2017-05-10",
- "name": "nestedTemplate",
- "type": "Microsoft.Resources/deployments",
- "resourceGroup": "Env1",
- "dependsOn": [
- "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
- ],
- "properties": {
- "mode": "Incremental",
- "template": {
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
- "contentVersion": "1.0.0.0",
- "parameters": {},
- "variables": {},
- "resources": [
- {
- "apiVersion": "2016-06-01",
- "name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'))]",
- "location": "[resourceGroup().location]",
- "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
- "properties": {
- "protectedItemType": "Microsoft.Compute/virtualMachines",
- "policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
- "sourceResourceId": "[resourceId(subscription().subscriptionId, parameters('vmRsg'), 'Microsoft.Compute/virtualMachines', parameters('vmPrefix'))]"
- }
- }
- ]
- }
- }
- }
- {
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
- "contentVersion": "1.0.0.0",
- "parameters": {
- "adminUsername": {
- "type": "string",
- "minLength": 1,
- "metadata": {
- "description": "Username for the Virtual Machine."
- }
- },
- "adminPassword": {
- "type": "securestring",
- "metadata": {
- "description": "Password for the Virtual Machine."
- }
- },
- "dnsNameForPublicIP": {
- "type": "string",
- "minLength": 1,
- "metadata": {
- "description": "Globally unique DNS Name for the Public IP used to access the Virtual Machine."
- }
- },
- "windowsOSVersion": {
- "type": "string",
- "defaultValue": "2012-R2-Datacenter",
- "allowedValues": [
- "2008-R2-SP1",
- "2012-Datacenter",
- "2012-R2-Datacenter"
- ],
- "metadata": {
- "description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter."
- }
- },
- "vmCount": {
- "type": "int",
- "defaultValue": 1
- },
- "virtualNetworkName": {
- "type": "string"
- },
- "dataDiskCount": {
- "type": "int",
- "defaultValue": 1
- },
- "recoveryVault": {
- "type": "string",
- "metadata": {
- "description": "Backup vault name"
- }
- },
- "recoveryPolicy": {
- "type": "string",
- "metadata": {
- "description": "Backcup policy name"
- }
- },
- "vmPrefix": {
- "type": "string",
- "metadata": {
- "description": "Prefix for VM names, used with vmCount to build the VM names"
- }
- },
- "vmRsg": {
- "type": "string",
- "metadata": {
- "description": "Resource group where VMs reside"
- }
- }
- },
- "variables": {
- "imagePublisher": "MicrosoftWindowsServer",
- "imageOffer": "WindowsServer",
- "OSDiskName": "osdiskforwindowssimple",
- "nicName": "myVMNic",
- "subnetName": "Subnet",
- "vhdStorageType": "Standard_LRS",
- "publicIPAddressName": "myPublicIP",
- "publicIPAddressType": "Dynamic",
- "vhdStorageContainerName": "vhds",
- "vmName": "MWindowsVM",
- "vmSize": "Standard_A2",
- "virtualNetworkName": "MyVNET",
- "vnetId": "[resourceId(resourceGroup().name, 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
- "subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]"
- },
- "resources": [
- {
- "apiVersion": "2016-03-30",
- "type": "Microsoft.Network/publicIPAddresses",
- "name": "[concat(variables('publicIPAddressName'), copyIndex(1))]",
- "location": "[resourceGroup().location]",
- "tags": {
- "displayName": "PublicIPAddress"
- },
- "properties": {
- "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
- "dnsSettings": {
- "domainNameLabel": "[concat(parameters('dnsNameForPublicIP'), copyIndex(1))]"
- }
- },
- "copy": {
- "name": "publicIpCopy",
- "count": "[parameters('vmCount')]"
- }
- },
- {
- "apiVersion": "2016-03-30",
- "type": "Microsoft.Network/networkInterfaces",
- "name": "[concat(variables('nicName'), copyIndex(1))]",
- "location": "[resourceGroup().location]",
- "tags": {
- "displayName": "NetworkInterface"
- },
- "dependsOn": [
- "[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'), copyIndex(1)))]"
- ],
- "properties": {
- "ipConfigurations": [
- {
- "name": "[concat('ipconfig', copyIndex(1))]",
- "properties": {
- "privateIPAllocationMethod": "Dynamic",
- "publicIPAddress": {
- "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIPAddressName'), copyIndex(1)))]"
- },
- "subnet": {
- "id": "[variables('subnetRef')]"
- }
- }
- }
- ]
- },
- "copy": {
- "name": "nicCopy",
- "count": "[parameters('vmCount')]"
- }
- },
- {
- "apiVersion": "2017-03-30",
- "copy": {
- "name": "nodeCopy",
- "count": "[parameters('vmCount')]"
- },
- "type": "Microsoft.Compute/virtualMachines",
- "name": "[concat(variables('vmName'), copyIndex(1))]",
- "location": "[resourceGroup().location]",
- "tags": {
- "displayName": "VirtualMachine"
- },
- "dependsOn": [
- "[resourceId('Microsoft.Network/networkInterfaces/', concat(variables('nicName'), copyIndex(1)))]"
- ],
- "properties": {
- "hardwareProfile": {
- "vmSize": "[variables('vmSize')]"
- },
- "osProfile": {
- "computerName": "[concat(variables('vmName'), copyIndex(1))]",
- "adminUsername": "[parameters('adminUsername')]",
- "adminPassword": "[parameters('adminPassword')]"
- },
- "storageProfile": {
- "imageReference": {
- "publisher": "[variables('imagePublisher')]",
- "offer": "[variables('imageOffer')]",
- "sku": "[parameters('windowsOSVersion')]",
- "version": "latest"
- },
- "osDisk": {
- "createOption": "FromImage"
- },
- "copy": [
- {
- "name": "dataDisks",
- "count": "[parameters('dataDiskCount')]",
- "input": {
- "diskSizeGB": 1023,
- "lun": "[copyIndex('dataDisks')]",
- "createOption": "Empty"
- }
- }
- ]
- },
- "networkProfile": {
- "networkInterfaces": [
- {
- "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex(1)))]"
- }
- ]
- }
- }
- },
- {
- "apiVersion": "2017-05-10",
- "name": "nestedTemplate",
- "type": "Microsoft.Resources/deployments",
- "resourceGroup": "Env1",
- "dependsOn": [
- "[concat('Microsoft.Compute/virtualMachines/', concat(variables('vmName'), copyIndex(1)))]"
- ],
- "properties": {
- "mode": "Incremental",
- "template": {
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
- "contentVersion": "1.0.0.0",
- "parameters": {},
- "variables": {},
- "resources": [
- {
- "copy": {
- "name": "protectedItemsCopy",
- "count": "[parameters('vmCount')]"
- },
- "apiVersion": "2017-03-30",
- "name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), copyIndex(1), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'), copyIndex(1))]",
- "location": "[resourceGroup().location]",
- "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
- "properties": {
- "protectedItemType": "Microsoft.Compute/virtualMachines",
- "policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
- "sourceResourceId": "[resourceId(subscription().subscriptionId ,parameters('vmRsg'),'Microsoft.Compute/virtualMachines', concat(parameters('vmPrefix'), copyIndex(1)) )]"
- }
- }
- ]
- }
- }
- }
- ]
- }
- Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource 'nestedTemplate' at line '198' and column '10' is not valid: The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-copy for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.
- The deployment validation failed
Add Comment
Please, Sign In to add comment