Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions - how to obtain invocation ID from within the function?

I am trying to return the invocation ID of an Azure function, similar to WebJob's sending the WebJob run ID back in the HTTP Location header. This is so the invoker of my function can check the status periodically to know when it completes.

I see that I must add this id into the response object, and I surmise I need to retrieve it from some context object in the function. This is because when I visit the Functions UI at https://functionapp.scm.azurewebsites.net/azurejobs/#/functions/invocations/a-long-guid I see a variable named _context with the invocation id. However, I can't seem to access a variable named context, _context, etc in my function.

like image 251
r590 Avatar asked Oct 16 '25 05:10

r590


1 Answers

You can bind to the ExecutionContext by adding a parameter of that type to your function's method (e.g. Run(..., ExecutionContext context)).

That type exposes an InvocationId property that will give you the information you're looking for.

like image 136
Fabio Cavalcante Avatar answered Oct 18 '25 19:10

Fabio Cavalcante



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!