Skip to content

Instantly share code, notes, and snippets.

View claruspeter's full-sized avatar

Peter Bayne claruspeter

View GitHub Profile
@dolphinspired
dolphinspired / FunctionContextAccessor.md
Last active March 29, 2024 10:49
FunctionContextAccessor example

IFunctionContextAccessor Implementation

This is a brief tutorial on how to create a dependency-injectable FunctionContext accessor for Azure Functions running on the dotnet-isolated runtime (.NET 5 and up). This will work very similarly to IHttpContextAccessor - it will allow you to access details about the current Function invocation and pass arbitrary values between injected services that are scoped to this invocation.

  1. Create your interface. You must include both get and set on this interface.
public interface IFunctionContextAccessor
{
 FunctionContext FunctionContext { get; set; }