Reputation: 736
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.
Upvotes: 4
Views: 6066
Reputation: 12538
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.
Upvotes: 11