入门模板

本节包含一套完整的 ARM 模板,可与 Azure 部署连接器配合使用。这些模板可以按原样使用,也可以根据特定需求进行修改。

这些模板创建的每个资源都标有相同的标签集。这些标签包含有关部署上下文的有用信息,例如启动任务的用户名称及其输入的注释。

这些模板广泛使用了连接器配置中的自定义数据。自定义数据允许用户定义 locationvmSizegeneration 等常见参数,而无需修改模板。

下表列出了这些模板使用的所有自定义数据属性。它指定了哪些模板适用于每个属性以及该属性是否为必需。

R = 必需,O = 可选,- = 未使用

名称 类型 描述 默认值 缓存磁盘 启动映像 计算机 分层映像
location string 创建资源的区域。 与目标资源组相同的区域。 O O O O
gallery string 用于创建映像的计算库的名称。该库必须位于目标资源组中。 - - R - R
storageSku string 用于托管磁盘的 SKU 名称。 “StandardSSD_LRS” O - O -
NVMe boolean true 表示使用 NVMe 磁盘控制器,否则为 false。所有部署类型的值必须相同。 false O O O O
generation string 虚拟机的代系。 “V2” - O O O
trustedLaunch boolean true 表示启用受信任启动,否则为 false。所有部署类型的值必须相同。 false O O O O
diskAccessId string 上传磁盘内容时使用的磁盘访问资源 ID。如果指定此项,则创建的磁盘将禁用公共网络访问。有关详细信息,请参阅 Azure 文档 null O - - -
vmSize string 要创建的 VM 大小。 “Standard_D2s_v3” - - O -
prefix string 附加到计算机部署创建的资源名称的前缀。 “al-“ - - O -
licenseType string 应用于所创建虚拟机的本地许可证类型。 null - - O -
subnetId string 要将 VM 网卡附加到的子网的资源 ID。 - - - R -
acceleratedNetworking boolean true 表示启用加速网络,否则为 false。所有部署类型的值必须相同。 false O O O O
replicaCount number 每个区域的库映像版本的默认副本数。 1 - - - O
imageStorageAccountType string 指定用于存储映像的存储帐户类型。 “Standard_LRS” - - - O
targetRegions array 库映像版本的目标区域。这指定为区域名称字符串数组和/或 TargetRegion 对象。该数组必须包含源磁盘的区域(由 location 自定义数据指定)。 location 自定义数据指定的区域 - - - O
publishAs string or array 发布映像的资源类型。指定为包含“galleryImage”和/或“managedDisk”的数组或字符串。 [“galleryImage”] - - - O
diskNameFormat string 控制发布为托管磁盘的映像的名称。“version”表示将版本附加到映像名称,“timestamp”表示附加发布时间。 “version” - - - O

示例自定义数据:

{
    "gallery": "MyGallery",
    "subnetId": "/subscriptions/ab3d1259-f5a9-407f-bbdd-bfd5701e2e94/resourceGroups/PDGTPB/providers/Microsoft.Network/virtualNetworks/MyVnet/subnets/mysubnet"
}
<!--NeedCopy-->

自定义数据的另一个示例:

{
    "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-->

缓存磁盘

  • 创建托管磁盘。

  • 缓存磁盘自定义数据

名称 类型 描述 默认值 必需
location string 创建资源的区域。 与目标资源组相同的区域
storageSku string 要使用的 SKU 名称。 “StandardSSD_LRS”
NVMe boolean true 表示启用 NVMe 磁盘控制器,否则为 false。所有部署类型的值必须相同。 false
acceleratedNetworking boolean true 表示启用加速网络,否则为 false。所有部署类型的值必须相同。 false
trustedLaunch boolean true 表示启用受信任启动,否则为 false。所有部署类型的值必须相同。 false
diskAccessId string 上传磁盘内容时要使用的磁盘访问资源 ID。如果指定,则创建的磁盘将禁用公共网络访问。 null

缓存磁盘模板

  • 1.2.1.0 - 修复了在启用 NVMe 时阻止发布映像的第二个版本的错误
  • 1.2.0.0 - 添加了对加速网络和 NVMe 磁盘控制器的支持
  • 1.1.0.0 - 添加了对受信任启动的支持
  • 1.0.0.0 - 初始版本
{
    "$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'), 'SCSI, NVMe', 'SCSI')]",
                    "acceleratedNetwork": "[variables('acceleratedNetworking')]"
                }
-  }
-  }
-  ]
    -  }
<!--NeedCopy-->

启动映像

启动映像部署在自定义数据指定的库中创建库映像和映像版本。它输出所创建的计算库映像版本的 ID,供 Machine 模板使用。

启动映像自定义数据

名称 类型 描述 默认值 必需
location string 资源创建所在的区域。 与目标资源组相同的区域。
generation string 磁盘中使用的虚拟机的代系。 “V2”
NVMe boolean true 表示启用 NVMe 磁盘控制器,否则为 false。所有部署类型都必须使用相同的值。 false
acceleratedNetworking boolean true 表示启用加速网络,否则为 false。所有部署类型都必须使用相同的值。 false
trustedLaunch boolean true 表示启用受信任启动,否则为 false。所有部署类型都必须使用相同的值。 false
gallery string 用于创建映像的计算库的名称。该库必须位于目标资源组中。 -

启动映像模板

-  1.2.1.0 - 修复了在启用 NVMe 时阻止发布映像的第二个版本的问题
-  1.2.0.0 - 添加了对加速网络和 NVMe 磁盘控制器的支持
-  1.1.0.0 - 添加了对受信任启动的支持
-  1.0.0.0 - 初始版本
{
    "$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": "SCSI, NVMe"
                }
            }
        ]
    },
    "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-->
-  ## 计算机

计算机部署会创建虚拟机、NIC 和托管磁盘。此模板在指定或未指定 启动映像 部署的情况下均可运行。

计算机自定义数据

名称 类型 描述 默认值 必需
location string 资源创建所在的区域。 与目标资源组相同的区域。
storageSku string 所创建磁盘的 SKU 名称。 “StandardSSD_LRS”
generation string 虚拟机的代系。 “V2”
NVMe boolean true 表示使用 NVMe 磁盘控制器,否则为 false。所有部署类型都必须使用相同的值。 false
acceleratedNetworking boolean true 表示启用加速网络,否则为 false。所有部署类型都必须使用相同的值。 false
trustedLaunch boolean true 表示启用受信任启动,否则为 false。所有部署类型都必须使用相同的值。 false
secureBoot boolean true 表示启用安全启动,否则为 false。仅当 trustedLaunch 设置为 true 时才应用此设置。 true
vTpm boolean true 表示启用 vTPM,否则为 false。仅当 trustedLaunch 设置为 true 时才应用此设置。 true
vmSize string 要创建的 VM 大小。 “Standard_D2s_v3”
licenseType string 要应用于虚拟机的本地许可证类型。 null
subnetId string 要将 NIC 附加到的子网的资源 ID。 -
prefix string 要添加到所创建资源名称前的名称前缀 “al-“

计算机模板

-  1.2.0.0
-  添加了对加速网络的支持
-  添加了对 NVMe 磁盘控制器的支持
-  添加了对 IPS 导出的支持
-  添加了自定义资源名称前缀的功能
-  将 IP 地址添加到 App Layering 子任务中显示的消息
-  禁用了对 OS 磁盘的网络访问
-  1.1.0.0 - 添加了对受信任启动的支持
  • 1.0.0.0 - 初始版本
{
    "$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-->

分层映像

分层映像部署可以创建两种类型的资源:库映像版本和/或托管磁盘。这两种资源类型都使用正在发布的 App Layering 映像模板的名称及其构建的版本号命名。版本号是使用 App Layering 映像模板磁盘名称中的主要版本号和次要版本号构建的。如果磁盘名称未格式化为数字版本(number.number),则默认应用 1.0。修补程序号是 App Layering 映像模板的版本号(即已发布的次数)。库映像被分配名称,库映像版本被分配版本号。托管磁盘被分配附加了版本号或当前时间戳的名称,具体取决于 diskNameFormat

库映像和版本是在自定义数据指定的库中创建的。当映像多次发布时,计算库映像会添加一个新版本,而旧版本会保留。

分层映像自定义数据

R = 必需,O = 可选,- = 未使用

名称 类型 描述 默认值 库映像 托管磁盘
publishAs string or array 要创建的资源类型。指定为包含“galleryImage”和/或“managedDisk”的数组或字符串 [“galleryImage”] O R
location string 资源创建所在的区域。 与目标资源组相同的区域 O O
generation string 映像将支持的虚拟机的代系。 “V2” O O
NVMe boolean true 表示启用 NVMe 磁盘控制器,否则为 false。所有部署类型都必须使用相同的值。 false O O
acceleratedNetworking boolean true 表示启用加速网络,否则为 false。所有部署类型都必须使用相同的值。 false O O
trustedLaunch boolean true 表示启用受信任启动,否则为 false。所有部署类型都必须使用相同的值。 false O O
gallery string 用于创建映像的计算库的名称。该库必须位于目标资源组中。 - R -
replicaCount number 库映像版本每个区域的默认副本数 1 O -
imageStorageAccountType string 指定用于存储映像的存储帐户类型。 “Standard_LRS” O -
targetRegions array 库映像版本的目标区域。这指定为区域名称字符串和/或 TargetRegion 对象的数组。该数组必须包含源磁盘的区域(由 location 自定义数据指定)。 location 自定义数据指定的区域 O -
storageSku string 要使用的 SKU 名称。 “StandardSSD_LRS” - O
diskAccessId string 上传磁盘内容时要使用的磁盘访问的资源 ID。如果指定,则创建的磁盘将禁用公共网络访问。 null - O
diskNameFormat string 控制发布为托管磁盘的映像的名称。“version”表示将版本附加到映像名称,“timestamp”表示附加发布时间。 “version” - O

分层映像模板

  • 1.2.1.0 - 修复了在启用 NVMe 时阻止发布映像的第二个版本的问题
  • 1.2.0.0
    • 添加了对加速网络的支持
    • 添加了对 NVMe 磁盘控制器的支持
    • 添加了指定库映像版本存储帐户类型的能力
    • 添加了选择使用发布时间而不是映像版本命名托管磁盘的功能(类似于旧版命名)
    • 修复了即使未发布为库映像版本也要求 galleryName 的错误
  • 1.1.0.0
    • 添加了对受信任启动的支持
    • 添加了对库映像版本的副本计数和目标区域支持
    • 添加了对发布为托管磁盘的支持
  • 1.0.0.0 - 初始版本
{
    "$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": "SCSI, NVMe"
                }
            }
        ]
    },
    "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-->
入门模板