Noor A Shuvo
Noor A Shuvo

Reputation: 2807

Calling an azure function secured by AAD

I want to call an azure function. The authentication for this function is enabled by Azure AD.

I want to call this function from an azure web job or internal tool that may use HTTP and connect the function automatically. In this case, there is no way to prompt a login page and then login.

Can I get a token for the function where AAD is enabled, and then while calling the function will send the token as bearer token?

How to accomplish that or any better idea?

Upvotes: 0

Views: 1089

Answers (1)

Jim Xu
Jim Xu

Reputation: 23111

Regarding how to call the Azure function projected by Azure AD, please refer to the following steps

  1. Configure Azure AD for Azure Function enter image description here

  2. Get the details of AD application used to project Azure function

    a. Get application ID enter image description here

    b. Create client secret enter image description here

    c. Get Application Id Url enter image description here

  3. Use client credentials flow to get Azure AD access token

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. Call Azure function
<function url>

Authorization: Bearer <access token>

enter image description here

Upvotes: 1

Related Questions