Azure / Azure/azure-functions-host
Prevent access to host's HttpConfiguration
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
We had a customer run into a tough-to-diagnose scenario where they were overwriting the `GlobalConfiguration.Configurate.DependencyResolver` property, which the host needs to function properly. This led to a lot of confusing errors (but their functions continued to run, adding to the confusion).
Is there a way to prevent access to this config? It really shouldn't be touched as the results can be tough to predict.
Repro:
In a new function, add project.json with:
```
{
"frameworks": {
"net46":{
"dependencies": {
"Unity.AspNet.WebApi": "5.0.11"
}
}
}
}
```
In the function add:
```
using System.Net;
using System.Web.Http;
using Unity.AspNet.WebApi;
using Unity;
public static async Task Run(HttpRequestMessage req, TraceWriter log)
{
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(new UnityContainer());
}
```
Run the function and you'll start getting red popups in the portal as calls to our Controllers start to fail.
Contributor guide
Research direction
Start with the project.json dependency setup and the function Run entry point in the repro, then run it and observe the portal errors when DependencyResolver is overwritten. Done means the host remains protected from this configuration change or the issue has a clearly defined, tested prevention behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100