Azure VM 自定义 OS 映像 ARM 模板部署

Azure VM custom OS image ARM template deployment

到目前为止,我一直在使用市场上的 Suse SLES for SAP 映像来创建我的 VM。但是现在我打算使用包含其他软件和配置的金色 OS 映像。为此,我创建了一个带有市场图像的 VM 并对其进行了配置。然后我创建了一个只有 OS 磁盘 Linux image creation 的映像。似乎 MS 正在转向 VM 映像而不是早期的磁盘映像。但是我找不到任何方法将此 VM 映像用作 ARM 模板部署的一部分。以前我使用的标准模板如下:

 "osProfile": {
                "computerName": "[parameters('vmName')]",
                "adminUsername": "[parameters('vmUserName')]",
                "adminPassword": "[parameters('vmPassword')]"
            },
            "storageProfile": {
                "imageReference": {
                    "publisher": "[variables('OperatingSystemSpec').imagePublisher]",
                    "offer": "[variables('OperatingSystemSpec').imageOffer]",
                    "sku": "[variables('OperatingSystemSpec').sku]",
                    "version": "latest"
                },
                "osDisk": {
                    "name": "[concat(parameters('vmName'),'-OS')]",
                    "createOption": "FromImage",
                    "caching": "ReadWrite",
                    "managedDisk": {
                        "storageAccountType": "Premium_LRS"
                    } 
                }

如何使用模板中的通用黄金图像?

objective 是我的黄金镜像应该像我使用市场镜像一样可用,否则所有 ARM 模板都会有很大的变化。我能否以某种方式发布我的图像,就像市场图像一样(但作为私有 collection),以便它像其中之一一样可用?

我需要为这种用途创建 VHD 映像吗?我看到有 ARM 模板示例可以引用存储在 azure 存储中的 VHD。如何为我的 Azure VM OS 磁盘创建 VHD?我看到了展示如何创建和上传 VHD 的示例,但这些示例适用于 on-prem VM。另请注意,我正在为我的 Azure VM 使用托管磁盘。

非常感谢任何帮助..

How do I use the generalized golden image from my template?

您可以使用

"imageReference": {
                    "id":{the image resource id}
                }

在模板中。此 ID 必须采用以下形式: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}

Do I need to create a VHD image for this kind of usage? How do I create a VHD for my Azure VM OS disk?

这取决于你。如果要使用 VHD 作为映像以使用新磁盘创建其他 VM,可以使用 Sysprep 概括文件中包含的操作系统,然后停止 VM。您将获得 VHD uri。请参阅此 document 了解更多详情。