使用ARM模板禁用ARR亲和力

时间:2017-02-03 10:49:50

标签: azure arm-template azure-resource-manager

我希望在通过ARM模板配置新的应用服务时,将应用设置“ARR Affinity”配置为关闭。我该怎么做?

我找不到任何关于此的信息,这表明目前还没有支持它。

2 个答案:

答案 0 :(得分:7)

您正在寻找clientAffinityEnabled

下的properties

答案 1 :(得分:5)

以下是经过全面测试的工作ARM模板,该模板在部署成功后部署 ARR Affinity 设置为 OFF 的Azure Web App。

有用的参考:Disable Session affinity cookie (ARR cookie) for Azure web apps

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "hostingplan.name": {
      "type": "string",
      "defaultValue": "[concat(resourceGroup().name, '-hp')]"
    },
    "webapp.name": {
      "type": "string",
      "defaultValue": "[resourceGroup().name]"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Web/serverfarms",
      "name": "[parameters('hostingplan.name')]",
      "apiVersion": "2016-09-01",
      "sku": {
        "name": "S1",
        "capacity": 1
      },
      "properties": {
        "name": "[parameters('hostingplan.name')]"
      },
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.Web/sites",
      "name": "[parameters('webapp.name')]",
      "apiVersion": "2016-08-01",
      "properties": {
        "clientAffinityEnabled": false,
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingplan.name'))]"
      },
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', parameters('hostingplan.name'))]"
      ]
    }
  ]
}