【问题标题】:Azure function staging slot swap bug when deployed via ARM template通过 ARM 模板部署时的 Azure 函数暂存槽交换错误
【发布时间】:2018-08-22 04:38:15
【问题描述】:

我使用 ARM 模板创建了一个 Azure 函数应用(消费计划)。 在我部署代码并执行交换操作(VSTS 任务)后,生产槽和暂存槽都有新代码。但是我希望在交换操作之后暂存槽有旧代码,这是 Azure 函数中的一个已知错误吗?还是我需要做任何额外的事情

"resources": [
    {
      "name": "CampaignSyncJob",
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2016-09-01",
      "dependsOn": [],
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[concat(parameters('artifactsLocation'), '/', variables('linkedTemplateFolderName'), '/', variables('webAppTemplateFileName'), parameters('artifactsLocationSasToken'))]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "appServicePlanName": {
            "value": "[reference('ReleaseParams').outputs.webApp.value.appServicePlanName]"
          },
          "appServiceName": {
            "value": "[reference('ReleaseParams').outputs.webApp.value.appServiceName]"
          },
          "artifactsLocation": {
            "value": "[parameters('artifactsLocation')]"
          },
          "artifactsLocationSasToken": {
            "value": "[parameters('artifactsLocationSasToken')]"
          },
          "packageFolder": {
            "value": "CampaignSyncJob"
          },
          "packageFileName": {
            "value": "package.zip"
          },
          "appSettings": {
            "value": {
              "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]",
              "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]",
              "WEBSITE_CONTENTSHARE": "[toLower(variables('appServiceName'))]",
              "FUNCTIONS_EXTENSION_VERSION": "~2",
              "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
              "MSDEPLOY_RENAME_LOCKED_FILES": "1",
              "AppInsights_InstrumentationKey": "[variables('appInsightsInstrumentationKey')]",
              "StickySetting": "StuckToProduction1"
            }
          },
          "slotAppSettings": {
            "value": {
              "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]",
              "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]",
              "WEBSITE_CONTENTSHARE": "[toLower(variables('appServiceName'))]",
              "FUNCTIONS_EXTENSION_VERSION": "~2",
              "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
              "MSDEPLOY_RENAME_LOCKED_FILES": "1",
              "AppInsights_InstrumentationKey": "[variables('appInsightsInstrumentationKey')]",
              "StickySetting": "StuckToStaging1"
            }
          },
          "slotName": {
            "value": "[reference('ReleaseParams').outputs.webApp.value.appServiceSlotName]"
          },
          "appServiceLocation": {
            "value": "[reference('ReleaseParams').outputs.common.value.location]"
          },
          "slotSpecificAppSettingKeys": {
            "value": [
              "StickySetting"
            ]
          }
        }
      }
    },

部署函数应用的链接模板

{
      "condition": "[parameters('deployOnStagingSlot')]",
      "apiVersion": "2015-08-01",
      "name": "[concat(parameters('appServiceName'), '/', parameters('slotName'))]",
      "type": "Microsoft.Web/sites/slots",
      "location": "[parameters('appServiceLocation')]",
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
      },
      "dependsOn": [
      ],
      "resources": [
        {
          "condition": "[parameters('deployOnStagingSlot')]",
          "name": "appsettings",
          "type": "config",
          "apiVersion": "2015-08-01",
          "dependsOn": [
            "[concat('Microsoft.Web/sites/', parameters('appServiceName'), '/slots/', parameters('slotName'))]",
            "[concat('Microsoft.Web/sites/', parameters('appServiceName'), '/slots/', parameters('slotName'), '/Extensions/MSdeploy')]"
          ],
          "properties": "[parameters('slotAppSettings')]"
        },
        {
          "condition": "[parameters('deployOnStagingSlot')]",
          "name": "MSDeploy",
          "type": "extensions",
          "location": "[parameters('appServiceLocation')]",
          "apiVersion": "2015-08-01",
          "dependsOn": [
            "[concat('Microsoft.Web/sites/', parameters('appServiceName'), '/slots/', parameters('slotName'))]"
          ],
          "properties": {
            "packageUri": "[concat(parameters('artifactsLocation'), '/', parameters('packageFolder'), '/', parameters('packageFileName'), parameters('artifactsLocationSasToken'))]",
            "setParameters": {
              "IIS Web Application Name": "[parameters('slotName')]"
            }
          }
        }
      ]
    }

【问题讨论】:

    标签: azure azure-devops azure-functions azure-resource-manager azure-pipelines-release-pipeline


    【解决方案1】:

    嗯,我知道要在功能应用程序中交换插槽,需要将应用程序设置 WEBSITE_CONTENTSHARE 更改为插槽特定设置。

    有关此解决方案和其他有关多插槽的 ARM 问题,请查看 Gary Lumsden 的博客

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-28
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      • 1970-01-01
      • 2019-02-11
      相关资源
      最近更新 更多