当前位置: 首页 > 知识库问答 >
问题:

使用ARM模板在Azure功能应用中轻松实现身份验证和授权

曾歌者
2023-03-14

Azure App服务的“轻松认证和授权”功能在我的Azure功能App中工作,如果我手动配置的话。当我使用ARM模板时,它不起作用。

我使用此网站计算了配置值:https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.websites.models.siteauthSettings?view=azuremgmtwebsites-1.6.0-preview

这就是它看起来的样子,想法?

编辑:在https://resources.azure.com上检查得到的配置后,我看到根本没有应用“SiteAuthEnabled”和“SiteAuthSettings”。是否应该在其他地方指定它们?

{
  "apiVersion": "2016-08-01",
  "type": "Microsoft.Web/sites",
  "name": "[parameters('webApiFunctionAppName')]",
  "location": "[resourceGroup().location]",
  "kind": "functionapp",
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('webApiFunctionAppHostingPlanName'))]",
    "[resourceId('Microsoft.Storage/storageAccounts', variables('azFunctionsAppStorageAccountName'))]"
  ],
  "resources": [{
    "apiVersion": "2016-08-01",
    "name": "[concat(parameters('webApiFunctionAppName'), '/authsettings')]",
    "type": "Microsoft.Web/sites/config",
    "dependsOn": [
      "[concat('Microsoft.Web/sites/', parameters('webApiFunctionAppName'))]"
    ],
    "properties": {
      "netFrameworkVersion": "v4.0",
      "managedPipelineMode": "Integrated",
      "siteAuthEnabled": true,
      "siteAuthSettings": {
        "enabled": true,
        "unauthenticatedClientAction": "RedirectToLoginPage",
        "tokenStoreEnabled": true,
        "allowedExternalRedirectUrls": null,
        "defaultProvider": "AzureActiveDirectory",
        "clientId": "[parameters('aadClientId')]",
        "clientSecret": null,
        "issuer": "[concat('https://sts.windows.net/', parameters('aadTenant'), '/')]",
        "allowedAudiences": null,
        "isAadAutoProvisioned": false
      }
    }
  }],
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('webApiFunctionAppHostingPlanName'))]",
    "hostNameSslStates": [{
        "name": "[concat(parameters('webApiFunctionAppName'),'.azurewebsites.net')]",
        "sslState": "Disabled",
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "hostType": "Standard"
      },
      {
        "name": "[concat(parameters('webApiFunctionAppName'),'.scm.azurewebsites.net')]",
        "sslState": "Disabled",
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "hostType": "Repository"
      }
    ],
    "siteConfig": {
      "appSettings": [{
          "name": "AzureWebJobsDashboard",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "AzureWebJobsStorage",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "FUNCTIONS_EXTENSION_VERSION",
          "value": "~1"
        },
        {
          "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "WEBSITE_CONTENTSHARE",
          "value": "[toLower(parameters('webApiFunctionAppName'))]"
        }
      ]
    }
  }
}

共有1个答案

赵昊阳
2023-03-14

好的,明白了。此模板有效。

 {
  "apiVersion": "2016-08-01",
  "type": "Microsoft.Web/sites",
  "name": "[parameters('webApiFunctionAppName')]",
  "location": "[resourceGroup().location]",
  "kind": "functionapp",
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('webApiFunctionAppHostingPlanName'))]",
    "[resourceId('Microsoft.Storage/storageAccounts', variables('azFunctionsAppStorageAccountName'))]"
  ],
  "resources": [{
    "name": "[concat(parameters('webApiFunctionAppName'), '/authsettings')]",
    "apiVersion": "2016-08-01",
    "type": "Microsoft.Web/sites/config",
    "location": "[resourceGroup().location]",
    "dependsOn": [
      "[resourceId('Microsoft.Web/sites', parameters('webApiFunctionAppName'))]"
    ],
    "properties": {
      "enabled": true,
      "unauthenticatedClientAction": "RedirectToLoginPage",
      "tokenStoreEnabled": true,
      "defaultProvider": "AzureActiveDirectory",
      "clientId": "[parameters('aadClientId')]",
      "issuer": "[concat('https://sts.windows.net/', parameters('aadTenant'), '/')]"
    }
  }],
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('webApiFunctionAppHostingPlanName'))]",
    "hostNameSslStates": [{
        "name": "[concat(parameters('webApiFunctionAppName'),'.azurewebsites.net')]",
        "sslState": "Disabled",
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "hostType": "Standard"
      },
      {
        "name": "[concat(parameters('webApiFunctionAppName'),'.scm.azurewebsites.net')]",
        "sslState": "Disabled",
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "hostType": "Repository"
      }
    ],
    "siteConfig": {
      "appSettings": [{
          "name": "AzureWebJobsDashboard",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "AzureWebJobsStorage",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "FUNCTIONS_EXTENSION_VERSION",
          "value": "~1"
        },
        {
          "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('azFunctionsAppStorageAccountName'), ';AccountKey=', listKeys(variables('azFunctionAppStorageAccountid'),'2015-05-01-preview').key1)]"
        },
        {
          "name": "WEBSITE_CONTENTSHARE",
          "value": "[toLower(parameters('webApiFunctionAppName'))]"
        }
      ]
    }
  }
}
 类似资料:
  • 我正在通过以下URL为功能应用程序执行azure active directory身份验证https://www.c-sharpcorner.com/article/secure-azure-function-with-azure-ad/ 但是,当我通过功能应用程序点击我的url时,它会给我未经授权的权限,我还需要做其他事情吗 请查看以下屏幕截图。 非常感谢您的帮助

  • 我正在制作一个需要firebase身份验证的应用程序,但收到一个错误。 “此应用未被授权使用Firebase身份验证。 > sha-1是正确的 项目包是正确的 项目已连接到firebase 依赖项设置正确 电话身份验证已启用 还有一件事,我只收到这个错误,当我从Playstore下载的应用程序,当我从Android Studio安装它的应用程序工作正常。.

  • 我正在学习Azure AD和Office 365,我想知道以下内容是否可行,如果可行,如何进行,因为我对文档的几个方面感到困惑: 假设一家名为Companyya的公司为其组织的用户提供Office 365。这些用户使用其Office 365 Cred使用Exchange/Outlook和Office登录(Office desktop)。 Companyya在内部托管了Active Director

  • 我收到以下错误: 尽管我在。 我点击了以下链接:https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory POM: 主要内容: 控制器 应用属性 我更新了我的POM 更新POM后的新

  • 我有一个ASP。NET MVC Web应用程序在Azure应用程序服务中作为Web应用程序运行。此web应用程序通过HttpClient从控制器调用Azure函数。使用Azure Active Directory在web应用中配置身份验证/授权。我需要在调用Azure函数时对用户进行身份验证,以便我可以访问用户声明。我还试图在Azure功能本身中配置身份验证,但每当我从web应用调用该功能时,这都