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.
- Create your interface. You must include both
get
andset
on this interface.
public interface IFunctionContextAccessor
{
FunctionContext FunctionContext { get; set; }