Проблемы развертывания приложений и слотов с помощью шаблона ARM - PullRequest
0 голосов
/ 21 февраля 2020

У меня есть код шаблона ARM для развертывания веб-приложения и создания слота вместе с приложением с соответствующей средой в зависимости от условий. Когда я пытаюсь развернуть ресурс с помощью шаблона, он развертывает только веб-приложение, а слот не создается с использованием параметров приложения. Я новичок в ARM, может кто-нибудь, пожалуйста, помогите мне с тем, что я сделал неправильно с моим шаблоном.

       {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
        "resourceGroup": {
        "type": "string"
        },
"displayNameTag": {
  "type": "string"
},
"appInsightName": {
  "type": "string"
},
  "environment": {
    "type": "string"
  },
  "appType": {
    "type": "string"
  },
  "appServicePlanName": {
    "type": "string"
  },
  "alwaysOn": {
    "type": "bool"
  },
  "currentStack": {
    "type": "string"
  },
  "netFrameworkVersion": {
    "type": "string",
    "defaultValue": "v4.0"

  },
  "secondaryApp":{
    "type":"string"
  }
},
    "variables": {

"AustraliaEast": {
  "countryCode": "au",
  "regionShortCode": "aue",
  "regionShortCodePair": "aue",
  "omsLocation": "AustraliaEast",
  "omsLocationShortCode": "aue",
  "PrimaryRegion": true,
  "SecondaryRegion": "AustraliaSoutheast",
  "regionLocation":"AustraliaEast"
},
"AustraliaSoutheast": {
  "countryCode": "au",
  "regionShortCode": "aus",
  "regionShortCodePair": "aue",
  "PrimaryRegion": false,
  "regionLocation":"AustraliaSoutheast"
},

"regionSpec": "[variables(resourceGroup().location)]",
"applicationRegion" : "[if(equals(parameters('secondaryApp'),'Yes'),variables('AustraliaSoutheast'),variables('regionspec'))]",
"appName": "[concat('myapp-',parameters('environment'),'-',parameters('appType'),'-',variables('applicationRegion').regionShortcode,'-',parameters('displayNameTag'))]"
  },
   "resources": [
{
  "apiVersion": "2018-11-01",
  "name": "[variables('appName')]",
  "type": "Microsoft.Web/sites",
  "location": "[variables('applicationRegion').regionLocation]",
  "tags": {
    "displayName": "[parameters('displayNameTag')]",
    "environment": "[parameters('environment')]"
  },
  "dependsOn": [],
  "properties": {
    "name": "[variables('appName')]",
    "mode": "incremental",
    "siteConfig": {
      "appSettings": [
        {
          "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
          "value": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightName')), '2015-05-01').InstrumentationKey]"
        },
        {
          "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
          "value": "[concat('InstrumentationKey=',reference(resourceId('Microsoft.Insights/components', parameters('appInsightName')), '2015-05-01').InstrumentationKey)]"
        }
      ],
      "metadata": [
        {

          "name": "CURRENT_STACK",
          "value": "[parameters('currentStack')]"
        }
      ],
      "netFrameworkVersion": "[parameters('netFrameworkVersion')]",
      "alwaysOn": "[parameters('alwaysOn')]"
    },
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
    "clientAffinityEnabled": true
  }
},
{

  "condition":"[equals(parameters('secondaryApp'),'Yes')]",
  "apiVersion": "2018-11-01",
  "type": "Microsoft.Web/sites/slots",
  "name": "[concat(variables('appName'), '/', 'Slot-Staging')]",
  "location": "[variables('applicationRegion').regionLocation]",
  "comments": "This specifies the web app slots.",
  "tags": {
    "displayName": "WebAppSlots"
  },
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
  },
  "dependsOn": [
    "[resourceId('Microsoft.Web/sites', variables('appName'))]"
  ]
}
 ],
 "outputs": {
"webAppName": {
  "type": "string",
  "value": "[variables('appName')]"
  }
  }
 }'

1 Ответ

0 голосов
/ 21 февраля 2020

Пожалуйста, попробуйте добавить код json, указанный в шаблоне ARM.

"resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "appsettings",
      "type": "config",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'), 'Staging')]"
      ],
      "properties": {
        "AppSettingKey1": "Some staging value",
        "AppSettingKey2": "My second staging setting",
        "AppSettingKey3": "My third staging setting"
      }
    }
  ]

Следуйте этому SO для полной справки.

...