ARM 模板 Web 应用程序身份验证设置不起作用

Ita*_*nex 6 azure-active-directory azure-resource-manager azure-web-app-service

我正在设置我的站点身份验证设置以使用 AAD 提供程序。大多数模板都受到尊重。但是,unauthenticatedClientActionallowedAudiences没有被正确分配。我观察到“允许匿名”并且没有分配“允许的观众”。

请注意,我正在使用 ARM Template API 2018-02-01。由于文档原因,此问题可能仍然存在,如果您提供答案,请注意其解决的 ARM 模板版本。

此外,为 ARM 文档团队创建一个问题以更正任何问题。

这是我的这些设置的模板段。它嵌套在我的网站模板中的资源下。

根 > Microsoft.Web/站点 > 资源

{
    "type": "config",
    "name": "web",
    "apiVersion": "2016-08-01",
    "location": "[parameters('app-location')]",
    "dependsOn": [
        "[resourceId('Microsoft.Web/sites', variables('web-site-name'))]"
    ],
    "properties": {
        "siteAuthEnabled": true,
        "siteAuthSettings": {
            "enabled": true,
            "unauthenticatedClientAction": "RedirectToLoginPage",
            "tokenStoreEnabled": true,
            "defaultProvider": "AzureActiveDirectory",
            "clientId": "[parameters('web-aad-client-id')]",
            "issuer": "[concat('https://sts.windows.net/', parameters('web-aad-tenant'))]",
            "allowedAudiences": [
                "[concat('https://', variables('web-site-name'), '.azurewebsites.net')]"
            ]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 模板验证
  • 部署不输出任何错误

问题:

  1. unauthenticatedClientAction 被分配允许匿名而不是 RedirectToLoginPage
  2. allowedAudiences 未分配任何站点

什么可能导致这些问题?我可能错过了什么?

Ita*_*nex 7

在与 Azure 支持的优秀人员合作后,我得到了答案。

请注意,此解决方案针对 API 2018-02-01,这是本文发布时的当前版本。

此子资源不再是有效的解决方案,而端点可能仍会识别其某些字段,但已弃用。

新的解决方案是将siteAuthSettings对象添加到主要的“Microsoft.Web/site”属性中,并且siteAuthEnabled不再需要它,因为它siteAuthSettings.enable重复了此功能。

更新的 ARM 模板(为简洁起见删除了其他设置)

{
    "name": "[variables('app-service-name')]",
    "type": "Microsoft.Web/sites",
    "location": "[parameters('app-location')]",
    "apiVersion": "2016-08-01",
    "dependsOn": [
        "[variables('app-plan-name')]"
    ],
    "properties": {
        //... other app service settings
        "siteAuthSettings": {
            "enabled": true,
            "unauthenticatedClientAction": "RedirectToLoginPage",
            "tokenStoreEnabled": true,
            "defaultProvider": "AzureActiveDirectory",
            "clientId": "[parameters('web-aad-client-id')]",
            "issuer": "[concat('https://sts.windows.net/', parameters('web-aad-tenant'))]",
            "allowedAudiences": [
                "[concat('https://', variables('web-site-name'), '.azurewebsites.net')]"
            ]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 我遇到了同样的问题,当前的文档对此仍不清楚。我的部分设置未应用其他设置。将其直接放入 wep 应用程序属性对我有用,但不要忘记将其放入“siteConfig”条目中。 (2认同)