Access user info in a python Azure function

JDR 70 Reputation points


Failry new to Azure. I have created a React web app service and protected it with authentication following

Using this web app, my users can call azure functions (rest api calls from React) to perform data manipulation operations (upload, edit, remove, etc.).

Q1: do I need to follow the same process to add authentication to my azure functions?

Q2: Can I access some info about the user (for ex. a user id) in my azure functions? My functions are in python, python examples would be fantastic.

Thanks in advance for any help.


Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,699 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JDR 70 Reputation points

    As simple as

    def main(req: func.HttpRequest) -> func.HttpResponse:
        # Retrieve the claims from the request headers
        claims = req.headers.get("X-MS-CLIENT-PRINCIPAL")

    and claims contains a Base64 encoded JSON representation of the available claims.