Quick tip: using ExecutionContext in Azure Functions
You might have a function in and Azure Functions App, where you need to know the local path for the function, for example to compose a path to a local file that resides there.
There’s a way to get the path, by adding a parameter of type Microsoft.Azure.WebJobs.ExecutionContext to your function. The Functions runtime will automatically populate it with the function location and an invocation id that might be handy for tracing purposes.
In the following sample function I added the parameter, serialize all it’s properties to JSON and write it to the log stream: