Azure / Azure/azure-functions-dotnet-worker

Providing a parameter value from middleware

Open
#1,300 14 comments 1 reaction 2 assignees Claimed by @fabiocav View on GitHub
area: documentation
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

Using Middleware in an azure function, is it possible to modify the context to bind an object to a parameter in the function?

```
public class FunctionInvocationLoggingMiddleware : IFunctionsWorkerMiddleware
{
public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next)
{
context.SupplyParameter("myObject", new someObject()); // Fictional code that shows what I want to do
await next(context);
}
}
```

```
[Function("Function1")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
someObject myObject) // This value is provided by the middleware if requested
{
....
}
```

This would be similar to MVC value providers, I guess.

The use case is that I have a lot of functions that take a blob of xml, and it would be nice to be able to parse, log and debug that xml in the middleware before simply providing the C# type to the function all nice and ready to go.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.