使用App服务的身份验证来授权功能App

时间:2019-08-23 11:24:20

标签: azure azure-active-directory azure-web-sites azure-functions

在Azure中,我有一个与Application App通信的Web应用程序App服务。我在Web应用程序上具有Azure AD身份验证。我想确保功能应用程序仅由经过身份验证的用户调用。

作为一种选择,我在想是否可以将某些令牌或任何数据从Web应用程序传递到功能应用程序,以验证用户。

如果没有,请分享其他方式。

注意:Web应用程序在Angular中,Function App在Java中。

1 个答案:

答案 0 :(得分:0)

如果您的azure函数身份验证级别为匿名或也需要函数密钥,则可以使用访问令牌直接访问Azure函数API。详细步骤如下。

  1. 为Azure功能配置Azure AD。请参阅https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings#auth
  2. 获取访问令牌
Method : POST
URL:  https://login.microsoftonline.com/your directory ID/oauth2/token 

Header:  
        Content-Type : application/x-www-form-urlencoded
Body
       "grant_type ": "client_credentials",
        "client_id": "the app id of the Azure AD application you project Azure function",
        "client_secret": ":the app secret of the Azure AD application you project Azure function",
        "resource": "the app id of the Azure AD application you project Azure function"

enter image description here

  1. 调用Azure函数 enter image description here