Starter templates
This section contains a full set of ARM templates that can be used with the Azure Deployments connector. These templates can be used as-is, or they can be modified to meet specific needs.
Each resource created by these templates is tagged with the same set of tags. These tags include useful information about the context of the deployment, such as the name of the user who started the task and the comment they entered.
The templates make extensive use of custom data in the connector configuration. Custom data allows the user to define common parameters such as location
, vmSize
, generation
, and other parameters without needing to modify the template.
The following table lists all the custom data properties used by these templates. It specifies which templates apply to each property and whether the property is required.
R = Required, O = Optional, - = Not used
Name | Description | Default | Cache Disk | Boot Image | Machine | Layered Image |
---|---|---|---|---|---|---|
location | The region where resources are created. | Same region as the target resource group. | O | O | O | O |
gallery | The name of the compute gallery to create images in. The gallery must be in the target resource group. | - | - | R | - | R |
storageSku | The name of the SKU to use for managed disks. | StandardSSD_LRS | O | - | O | - |
generation | The generation of virtual machine. | V2 | - | O | O | O |
diskAccessId | The resource ID of the disk access used when uploading the disk contents. If this is specified, the disk is created with public network access disabled. For more information, see Azure documentation. | null | O | - | - | - |
vmSize | The size of the VM to create. | Standard_D2s_v3 | - | - | O | - |
licenseType | The on-premises license type to apply to created virtual machines. | null | - | - | O | - |
subnetId | The resource ID of the subnet to which to attach the VM’s network card. | - | - | - | R | - |
Example custom data:
{
"gallery": "MyGallery",
"subnetId": "/subscriptions/ab3d1259-f5a9-407f-bbdd-bfd5701e2e94/resourceGroups/PDGTPB/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/mysubnet"
}
<!--NeedCopy-->
Another example of custom data:
{
"location": "eastus",
"gallery": "MyGallery",
"storageSku": "Premium_LRS",
"generation": "V1",
"diskAccessId": "/subscriptions/ab3d1259-f5a9-407f-bbdd-bfd5701e2e94/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/diskAccesses/MyDiskAccess",
"vmSize": "Standard_D4s_v3",
"subnetId": "/subscriptions/ab3d1259-f5a9-407f-bbdd-bfd5701e2e94/resourceGroups/MyResourceGroup/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/mysubnet"
}
<!--NeedCopy-->
Cache Disk
Creates a managed disk.
Cache Disk custom data
Name | Description | Default | Required |
---|---|---|---|
location | The region in which resources are created. | Same region as the target resource group | no |
storageSku | The name of the SKU to use. | StandardSSD_LRS | no |
diskAccessId | The resource ID of the disk access to use when uploading the disk contents. If specified, then the disk is created with public network access disabled. | null | no |
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"al": {
"type": "object"
}
},
"variables": {
"custom": "[parameters('al').context.config.custom]",
"location": "[if(contains(variables('custom'), 'location'), variables('custom').location, resourceGroup().location)]",
"name": "[concat(parameters('al').context.item.name,'-', parameters('al').context.item.id)]",
"tags": {
"alTaskId": "[parameters('al').context.taskId]",
"alUser": "[parameters('al').context.user]",
"alComment": "[parameters('al').context.comment]",
"alItemType": "[parameters('al').context.item.type]",
"alItemId": "[parameters('al').context.item.id]",
"alItemName": "[parameters('al').context.item.name]",
"alItemVersion": "[parameters('al').context.item.version.name]",
"alConfigId": "[parameters('al').context.config.id]",
"alConfigName": "[parameters('al').context.config.name]"
},
"hasDiskAccess": "[contains(variables('custom'), 'diskAccessId')]",
"storageSku": "[if(contains(variables('custom'), 'storageSku'), variables('custom').storageSku, 'StandardSSD_LRS')]"
},
"resources": [
{
"type": "Microsoft.Compute/disks",
"apiVersion": "2021-08-01",
"name": "[variables('name')]",
"location": "[variables('location')]",
"tags": "[variables('tags')]",
"sku": {
"name": "[variables('storageSku')]"
},
"properties": {
"creationData": {
"createOption": "Upload",
"uploadSizeBytes": "[parameters('al').input.uploadSize]"
},
"incremental": "false",
"diskAccessId": "[if(variables('hasDiskAccess'), variables('custom').diskAccessId, null())]",
"networkAccessPolicy": "[if(variables('hasDiskAccess'), 'AllowPrivate', 'AllowAll')]",
"publicNetworkAccess": "[if(variables('hasDiskAccess'), 'Disabled', 'Enabled')]"
}
}
]
}
<!--NeedCopy-->
Boot Image
The Boot Image deployment creates a gallery image and image version in the gallery specified by the custom data. It outputs the ID of the created compute gallery image version for use by the Machine template.
Boot Image custom data
Name | Description | Default | Required |
---|---|---|---|
location | The region in which resources are created. | Same region as the target resource group. | no |
generation | The generation of the virtual machine used in the disk. | V2 | no |
gallery | The name of the compute gallery to create the image in. The gallery must be in the target resource group. | - | yes |
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"al": {
"type": "object"
}
},
"variables": {
"custom": "[parameters('al').context.config.custom]",
"location": "[if(contains(variables('custom'), 'location'), variables('custom').location, resourceGroup().location)]",
"tags": {
"alTaskId": "[parameters('al').context.taskId]",
"alUser": "[parameters('al').context.user]",
"alComment": "[parameters('al').context.comment]",
"alItemType": "[parameters('al').context.item.type]",
"alItemId": "[parameters('al').context.item.id]",
"alItemName": "[parameters('al').context.item.name]",
"alItemVersion": "[parameters('al').context.item.version.name]",
"alConfigId": "[parameters('al').context.config.id]",
"alConfigName": "[parameters('al').context.config.name]"
},
"name": "[concat(parameters('al').context.item.name, '.', replace(parameters('al').context.config.id, '-', ''), '.', parameters('al').context.item.id)]",
"version": "[parameters('al').context.item.version.name]",
"galleryName": "[variables('custom').gallery]",
"generation": "[if(contains(variables('custom'), 'generation'), variables('custom').generation, 'V2')]"
},
"resources": [
{
"type": "Microsoft.Compute/galleries/images",
"name": "[concat(variables('galleryName'), '/', variables('name'))]",
"apiVersion": "2021-07-01",
"location": "[variables('location')]",
"tags": "[variables('tags')]",
"properties": {
"description": "[parameters('al').context.item.description]",
"hyperVGeneration": "[variables('generation')]",
"osType": "Windows",
"osState": "Specialized",
"endOfLifeDate": "2030-01-01T00:00:00Z",
"identifier": {
"publisher": "Citrix",
"offer": "[parameters('al').context.config.id]",
"sku": "[parameters('al').context.item.id]"
}
},
"resources": [
{
"type": "versions",
"apiVersion": "2021-07-01",
"name": "[variables('version')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/galleries/images', variables('galleryName'), variables('name'))]"
],
"tags": "[variables('tags')]",
"properties": {
"publishingProfile": {
"replicaCount": 1,
"targetRegions": [
{
"name": "[variables('location')]"
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "[parameters('al').input.source.diskId]"
}
}
}
}
}
]
}
],
"outputs": {
"id": {
"type": "string",
"value": "[resourceId('Microsoft.Compute/galleries/images/versions', variables('galleryName'), variables('name'), variables('version'))]"
}
}
}
<!--NeedCopy-->
Machine
The Machine deployment creates a virtual machine, NIC, and managed disk. This template works with or without the Boot Image deployment being specified.
Machine custom data
Name | Description | Default | Required |
---|---|---|---|
location | The region in which resources are created. | Same region as the target resource group. | no |
storageSku | The name of the SKU for the created disk. | StandardSSD_LRS | no |
generation | The generation for the virtual machine. | V2 | no |
vmSize | The size of VM to create. | Standard_D2s_v3 | no |
licenseType | The on-premises license type to apply to the virtual machine. | null | no |
subnetId | The resource ID of the subnet to which to attach the NIC. | - | yes |
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"al": {
"type": "object"
}
},
"variables": {
"custom": "[parameters('al').context.config.custom]",
"location": "[if(contains(variables('custom'), 'location'), variables('custom').location, resourceGroup().location)]",
"name": "[concat('al-', parameters('al').context.taskId)]",
"vmName": "[concat(variables('name'), '-vm')]",
"nicName": "[concat(variables('name'), '-nic')]",
"diskName": "[concat(variables('name'), '-disk')]",
"diskId": "[resourceId('Microsoft.Compute/disks', variables('diskName'))]",
"tags": {
"alTaskId": "[parameters('al').context.taskId]",
"alUser": "[parameters('al').context.user]",
"alComment": "[parameters('al').context.comment]",
"alItemType": "[parameters('al').context.item.type]",
"alItemId": "[parameters('al').context.item.id]",
"alItemName": "[parameters('al').context.item.name]",
"alItemVersion": "[parameters('al').context.item.version.name]",
"alConfigId": "[parameters('al').context.config.id]",
"alConfigName": "[parameters('al').context.config.name]"
},
"source": "[parameters('al').input.disk.image]",
"isFromImage": "[not(contains(variables('source'), 'diskId'))]",
"generation": "[if(contains(variables('custom'), 'generation'), variables('custom').generation, 'V2')]",
"vmSize": "[if(contains(variables('custom'), 'vmSize'), variables('custom').vmSize, 'Standard_D2s_v3')]",
"storageSku": "[if(contains(variables('custom'), 'storageSku'), variables('custom').storageSku, 'StandardSSD_LRS')]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-11-01",
"name": "[variables('nicName')]",
"location": "[variables('location')]",
"tags": "[variables('tags')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('custom').subnetId]"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": []
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false
}
},
{
"condition": "[not(variables('isFromImage'))]",
"type": "Microsoft.Compute/disks",
"apiVersion": "2021-08-01",
"name": "[variables('diskName')]",
"location": "[variables('location')]",
"tags": "[variables('tags')]",
"sku": {
"name": "[variables('storageSku')]"
},
"properties": {
"osType": "Windows",
"hyperVGeneration": "[variables('generation')]",
"creationData": {
"createOption": "Copy",
"sourceResourceId": "[variables('source').diskId]"
},
"diskSizeGB": "[parameters('al').input.disk.size]",
"networkAccessPolicy": "DenyAll",
"publicNetworkAccess": "Disabled"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-07-01",
"name": "[variables('vmName')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"[variables('diskId')]"
],
"tags": "[variables('tags')]",
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"storageProfile": {
"imageReference": "[if(variables('isFromImage'), createObject('id', variables('source').id), null())]",
"osDisk": {
"osType": "Windows",
"createOption": "[if(variables('isFromImage'), 'FromImage', 'Attach')]",
"caching": "ReadWrite",
"deleteOption": "Delete",
"diskSizeGB": "[parameters('al').input.disk.size]",
"managedDisk": "[if(variables('isFromImage'), createObject('storageAccountType', variables('storageSku')), createObject('id', variables('diskId')))]"
},
"dataDisks": []
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"licenseType": "[if(contains(variables('custom'), 'licenseType'), variables('custom').licenseType, null())]",
"userData": "[parameters('al').input.vm.userData]"
}
}
],
"outputs": {
"diskId": {
"type": "string",
"value": "[reference(variables('vmName')).storageProfile.osDisk.managedDisk.id]"
},
"message": {
"type": "string",
"value": "[format('See [link=\"{0}/#@{1}/resource/{2}\"]{2}[/link].', environment().portal, tenant().tenantId, resourceId('Microsoft.Compute/virtualMachines', variables('vmName')))]"
}
}
}
<!--NeedCopy-->
Layered Image
The Layered Image deployment creates a gallery image and version in the gallery specified by the custom data. The image is named after the App Layering image template being published. The major and minor numbers of the version name are taken from the disk name specified in the App Layering image template. If the disk name isn’t formatted like a numeric version (number.number
), then 1.0 is used. The patch number of the version name is the version number of the App Layering image template (that is, the number of times that it’s been published).
When an image is published multiple times, a new version is added to the compute gallery image, and the old version stays.
Layered Image custom data
Name | Description | Default | Required |
---|---|---|---|
location | The region in which resources are created. | Same region as the target resource group | no |
generation | The generation of the virtual machine that the image will support. | V2 | no |
gallery | The name of the compute gallery to create the image in. The gallery must be in the target resource group. | - | yes |
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"al": {
"type": "object"
}
},
"variables": {
"invalidChars": [ " ", "(", ")", "[[", "]", "{", "}", "!", "@", "#", "$", "%", "^", "&", "*", "+", "/", "\\", "'", "\"", "|", "`", "~", "<", ">", ",", "?", "*" ],
"numericChars": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ],
"custom": "[parameters('al').context.config.custom]",
"location": "[if(contains(variables('custom'), 'location'), variables('custom').location, resourceGroup().location)]",
"name": "[join(split(parameters('al').context.item.name, variables('invalidChars')), '_')]",
"tags": {
"alTaskId": "[parameters('al').context.taskId]",
"alUser": "[parameters('al').context.user]",
"alComment": "[parameters('al').context.comment]",
"alItemType": "[parameters('al').context.item.type]",
"alItemId": "[parameters('al').context.item.id]",
"alItemName": "[parameters('al').context.item.name]",
"alItemVersion": "[parameters('al').context.item.version.name]",
"alConfigId": "[parameters('al').context.config.id]",
"alConfigName": "[parameters('al').context.config.name]"
},
"splitVer": "[split(parameters('al').input.diskName, '.')]",
"major": "[if(equals(0, length(join(split(variables('splitVer')[0], variables('numericChars')), ''))), variables('splitVer')[0], '1')]",
"minor": "[if(greater(length(variables('splitVer')), 1), if(equals(0, length(join(split(variables('splitVer')[1], variables('numericChars')), ''))), variables('splitVer')[1], '0'), '0')]",
"version": "[format('{0}.{1}.{2}', variables('major'), variables('minor'), parameters('al').context.item.version.number)]",
"galleryName": "[variables('custom').gallery]",
"generation": "[if(contains(variables('custom'), 'generation'), variables('custom').generation, 'V2')]"
},
"resources": [
{
"type": "Microsoft.Compute/galleries/images",
"name": "[format('{0}/{1}', variables('galleryName'), variables('name'))]",
"apiVersion": "2021-07-01",
"location": "[variables('location')]",
"properties": {
"description": "[parameters('al').context.item.description]",
"hyperVGeneration": "[variables('generation')]",
"osType": "Windows",
"osState": "Specialized",
"endOfLifeDate": "2030-01-01T00:00:00Z",
"identifier": {
"publisher": "AppLayering",
"offer": "[variables('name')]",
"sku": "[variables('generation')]"
}
},
"tags": "[variables('tags')]",
"resources": [
{
"type": "versions",
"apiVersion": "2020-09-30",
"name": "[variables('version')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/galleries/images', variables('galleryName'), variables('name'))]"
],
"tags": "[variables('tags')]",
"properties": {
"publishingProfile": {
"replicaCount": 1,
"targetRegions": [
{
"name": "[variables('location')]"
}
]
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "[parameters('al').input.source.diskId]"
}
}
}
}
}
]
}
],
"outputs": {
"message": {
"type": "string",
"value": "[format('See [link=\"{0}/#@{1}/resource/{2}\"]{2}[/link].', environment().portal, tenant().tenantId, resourceId('Microsoft.Compute/galleries/images/versions', variables('galleryName'), variables('name'), variables('version')))]"
}
}
}
<!--NeedCopy-->