【问题标题】:ARM Template: How can i ensure Web App slots do not get the Web App Settings deployed over?ARM 模板:如何确保 Web 应用程序插槽不会部署 Web 应用程序设置?
【发布时间】:2023-04-10 06:54:02
【问题描述】:

我在 Azure 上为我们的暂存和生产环境提供了完整的 ARM 模板。它通过 Azure DevOps 发布。

但是,我注意到我在我的 ARM 中为 Web 应用应用的 Web 应用设置,它也会复制到 Web 应用插槽。我知道这可以在 Azure 上手动勾选,但是有没有办法在 ARM 模板上做到这一点?我查看了 Microsoft 网站,但没有看到任何帮助,并且想知道这是否是手动任务?

{
        "type": "Microsoft.Web/sites/config",
        "apiVersion": "2019-08-01",
        "location": "[resourceGroup().location]",
        "name": "[concat(parameters('webAppName'), '/appsettings')]",
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ],
        "properties": {
            "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsights')), '2014-04-01').InstrumentationKey]",
            "ApplicationInsightsAgent_EXTENSION_VERSION": "~2",
            "DiagnosticServices_EXTENSION_VERSION": "~3",
}

这就是我的应用程序设置代码的样子(还有更多应用程序设置,我不必全部复制)

下面是我的 Web App Slots ARM 代码

{
        "apiVersion": "2019-08-01",
        "type": "Microsoft.Web/sites/slots",
        "name": "[concat(parameters('webAppName'), '/', parameters('slots')[copyIndex()])]",
        "kind": "app",
        "location": "[resourceGroup().location]",
        "copy": {
            "name": "WebAppSlots",
            "count": "[length(parameters('slots'))]"
        },
        "properties": {
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
        },
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ]
    },

我非常感谢您对此事的任何见解。

谢谢你:)

【问题讨论】:

    标签: json azure web-applications azure-devops azure-resource-manager


    【解决方案1】:

    使用 ARM 模板的插槽设置非常痛苦。在 ARM 模板中无法复制设置而不实际复制插槽定义中的属性部分。

    由于您使用 Azure DevOps 进行部署,因此您可以使用更多选项。在我的脑海中,这些包括:

    • 使用 Azure App Service Settings Task 将您的 Web 应用程序和插槽设置设置为管道的一部分。
    • 使用Azure App Configuration Service 我很幸运。这将需要您编写一些代码,但我喜欢配置历史记录跟踪、比较以及无需回收您的 Web 应用即可热插拔设置的能力。
    • 我还刚刚执行了 Powershell 脚本作为我的部署管道的一部分来设置 Azure Web 应用程序和插槽设置。有了上述方法的可用性,我想说这是一个遥远的三分之一。但为了完整起见,我想包含它。

    【讨论】:

    • 感谢 Rob 的回复。所以要确认一下,我没有通过 ARM 的选项来确保 Wep App 设置不会转移到 Web App Slots?干杯
    • 正确。 Azure 开发团队的迭代速度非常快,因此这并不意味着它永远是答案。但现在是。
    • 谢谢 Rob - 我非常感谢您的帮助。我快疯了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 1970-01-01
    相关资源
    最近更新 更多