My Azure Function code is like below
public static class MyHttpTriggerFunction
{
public static async Task Run([HttpTrig
This is not specific to Azure Functions, but in order to execute this test outside of the context of an actual HTTP request you need to make sure you create an HttpConfiguartion
instance, configure it as required (e.g. add any formatters you may need) and call SetConfiguration
on the HttpRequestMessage
instance with that object.
Example:
var configuration = new HttpConfiguration();
var request = new HttpRequestMessage();
request.SetConfiguration(configuration);
The Error message is telling you the problem.
The request does not have an associated configuration object or the provided configuration was null.
When testing the request out side of a httpserver you need to give the request a HttpConfiguration.
// Arrange.
var configuration = new HttpConfiguration();
var request = new System.Net.Http.HttpRequestMessage();
request.Properties[System.Web.Http.Hosting.HttpPropertyKeys.HttpConfigurationKey] = configuration;
//...other code