调用由AAD保护的天蓝色函数

时间:2020-04-27 04:14:35

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

我想调用azure函数。此功能的身份验证由Azure AD启用。

我想从可能使用HTTP并自动连接该功能的Azure Web作业或内部工具中调用此功能。在这种情况下,无法提示登录页面然后登录。

我可以为启用了AAD的功能获取令牌,然后在调用该功能时将令牌作为承载令牌发送吗?

如何实现这一目标或任何更好的主意?

1 个答案:

答案 0 :(得分:1)

关于如何调用Azure AD投影的Azure函数,请参考以下步骤

  1. 为Azure功能配置Azure AD enter image description here

  2. 获取用于投影Azure功能的AD应用程序的详细信息

    a。获取应用程序ID enter image description here

    b。创建客户机密 enter image description here

    c。获取应用程序ID网址 enter image description here

  3. 使用client credentials flow获取Azure AD访问令牌

POST /<your tenant id>/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded

grant_type =client_credentials
&client_id=<your application id>
&client_secret=<your client secret>
&resource=<your application id url>
  1. 调用Azure函数
<function url>

Authorization: Bearer <access token>

enter image description here

相关问题