We need OperationId value inside a HTTP Trigger Azure Function. How can we get it. Highlighted OperationID in the image
You can use Activity.Current.RootId
to get Operation Id inside a HTTP Trigger in portal.
Code:
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Diagnostics;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
log.LogInformation($"Activity Current RootId:{Activity.Current.RootId}");
string operationId = Activity.Current.RootId;
return new OkObjectResult("success");
}