简体   繁体   中英

How to add security to Azure Function?

I'm new at Azure. So i've developed a simple Web app in.net core 6 which autenticathes with AZ AD. I also add to my solución an azure function but the idea is to add JWT to it. From azure portal i added, authentication but i dont know how to get a token to, for example, test it with postman.

Does someone know how to do this? I've Watch a lot of videos but still can't get it.

Regards

i need help to add security to my az function and be able to add jwt to my web app and to try tokens from postman.

I tried to reproduce the same in my environment and got the results like below:

Create an Azure AD Application and add API permissions:

在此处输入图像描述

Generate the Auth-Code by using below Endpoint:

https://login.microsoftonline.com/TenantID/oauth2/v2.0/authorize?  
client_id=ClientID  
&response_type=code  
&redirect_uri=RedirectURI  
&response_mode=query  
&scope=[https://management.azure.com/.default](https://management.azure.com/.default "https://management.azure.com/.default")  
&state=12345  

在此处输入图像描述

To generate the token, I used the below parameters:

GET https://login.microsoftonline.com/TenantId/oauth2/v2.0/token 

client_id:ClientID
client_secret:ClientSecret
scope:https://management.azure.com/.default
grant_type:authorization_code
redirect_uri:RedirectUri
code:code

在此处输入图像描述

By using the above generated access token, you can access Azure Function successfully like below:

GET https://management.azure.com/subscriptions/SubID/resourceGroups/RG/providers/Microsoft.Web/sites/funcapp/functions/function?api-version=2022-03-01

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM