Azure Function App Secured by AAD App registration. 401 - you do not have permission to view this directory or page

Zakaria Muhammad 161 Reputation points
2021-05-03T20:34:34.25+00:00

I created a simple function with default code to say Hello <name>. I am able to run the code if the Authentication Settings under (Function -> Authentication) is set to "Allow unauthenticated Access".

As soon as I change those to "Require authentication" and add a Identity provider by following the documentation (https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad). the simple code start throwing Error. I am using Postman and able to generate the token but when I pass that tokens to access the function, it says 401 did I miss any configuration. I am gone through a lot of community article but none of them is clear. I still think that I am missing some authorization permission for the App Registration account which is not mentioned in the above article because as being a Global admin, I am able to access the function directly using browser and my credentials.

93360-image.png

Token generator

93421-image.png

Pass Token to call the function.

93375-image.png

Error "You do not have permission to view this directory or page."

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,999 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,626 questions
{count} vote

Accepted answer
  1. Zakaria Muhammad 161 Reputation points
    2021-05-04T19:33:41.393+00:00

    Followed this documentation "https://cuteprogramming.wordpress.com/2019/01/02/authenticate-an-azure-function-with-azure-active-directory/" and successfully configured the function with AAD authentication.

    the only thing is that, for me the Authentication (Classic) was greyed out and I have to recreate the new Azure Function.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sam Johnson 6 Reputation points
    2021-06-13T00:32:50.273+00:00

    Suggestion: Make it clear that one cannot simply switch back to 'Classic' once trying the new experience.

    Figured an improved version would be easier to use. I've tried it twice so far, no success, and I'm uncertain why this left preview. Would love to see some good documentation for it.

    Thanks!

    0 comments No comments