gpt4 book ai didi

azure - 从基础打包程序镜像部署超过 1 个 azure 虚拟机

转载 作者:行者123 更新时间:2023-12-03 04:25:29 25 4
gpt4 key购买 nike

我在从使用打包程序构建的自定义镜像(又名 ami)部署多个 Azure 虚拟机时遇到问题。

这是我用于创建基本镜像的打包脚本:

{
"builders": [
{
"type": "azure-arm",
"client_id": "CHANGE_ME",
"client_secret": "CHANGE_ME",
"object_id": "CHANGE_ME",
"subscription_id": "CHANGE_ME",
"tenant_id": "CHANGE_ME",
"resource_group_name": "packerrgvm",
"storage_account": "packerrgvm",
"capture_container_name": "images",
"capture_name_prefix": "packer",
"os_type": "Linux",
"image_publisher": "Canonical",
"image_offer": "UbuntuServer",
"image_sku": "16.04.0-LTS",
"azure_tags": {
"dept": "engineering"
},
"location": "westeurope",
"vm_size": "Standard_A2"
}
],
"provisioners": [
{
"type": "shell",
"inline": ["do sth interesting here"]
},
{
"type": "shell",
"inline": [
"sudo /usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
]
}
]
}

现在,我正在尝试使用 ARM 模板部署新的虚拟机。我的模板包含成功构建后由打包程序提供的 imageName、imageUri 和 vhdUri。省略 Vnet、网络接口(interface)等:

{
"apiVersion": "2016-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('workerVM').machine.name]",
"location": "[resourceGroup().location]",
"properties": {
"hardwareProfile": {
"vmSize": "[variables('workerVM').machine.size]"
},
"storageProfile": {
"osDisk": {
"osType": "Linux",
"name": "[variables('workerVM').machine.imageName]",
"createOption": "FromImage",
"image": {
"uri": "[variables('workerVM').machine.imageUri]"
},
"vhd": {
"uri": "[variables('workerVM').machine.vhdUri]"
},
"caching": "ReadWrite"
}
},
"osProfile": {
"computerName": "[variables('workerVM').machine.name]",
"adminUsername": "[variables('workerVM').machine.adminUsername]",
"adminPassword": "[variables('workerVM').machine.adminPassword]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('workerVM').network.nicName)]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": false
}
},
"provisioningState": 0
}
}

当我第一次部署它时,它可以工作。然而,即使我完全删除资源组并尝试再次部署虚拟机,我也会收到以下错误:

error:   The resource operation completed with terminal provisioning state 'Failed'.
error: Blob https://packerrgvm.blob.core.windows.net/vmcontainera1ba96d3-a593-44b9-8c71-1d345ef67a2d/osDisk.a1ba96d3-a593-44b9-8c71-1d345ef67a2d.vhd already exists. Please provide a different blob URI as target for disk 'packer-osDisk.49359f62-5c49-44c1-aed8-4ea1613ab2e9.vhd'.

是否可以通过这种方式使用打包程序构建的自定义 ami?

最佳答案

how do i create more than 1 vm from single base image built with backer

您可以在重新部署 ARM 模板之前更改 vhdUri 变量的值。

"vhd": {
"uri": "[variables('workerVM').machine.vhdUri]"
}

ARM 模板中的 vhdUri 变量可能如下所示,

"variables": {
"workerVM": {
"machine": {
"vhdUri": "reset this uri"
}
}

关于azure - 从基础打包程序镜像部署超过 1 个 azure 虚拟机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43963022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com