Reputation: 2807
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
Reputation: 23111
Regarding how to call the Azure function projected by Azure AD, please refer to the following steps
Get the details of AD application used to project Azure function
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>
<function url>
Authorization: Bearer <access token>
Upvotes: 1