修改 201-vmss-ubuntu-autoscale Azure 快速入门模板以包含 Docker 扩展

Modifying 201-vmss-ubuntu-autoscale Azure quickstart template to include Docker extension

我正在尝试部署 https://github.com/Azure/azure-quickstart-templates/blob/master/201-vmss-ubuntu-autoscale/azuredeploy.json to add in the Docker extension but am getting an error when trying to deploy. You can see how I've tried to do this at https://gist.github.com/jinky32/d80e0ab2137236ff262484193f93c946 行 329++

的修改版本
{
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(variables('vmName'),'/', variables('extensionName'))]",
  "apiVersion": "2015-05-01-preview",
  "location": "[variables('location')]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
  ],
  "properties": {
    "publisher": "Microsoft.Azure.Extensions",
    "type": "DockerExtension",
    "typeHandlerVersion": "1.0",
    "autoUpgradeMinorVersion": true
        }
      }

当我运行azure group create --name autoscalegroup2 --location "West Europe" \ --template-uri http://path/to.json

输入一些详细信息后,我得到了提示 error: InvalidTemplate : Deployment template validation failed: 'The resource 'Microsoft.Compute/virtualMachines/autoscalegroup2' is not defined in the template. Please see https://aka.ms/arm-template for usage details.'.

但是我认为这应该基于第 334-336 行

"dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
  ],

和 vmName 在上面的变量中定义(第 68 行)

"vmName": "[resourceGroup().name]",

非常感谢任何帮助!

VMSS 的扩展编写方式不同 - 我没有找到确切的示例(您可能没有找到),但可以看一下这个示例:

https://github.com/Azure/azure-quickstart-templates/blob/master/201-vmss-ubuntu-web-ssl/azuredeploy.json#L382-L398

VMSS 的扩展属性主体仍然相同,但它不是子资源。所以你最终会在 VMSS 资源属性对象中得到类似这样的东西:

      "extensionProfile": {
        "extensions": [
          {
            "name": "docker",
            "properties": {
              "publisher": "Microsoft.Azure.Extensions",
              "type": "DockerExtension",
              "typeHandlerVersion": "1.0",
              "autoUpgradeMinorVersion": true,
              "settings": {}
            }
          }
        ]
      },

扩展配置文件是 osProfile、networkProfile 等的对等