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:

Thanks for reading!

Tip: learn everything you need to know about Azure Functions with these courses.

Leave a Reply

Your email address will not be published. Required fields are marked *.

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Theme BCF By aThemeArt - Proudly powered by WordPress .