Guest User

Untitled

a guest
Nov 20th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.28 KB | None | 0 0
  1. {
  2. "apiVersion": "2017-05-10",
  3. "name": "nestedTemplate",
  4. "type": "Microsoft.Resources/deployments",
  5. "resourceGroup": "Env1",
  6. "dependsOn": [
  7. "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
  8. ],
  9. "properties": {
  10. "mode": "Incremental",
  11. "template": {
  12. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  13. "contentVersion": "1.0.0.0",
  14. "parameters": {},
  15. "variables": {},
  16. "resources": [
  17. {
  18. "apiVersion": "2016-06-01",
  19. "name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'))]",
  20. "location": "[resourceGroup().location]",
  21. "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
  22. "properties": {
  23. "protectedItemType": "Microsoft.Compute/virtualMachines",
  24. "policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
  25. "sourceResourceId": "[resourceId(subscription().subscriptionId, parameters('vmRsg'), 'Microsoft.Compute/virtualMachines', parameters('vmPrefix'))]"
  26. }
  27. }
  28. ]
  29. }
  30. }
  31. }
  32.  
  33. {
  34. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  35. "contentVersion": "1.0.0.0",
  36. "parameters": {
  37. "adminUsername": {
  38. "type": "string",
  39. "minLength": 1,
  40. "metadata": {
  41. "description": "Username for the Virtual Machine."
  42. }
  43. },
  44. "adminPassword": {
  45. "type": "securestring",
  46. "metadata": {
  47. "description": "Password for the Virtual Machine."
  48. }
  49. },
  50. "dnsNameForPublicIP": {
  51. "type": "string",
  52. "minLength": 1,
  53. "metadata": {
  54. "description": "Globally unique DNS Name for the Public IP used to access the Virtual Machine."
  55. }
  56. },
  57. "windowsOSVersion": {
  58. "type": "string",
  59. "defaultValue": "2012-R2-Datacenter",
  60. "allowedValues": [
  61. "2008-R2-SP1",
  62. "2012-Datacenter",
  63. "2012-R2-Datacenter"
  64. ],
  65. "metadata": {
  66. "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."
  67. }
  68. },
  69. "vmCount": {
  70. "type": "int",
  71. "defaultValue": 1
  72. },
  73. "virtualNetworkName": {
  74. "type": "string"
  75. },
  76. "dataDiskCount": {
  77. "type": "int",
  78. "defaultValue": 1
  79. },
  80. "recoveryVault": {
  81. "type": "string",
  82. "metadata": {
  83. "description": "Backup vault name"
  84. }
  85. },
  86. "recoveryPolicy": {
  87. "type": "string",
  88. "metadata": {
  89. "description": "Backcup policy name"
  90. }
  91. },
  92. "vmPrefix": {
  93. "type": "string",
  94. "metadata": {
  95. "description": "Prefix for VM names, used with vmCount to build the VM names"
  96. }
  97. },
  98. "vmRsg": {
  99. "type": "string",
  100. "metadata": {
  101. "description": "Resource group where VMs reside"
  102. }
  103. }
  104. },
  105. "variables": {
  106. "imagePublisher": "MicrosoftWindowsServer",
  107. "imageOffer": "WindowsServer",
  108. "OSDiskName": "osdiskforwindowssimple",
  109. "nicName": "myVMNic",
  110. "subnetName": "Subnet",
  111. "vhdStorageType": "Standard_LRS",
  112. "publicIPAddressName": "myPublicIP",
  113. "publicIPAddressType": "Dynamic",
  114. "vhdStorageContainerName": "vhds",
  115. "vmName": "MWindowsVM",
  116. "vmSize": "Standard_A2",
  117. "virtualNetworkName": "MyVNET",
  118. "vnetId": "[resourceId(resourceGroup().name, 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
  119. "subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]"
  120. },
  121. "resources": [
  122. {
  123. "apiVersion": "2016-03-30",
  124. "type": "Microsoft.Network/publicIPAddresses",
  125. "name": "[concat(variables('publicIPAddressName'), copyIndex(1))]",
  126. "location": "[resourceGroup().location]",
  127. "tags": {
  128. "displayName": "PublicIPAddress"
  129. },
  130. "properties": {
  131. "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
  132. "dnsSettings": {
  133. "domainNameLabel": "[concat(parameters('dnsNameForPublicIP'), copyIndex(1))]"
  134. }
  135. },
  136. "copy": {
  137. "name": "publicIpCopy",
  138. "count": "[parameters('vmCount')]"
  139. }
  140. },
  141. {
  142. "apiVersion": "2016-03-30",
  143. "type": "Microsoft.Network/networkInterfaces",
  144. "name": "[concat(variables('nicName'), copyIndex(1))]",
  145. "location": "[resourceGroup().location]",
  146. "tags": {
  147. "displayName": "NetworkInterface"
  148. },
  149. "dependsOn": [
  150. "[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'), copyIndex(1)))]"
  151. ],
  152. "properties": {
  153. "ipConfigurations": [
  154. {
  155. "name": "[concat('ipconfig', copyIndex(1))]",
  156. "properties": {
  157. "privateIPAllocationMethod": "Dynamic",
  158. "publicIPAddress": {
  159. "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIPAddressName'), copyIndex(1)))]"
  160. },
  161. "subnet": {
  162. "id": "[variables('subnetRef')]"
  163. }
  164. }
  165. }
  166. ]
  167. },
  168. "copy": {
  169. "name": "nicCopy",
  170. "count": "[parameters('vmCount')]"
  171. }
  172. },
  173. {
  174. "apiVersion": "2017-03-30",
  175. "copy": {
  176. "name": "nodeCopy",
  177. "count": "[parameters('vmCount')]"
  178. },
  179. "type": "Microsoft.Compute/virtualMachines",
  180. "name": "[concat(variables('vmName'), copyIndex(1))]",
  181. "location": "[resourceGroup().location]",
  182. "tags": {
  183. "displayName": "VirtualMachine"
  184. },
  185. "dependsOn": [
  186. "[resourceId('Microsoft.Network/networkInterfaces/', concat(variables('nicName'), copyIndex(1)))]"
  187. ],
  188. "properties": {
  189. "hardwareProfile": {
  190. "vmSize": "[variables('vmSize')]"
  191. },
  192. "osProfile": {
  193. "computerName": "[concat(variables('vmName'), copyIndex(1))]",
  194. "adminUsername": "[parameters('adminUsername')]",
  195. "adminPassword": "[parameters('adminPassword')]"
  196. },
  197. "storageProfile": {
  198. "imageReference": {
  199. "publisher": "[variables('imagePublisher')]",
  200. "offer": "[variables('imageOffer')]",
  201. "sku": "[parameters('windowsOSVersion')]",
  202. "version": "latest"
  203. },
  204. "osDisk": {
  205. "createOption": "FromImage"
  206. },
  207. "copy": [
  208. {
  209. "name": "dataDisks",
  210. "count": "[parameters('dataDiskCount')]",
  211. "input": {
  212. "diskSizeGB": 1023,
  213. "lun": "[copyIndex('dataDisks')]",
  214. "createOption": "Empty"
  215. }
  216. }
  217. ]
  218. },
  219. "networkProfile": {
  220. "networkInterfaces": [
  221. {
  222. "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex(1)))]"
  223. }
  224. ]
  225. }
  226. }
  227. },
  228. {
  229. "apiVersion": "2017-05-10",
  230. "name": "nestedTemplate",
  231. "type": "Microsoft.Resources/deployments",
  232. "resourceGroup": "Env1",
  233. "dependsOn": [
  234. "[concat('Microsoft.Compute/virtualMachines/', concat(variables('vmName'), copyIndex(1)))]"
  235. ],
  236. "properties": {
  237. "mode": "Incremental",
  238. "template": {
  239. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  240. "contentVersion": "1.0.0.0",
  241. "parameters": {},
  242. "variables": {},
  243. "resources": [
  244. {
  245. "copy": {
  246. "name": "protectedItemsCopy",
  247. "count": "[parameters('vmCount')]"
  248. },
  249. "apiVersion": "2017-03-30",
  250. "name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), copyIndex(1), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'), copyIndex(1))]",
  251. "location": "[resourceGroup().location]",
  252. "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
  253. "properties": {
  254. "protectedItemType": "Microsoft.Compute/virtualMachines",
  255. "policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
  256. "sourceResourceId": "[resourceId(subscription().subscriptionId ,parameters('vmRsg'),'Microsoft.Compute/virtualMachines', concat(parameters('vmPrefix'), copyIndex(1)) )]"
  257. }
  258. }
  259. ]
  260. }
  261. }
  262. }
  263. ]
  264. }
  265.  
  266. 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.'.
  267. The deployment validation failed
Add Comment
Please, Sign In to add comment