Azure Active Directory 身份验证功能应用程序

编程入门 行业动态 更新时间:2024-10-28 18:36:04
本文介绍了Azure Active Directory 身份验证功能应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在通过以下 URL 为函数应用程序执行 azure Active Directory 身份验证

感谢任何帮助

解决方案

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

  • 为 Azure Function 配置 Azure AD.请参考

    然后我可以直接使用访问令牌.我用 Postman 测试过:

    请注意,如果你的天蓝色函数认证级别不是匿名的,你需要添加函数密钥

    I am doing azure active directory authentication for function app by following below URL www.c-sharpcorner/article/secure-azure-function-with-azure-ad/

    But when i hitting my url through function app It is giving unauthorized do i need to do anything else

    please find the below screen shots.

    any help is appreciated

    解决方案

    We could use the access token to access your Azure function API directly if your azure function authentication level is anonymous or function key is also required. The detailed steps are as below.

  • Configure Azure AD for Azure Function. Please refer to docs.microsoft/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings#auth.
  • Get Access token
  • I get an access token from AAD using clientID and clientSecret using the following code:

    METHOD: POST Url : login.microsoftonline/your directory ID/oauth2/token HEADERS: Content-Type : application/x-www-form-urlencoded BODY: grant_type+=client_credentials&resource+="your Function url"&client_id+++++="the application that your register id"&client_secret+="the key you create"

    Please note that according to the Azure Resources portal (resources.azure/), the default allowedAudiences is

    {functionAppName}.azurewebsites/.auth/login/aad/callback

    So I added the {functionAppName}.azurewebsites/ as allowed audiences.

    Then I can use the access token directly. I tested it with Postman:

    Please note that if your azure function authentication level is not anonymous, you need to add the function key

    更多推荐

    Azure Active Directory 身份验证功能应用程序

    本文发布于:2023-11-14 08:51:22,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1586761.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:应用程序   身份验证   功能   Azure   Active

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!