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

时间:2016-11-18 16:46:21

标签: azure ubuntu docker autoscaling azure-resource-manager

我尝试部署https://github.com/Azure/azure-quickstart-templates/blob/master/201-vmss-ubuntu-autoscale/azuredeploy.json的修改版本以添加Docker扩展,但在尝试部署时遇到错误。你可以在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]",

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

对于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等的同伴