CorrelationId
CorrelationId copied to clipboard
Usage in Azure Functions
Hi,
Thanks for this library, it is great.
I had a use case for it in Azure Functions where there is no middleware pipeline to hook into, so I used the library and added a small class that emulates the key bits of the middleware from this project but allowing it to be called as a wrapper function on a single HTTP Request in isolation.
You can see the code in this gist and you use it like this:
public MyFunc(HttpCorrelation http)
{
this.http = http;
}
[FunctionName(nameof("MyFunc"))]
public async Task<IActionResult> Put([HttpTrigger(AuthorizationLevel.Function, "put", Route = "endpoint")]
HttpRequest req)
{
return await http.ExecuteFunction(req, async () =>
{
// Do stuff ...
return new AcceptedResult();
});
}
Just posting it here in case it is of use to anyone or you wanted to adopt a version of it.