Giuseppe Solino Thanks for posting your question in Microsoft Q&A. From the description above, you are using Easy Auth in Azure Functions with B2C and would like to access user info, claims info in the function code.
The claims of the user/application authenticated are available in the HTTP request headers and you can access these headers in all language frameworks as described in Access user claims in app code doc and this applies to Azure Functions as well - refer Working with client identities doc. Then you need to decode the client principal header in your app code and since you mentioned C#, there is an example on how to parse the claims.
If you are using in-process
model (or csx
script), you can also pass ClaimsPrincipal
as parameter (as suggested by Albert Tanure, like in this example) or grabbing it from the HttpRequest
object via req.HttpContext.User
. See this comment and Azure Functions HTTP trigger documentation and let me know if you have any questions or issues.
In case of isolated
model, req.Identities
returns ClaimsIdentity
collection (HttpRequestData.Identities) with few limitations. If it returns null for your scenario (or not yet supported), please feel free to submit feedback via https://github.com/Azure/azure-functions-dotnet-worker/issues.
Note: ClaimsPrincipal.Current
isn't populated automatically.
I hope this helps and let me know if any questions.
If you found the answer to your question helpful, please take a moment to mark it as Yes
for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.