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 | Type | Description | Default | Cache Disk | Boot Image | Machine | Layered Image |
|---|---|---|---|---|---|---|---|
| location | string | The region where resources are created. | Same region as the target resource group. | O | O | O | O |
| gallery | string | The name of the compute gallery to create images in. The gallery must be in the target resource group. | - | - | R | - | R |
| storageSku | string | The name of the SKU to use for managed disks. | “StandardSSD_LRS” | O | - | O | - |
| NVMe | boolean |
true to use NVMe disk controllers, false otherwise. This must be the same value for all deployment types. |
false |
O | O | O | O |
| generation | string | The generation of virtual machine. | “V2” | - | O | O | O |
| trustedLaunch | boolean |
true to enable Trusted Launch, false otherwise. This must be the same value for all deployment types. |
false |
O | O | O | O |
| diskAccessId | string | 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 | string | The size of the VM to create. | “Standard_D2s_v3” | - | - | O | - |
| prefix | string | A prefix to prepend to the name of resources created by the machine deployment | “al-“ | - | - | O | - |
| licenseType | string | The on-premises license type to apply to created virtual machines. | null |
- | - | O | - |
| subnetId | string | The resource ID of the subnet to which to attach the VM’s network card. | - | - | - | R | - |
| acceleratedNetworking | boolean |
true to enable accelerated networking, false otherwise. This must be the same value for all deployment types. |
false |
O | O | O | O |
| replicaCount | number | The default number of replicas per region of the gallery image version | 1 | - | - | - | O |
| imageStorageAccountType | string | Specifies the storage account type to be used to store the image. | “Standard_LRS” | - | - | - | O |
| targetRegions | array | The target regions of the gallery image version. This is specified as an array of region name strings and/or TargetRegion objects. The array must contain the region of the source disk (which is specified by the location custom data). |
The region specified by the location custom data |
- | - | - | O |
| publishAs | string or array | The type of resource(s) to publish images as. Specified as an array or string consisting of ‘galleryImage’ and/or ‘managedDisk’ | [“galleryImage”] | - | - | - | O |
| diskNameFormat | string | Controls the name of images published as managed disks. “version” to append the version to the image name, “timestamp” to append the time of publish. | “version” | - | - | - | O |
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",
"trustedLaunch": true,
"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",
"replicaCount": 2,
"targetRegions": [
"eastus",
{
"name": "eastus2",
"regionalReplicaCount": 5,
"storageAccountType": "Premium_LRS"
},
"westus"
]
}
<!--NeedCopy-->
Cache Disk
Creates a managed disk.
Cache Disk custom data
| Name | Type | Description | Default | Required |
|---|---|---|---|---|
| location | string | The region in which resources are created. | Same region as the target resource group | no |
| storageSku | string | The name of the SKU to use. | “StandardSSD_LRS” | no |
| NVMe | boolean |
true to enable NVMe disk controllers, false otherwise. This must be the same value for all deployment types. |
false |
no |
| acceleratedNetworking | boolean |
true to enable accelerated networking, false otherwise. This must be the same value for all deployment types. |
false |
no |
| trustedLaunch | boolean |
true to enable Trusted Launch, false otherwise. This must be the same value for all deployment types. |
false |
no |
| diskAccessId | string | The resource ID of the disk access to use when uploading the disk contents. If specified, the disk is created with public network access disabled. | null |
no |
Cache Disk template
- 1.2.0.0 - Added support for accelerated networking and NVMe disk controllers
- 1.1.0.0 - Added support for Trusted Launch
- 1.0.0.0 - Initial version
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.2.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')]",
"trustedLaunch": "[if(contains(variables('custom'), 'trustedLaunch'), variables('custom').trustedLaunch, false())]",
"acceleratedNetworking": "[if(contains(variables('custom'), 'acceleratedNetworking'), variables('custom').acceleratedNetworking, false())]",
"NVMe": "[if(contains(variables('custom'), 'NVMe'), variables('custom').NVMe, false())]"
},
"resources": [
{
"type": "Microsoft.Compute/disks",
"apiVersion": "2024-03-02",
"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')]",
"securityProfile": "[if(variables('trustedLaunch'), createObject('securityType', 'TrustedLaunch'), null())]",
"supportedCapabilities": {
"diskControllerTypes": "[if(variables('NVMe'), 'NVMe, SCSI', 'SCSI')]",
"acceleratedNetwork": "[variables('acceleratedNetworking')]"
}
}
}
]
}
<!--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 | Type | Description | Default | Required |
|---|---|---|---|---|
| location | string | The region in which resources are created. | Same region as the target resource group. | no |
| generation | string | The generation of the virtual machine used in the disk. | “V2” | no |
| NVMe | boolean |
true to enable NVMe disk controllers, false otherwise. This must be the same value for all deployment types. |
false |
no |
| acceleratedNetworking | boolean |
true to enable accelerated networking, false otherwise. This must be the same value for all deployment types. |
false |
no |
| trustedLaunch | boolean |
true to enable Trusted Launch, false otherwise. This must be the same value for all deployment types. |
false |
no |
| gallery | string | The name of the compute gallery to create the image in. The gallery must be in the target resource group. | - | yes |
Boot Image template
- 1.2.0.0 - Added support for accelerated networking and NVMe disk controllers
- 1.1.0.0 - Added support for Trusted Launch
- 1.0.0.0 - Initial version
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.2.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')]",
"acceleratedNetworking": "[if(contains(variables('custom'), 'acceleratedNetworking'), variables('custom').acceleratedNetworking, false())]",
"NVMe": "[if(contains(variables('custom'), 'NVMe'), variables('custom').NVMe, false())]",
"trustedLaunch": "[if(contains(variables('custom'), 'trustedLaunch'), variables('custom').trustedLaunch, false())]",
"possibleFeatures": [
{
"include": "[variables('trustedLaunch')]",
"feature": {
"name": "SecurityType",
"value": "TrustedLaunch"
}
},
{
"include": "[variables('acceleratedNetworking')]",
"feature": {
"name": "IsAcceleratedNetworkSupported",
"value": "True"
}
},
{
"include": "[variables('NVMe')]",
"feature": {
"name": "DiskControllerTypes",
"value": "NVMe, SCSI"
}
}
]
},
"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]",
"features": "[map(filter(variables('possibleFeatures'), lambda('x', lambdaVariables('x').include)), lambda('x', lambdaVariables('x').feature))]",
"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 | Type | Description | Default | Required |
|---|---|---|---|---|
| location | string | The region in which resources are created. | Same region as the target resource group. | no |
| storageSku | string | The name of the SKU for the created disk. | “StandardSSD_LRS” | no |
| generation | string | The generation for the virtual machine. | “V2” | no |
| NVMe | boolean |
true to use NVMe disk controllers, false otherwise. This must be the same value for all deployment types. |
false |
no |
| acceleratedNetworking | boolean |
true to enable accelerated networking, false otherwise. This must be the same value for all deployment types. |
false |
no |
| trustedLaunch | boolean |
true to enable Trusted Launch, false otherwise. This must be the same value for all deployment types. |
false |
no |
| secureBoot | boolean |
true to enable Secure Boot, false otherwise. This is only applied if trustedLaunch is set to true. |
true |
no |
| vTpm | boolean |
true to enable the vTPM, false otherwise. This is only applied if trustedLaunch is set to true. |
true |
no |
| vmSize | string | The size of VM to create. | “Standard_D2s_v3” | no |
| licenseType | string | The on-premises license type to apply to the virtual machine. | null |
no |
| subnetId | string | The resource ID of the subnet to which to attach the NIC. | - | yes |
| prefix | string | A prefix to prepend to the name of created resources | “al-“ | no |
Machine template
- 1.2.0.0
- Added support for accelerated networking
- Added support for NVMe disk controllers
- Added support for IPS export
- Added ability to customize the prefix prepended to resource names
- Added the IP address to the message displayed in the App Layering subtask
- Disabled network access to the OS disk
- 1.1.0.0 - Added support for Trusted Launch
- 1.0.0.0 - Initial version
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.2.0.0",
"parameters": {
"al": {
"type": "object"
}
},
"variables": {
"custom": "[parameters('al').context.config.custom]",
"location": "[if(contains(variables('custom'), 'location'), variables('custom').location, resourceGroup().location)]",
"prefix": "[if(contains(variables('custom'), 'prefix'), variables('custom').prefix, 'al-')]",
"name": "[concat(variables('prefix'), 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')]",
"trustedLaunch": "[if(contains(variables('custom'), 'trustedLaunch'), variables('custom').trustedLaunch, false())]",
"secureBoot": "[if(contains(variables('custom'), 'secureBoot'), variables('custom').secureBoot, variables('trustedLaunch'))]",
"vTpm": "[if(contains(variables('custom'), 'vTpm'), variables('custom').vTpm, variables('trustedLaunch'))]",
"acceleratedNetworking": "[if(contains(variables('custom'), 'acceleratedNetworking'), variables('custom').acceleratedNetworking, false())]",
"NVMe": "[if(contains(variables('custom'), 'NVMe'), variables('custom').NVMe, false())]",
"securityProfile": {
"securityType": "TrustedLaunch",
"uefiSettings": {
"secureBootEnabled": "[variables('secureBoot')]",
"vTpmEnabled": "[variables('vTpm')]"
}
},
"dataDiskTemplate": {
"createOption": "Attach",
"deleteOption": "Delete",
"managedDisk": {
"id": "ToBeReplaced"
}
},
"dataDiskName": "[concat(variables('name'), '-disk{0}')]",
"additionalDisks": "[if(contains(parameters('al').input, 'additionalDisks'), parameters('al').input.additionalDisks, createArray())]",
"additionalDiskIds": "[map(variables('additionalDisks'), lambda('x', lambdaVariables('x').diskId))]",
"dataDiskIds": "[map(variables('additionalDiskIds'), lambda('x', 'i', resourceId('Microsoft.Compute/disks',format(variables('dataDiskName'), lambdaVariables('i')))))]"
},
"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": "[variables('acceleratedNetworking')]",
"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",
"supportedCapabilities": {
"acceleratedNetwork": "[variables('acceleratedNetworking')]"
}
}
},
{
"copy": {
"name": "data-disk-loop",
"count": "[length(variables('additionalDiskIds'))]",
"mode": "Parallel"
},
"type": "Microsoft.Compute/disks",
"apiVersion": "2021-08-01",
"name": "[format(variables('dataDiskName'), copyIndex())]",
"location": "[variables('location')]",
"tags": "[variables('tags')]",
"sku": {
"name": "[variables('storageSku')]"
},
"properties": {
"creationData": {
"createOption": "Copy",
"sourceResourceId": "[variables('additionalDiskIds')[copyIndex()]]"
},
"networkAccessPolicy": "DenyAll",
"publicNetworkAccess": "Disabled"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2022-08-01",
"name": "[variables('vmName')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"[variables('diskId')]",
"data-disk-loop"
],
"tags": "[variables('tags')]",
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"securityProfile": "[if(variables('trustedLaunch'), variables('securityProfile'), null())]",
"storageProfile": {
"imageReference": "[if(variables('isFromImage'), createObject('id', variables('source').id), null())]",
"diskControllerType": "[if(variables('NVMe'), 'NVMe', 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": "[map(variables('dataDiskIds'), lambda('x', 'i', union(variables('dataDiskTemplate'), createObject('lun', lambdaVariables('i'), 'managedDisk', createObject('id', lambdaVariables('x'))))))]"
},
"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]. IP Address: {3}', environment().portal, tenant().tenantId, resourceId('Microsoft.Compute/virtualMachines', variables('vmName')), reference(variables('nicName')).ipConfigurations[0].properties.privateIPAddress)]"
}
}
}
<!--NeedCopy-->
Layered Image
The Layered Image deployment can create two types of resources, a gallery image version and/or a managed disk. Both resource types are named using the name of the App Layering image template being published and its constructed version number. The version number is constructed using major and minor numbers from App Layering image template disk name. If the disk name is not formatted as a numeric version (number.number), then 1.0 is applied by default. The patch number is the version number of the App Layering image template (the number of times that it’s been published). The gallery image is assigned the name and the gallery image version is assigned the version number. The managed disk is assigned the name appended with the version number or the current timestamp depending on diskNameFormat.
The gallery image and version are created in the gallery specified by the custom data. 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
R = Required, O = Optional, - = Not used
| Name | Type | Description | Default | Gallery Image | Managed Disk |
|---|---|---|---|---|---|
| publishAs | string or array | The type of resource(s) to create. Specified as an array or string consisting of ‘galleryImage’ and/or ‘managedDisk’ | [“galleryImage”] | O | R |
| location | string | The region where resources are created. | Same region as the target resource group | O | O |
| generation | string | The generation of the virtual machine that the image will support. | “V2” | O | O |
| NVMe | boolean |
true to enable NVMe disk controllers, false otherwise. This must be the same value for all deployment types. |
false |
O | O |
| acceleratedNetworking | boolean |
true to enable accelerated networking, false otherwise. This must be the same value for all deployment types. |
false |
O | O |
| trustedLaunch | boolean |
true to enable Trusted Launch, false otherwise. This must be the same value for all deployment types. |
false |
O | O |
| gallery | string | The name of the compute gallery to create the image in. The gallery must be in the target resource group. | - | R | - |
| replicaCount | number | The default number of replicas per region of the gallery image version | 1 | O | - |
| imageStorageAccountType | string | Specifies the storage account type to be used to store the image. | “Standard_LRS” | O | - |
| targetRegions | array | The target regions of the gallery image version. This is specified as an array of region name strings and/or TargetRegion objects. The array must contain the region of the source disk (as specified by the location custom data). |
The region specified by the location custom data |
O | - |
| storageSku | string | The name of the SKU to use. | “StandardSSD_LRS” | - | O |
| diskAccessId | string | 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 |
- | O |
| diskNameFormat | string | Controls the name of images published as managed disks. “version” to append the version to the image name, “timestamp” to append the time of publish. | “version” | - | O |
Layered Image template
- 1.2.0.0
- Added support for accelerated networking
- Added support for NVMe disk controllers
- Added ability to specify the storage account type of gallery image versions
- Added choice to name managed disks using the publish time rather than image version (similar to legacy naming)
- Fixed a bug that made
galleryNamerequired even when not publishing as a gallery image version
- 1.1.0.0
- Added support for Trusted Launch
- Added replica count and target region support for gallery image versions
- Added support for publishing as a managed disk
- 1.0.0.0 - Initial version
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.2.0.0",
"parameters": {
"al": {
"type": "object"
},
"timestamp": {
"type": "string",
"defaultValue": "[utcNow('yyyy-MM-dd_HH-mm-ss')]"
}
},
"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": "[if(contains(variables('custom'), 'gallery'), variables('custom').gallery, 'galleryName.required.in.custom.data')]",
"generation": "[if(contains(variables('custom'), 'generation'), variables('custom').generation, 'V2')]",
"trustedLaunch": "[if(contains(variables('custom'), 'trustedLaunch'), variables('custom').trustedLaunch, false())]",
"acceleratedNetworking": "[if(contains(variables('custom'), 'acceleratedNetworking'), variables('custom').acceleratedNetworking, false())]",
"NVMe": "[if(contains(variables('custom'), 'NVMe'), variables('custom').NVMe, false())]",
"replicaCount": "[if(contains(variables('custom'), 'replicaCount'), variables('custom').replicaCount, 1)]",
"targetRegions": "[if(contains(variables('custom'), 'targetRegions'), variables('custom').targetRegions, createArray(variables('location')))]",
"diskNames": {
"version": "[format('{0}_{1}-{2}-{3}', variables('name'), variables('major'), variables('minor'), parameters('al').context.item.version.number)]",
"timestamp": "[format('{0}_{1}', variables('name'), parameters('timestamp'))]"
},
"diskName": "[variables('diskNames')[coalesce(tryGet(variables('custom'), 'diskNameFormat'), 'version')]]",
"hasDiskAccess": "[contains(variables('custom'), 'diskAccessId')]",
"storageSku": "[if(contains(variables('custom'), 'storageSku'), variables('custom').storageSku, 'StandardSSD_LRS')]",
"imageStorageAccountType": "[coalesce(tryGet(variables('custom'), 'imageStorageAccountType'), 'Standard_LRS')]",
"publishAs": "[if(contains(variables('custom'), 'publishAs'), variables('custom').publishAs, createArray('galleryImage'))]",
"galleryLink": "[format('[link=\"{0}/#@{1}/resource/{2}\"]{2}[/link].', environment().portal, tenant().tenantId, resourceId('Microsoft.Compute/galleries/images/versions', variables('galleryName'), variables('name'), variables('version')))]",
"diskLink": "[format('[link=\"{0}/#@{1}/resource/{2}\"]{2}[/link].', environment().portal, tenant().tenantId, resourceId('Microsoft.Compute/disks', variables('diskName')))]",
"outputLinks": "[filter(createArray(if(contains(variables('publishAs'), 'galleryImage'), variables('galleryLink'), null()), if(contains(variables('publishAs'), 'managedDisk'), variables('diskLink'), null())), lambda('link', not(equals(lambdaVariables('link'), null()))))]",
"possibleFeatures": [
{
"include": "[variables('trustedLaunch')]",
"feature": {
"name": "SecurityType",
"value": "TrustedLaunch"
}
},
{
"include": "[variables('acceleratedNetworking')]",
"feature": {
"name": "IsAcceleratedNetworkSupported",
"value": "True"
}
},
{
"include": "[variables('NVMe')]",
"feature": {
"name": "DiskControllerTypes",
"value": "NVMe, SCSI"
}
}
]
},
"resources": [
{
"condition": "[contains(variables('publishAs'), 'galleryImage')]",
"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]",
"features": "[map(filter(variables('possibleFeatures'), lambda('x', lambdaVariables('x').include)), lambda('x', lambdaVariables('x').feature))]",
"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": [
{
"condition": "[contains(variables('publishAs'), 'galleryImage')]",
"type": "versions",
"apiVersion": "2022-03-03",
"name": "[variables('version')]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/galleries/images', variables('galleryName'), variables('name'))]"
],
"tags": "[variables('tags')]",
"properties": {
"publishingProfile": {
"replicaCount": "[variables('replicaCount')]",
"storageAccountType": "[variables('imageStorageAccountType')]",
"targetRegions": "[map(variables('targetRegions'), lambda('item', if(contains(lambdaVariables('item'), 'name'), lambdaVariables('item'), createObject('name', lambdaVariables('item')))))]"
},
"storageProfile": {
"osDiskImage": {
"source": {
"id": "[parameters('al').input.source.diskId]"
}
}
}
}
}
]
},
{
"condition": "[contains(variables('publishAs'), 'managedDisk')]",
"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": "[parameters('al').input.source.diskId]"
},
"diskAccessId": "[if(variables('hasDiskAccess'), variables('custom').diskAccessId, null())]",
"networkAccessPolicy": "[if(variables('hasDiskAccess'), 'AllowPrivate', 'AllowAll')]",
"publicNetworkAccess": "[if(variables('hasDiskAccess'), 'Disabled', 'Enabled')]"
}
}
],
"outputs": {
"message": {
"type": "string",
"value": "[if(empty(variables('outputLinks')), null(), format('See {0}.', join(variables('outputLinks'), ' and ')))]"
}
}
}
<!--NeedCopy-->