Azure Functions and getting identity information

Looking for a quick Azure Function sample when working with Azure AD SSO?

#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Security.Claims;

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
    log.LogInformation("Request Started");

    ClaimsPrincipal principal = req?.HttpContext?.User as ClaimsPrincipal;

    string result = null;
    result += "Request Time: " + System.DateTime.Now.ToString() + "\n";

	if (req?.Headers != null) 
	{
		log.LogInformation("HTTP Request Headers");
		result += "HTTP Request Headers\n";
		foreach (var key in req.Headers.Keys)
		{
			log.LogInformation($"{key} = {req.Headers[key]}");
			result += $"{key} = {req.Headers[key]}\n";
		}
		result += "\n\n";
	}
    
    if (null != principal)  
    {      
        foreach (Claim claim in principal.Claims)  
        {  
            result += "CLAIM TYPE: " + claim.Type + "; CLAIM VALUE: " + claim.Value + "\n";  
        }  
    } 
    else 
    {
        result += "No Current User Principal\n";
    }
    
    log.LogInformation("Request Completed");

    return (ActionResult)new OkObjectResult(result);
}