使用Azure ARM模板

时间:2016-08-05 17:46:52

标签: azure azure-web-sites azure-automation azure-resource-manager

EDIT 11/15/2016 :这是Azure中的一个错误,几天前修复了。

原帖:

我尝试创建几个依赖于服务器场的应用服务。我使用ARM模板进行部署。我在模板中的每个其他资源上使用相同的标记和标记格式,并且它们正在创建,但由于某种原因,服务器场上的标记不是。我可以通过Azure门户和资源浏览器在服务器场上创建标记,但不能通过ARM模板创建标记。

这是我资源部分的一部分:

{
    "comments": "",
    "type": "Microsoft.Web/serverfarms",
    "sku": {
        "name": "S3",
        "tier": "Standard",
        "size": "S3",
        "family": "S",
        "capacity": 1
    },
    "tags": {
        "tag1": "[parameters('tag1Value')]",
        "tag2": "[parameters('tag2Value')]",
        "tag3": "[parameters('tag3Value')]",
        "tag4": "[parameters('tag4Value')]",
        "tag5": "[parameters('tag4Value')]",
        "tag6": "[parameters('tag6Value')]",
        "tag7": "[parameters('tag7Value')]"
    },
    "name": "[variables('serverFarmName')]",
    "apiVersion": "2015-08-01",
    "location": "[parameters('location')]",
    "properties": {
        "name": "[variables('serverFarmName')]",
        "numberOfWorkers": 1
    },
    "dependsOn": []
},
[...]

这有任何已知问题吗?我的标签是否在错误的位置?

编辑2016年8月8日: 仅部署服务器场可以正常工作,但只要我将站点添加到该服务器场,标记就不能正确部署。这里发生了什么:部署开始,服务器场被创建。在创建站点之前,我可以急于进入Azure门户,并在服务器场上查看正确创建的标记。创建站点后,我刷新,返回服务器场,标记消失。

1 个答案:

答案 0 :(得分:0)

它可以正常使用,您可以尝试利用Visual Studio中的Azure资源组项目,如https://blogs.msdn.microsoft.com/kaevans/2015/11/22/creating-arm-templates-with-azure-resource-explorer/所述。

以下是我的简单测试模板,供您参考:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
  "parameters": {
    "tag1Value": { "type": "string" },
    "tag2Value": { "type": "string" },
    "tag3Value": { "type": "string" },
    "tag4Value": { "type": "string" },
    "tag5Value": { "type": "string" },
    "tag6Value": { "type": "string" },
    "tag7Value": { "type": "string" },
    "garysfName": {
      "type": "string",
      "minLength": 1
    },
    "garysfSKU": {
      "type": "string",
      "allowedValues": [
        "Free",
        "Shared",
        "Basic",
        "Standard"
      ],
      "defaultValue": "Free"
    },
    "garysfWorkerSize": {
      "type": "string",
      "allowedValues": [
        "0",
        "1",
        "2"
      ],
      "defaultValue": "0"
    }
  },
    "variables": {
    },
  "resources": [
      {
          "name": "[parameters('garysfName')]",
          "type": "Microsoft.Web/serverfarms",
          "location": "[resourceGroup().location]",
          "apiVersion": "2014-06-01",
          "dependsOn": [ ],
        "tags": {
          "displayName": "garysf",
          "tag1": "[parameters('tag1Value')]",
          "tag2": "[parameters('tag2Value')]",
          "tag3": "[parameters('tag3Value')]",
          "tag4": "[parameters('tag4Value')]",
          "tag5": "[parameters('tag4Value')]",
          "tag6": "[parameters('tag6Value')]",
          "tag7": "[parameters('tag7Value')]"
        },
          "properties": {
              "name": "[parameters('garysfName')]",
              "sku": "[parameters('garysfSKU')]",
              "workerSize": "[parameters('garysfWorkerSize')]",
              "numberOfWorkers": 1
          }
      },
  {
      "name": "[variables('garyarmwebappName')]",
      "type": "Microsoft.Web/sites",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-08-01",
      "dependsOn": [
          "[concat('Microsoft.Web/serverfarms/', parameters('garysfName'))]"
      ],
      "tags": {
          "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('garysfName'))]": "Resource",
          "displayName": "garyarmwebapp"
      },
      "properties": {
          "name": "[variables('garyarmwebappName')]",
          "serverFarmId": "[resourceId('Microsoft.Web/serverfarms/', parameters('garysfName'))]"
      }
  }

  ],
    "outputs": {
    }
}

参数JSON文件:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
  "parameters": {
    "tag1Value": { "value": "tag11" },
    "tag2Value": { "value": "tag22" },
    "tag3Value": { "value": "tag33" },
    "tag4Value": { "value": "tag44" },
    "tag5Value": { "value": "tag55" },
    "tag6Value": { "value": "tag66" },
    "tag7Value": { "value": "tag77" },
      "garysfName": {
          "value": "garyserverfarms"
      }
  }
}

您可以参考https://ms.portal.azure.com/?flight=1&flight.browsegrid2=true&flight.pov2=true&flight.resourcemenuperf=true#blade/HubsExtension/SubscriptionTagsListBlade检查Azure门户网站上的标记列表。