title: Error while executing test, if using CreateResponse extention method to return Azure Function HttpResonseMessage
body: <p>My Azure Function code is like below</p>
  
  <pre><code>public static class MyHttpTriggerFunction
  {       
      public static async Task&lt;HttpResponseMessage&gt; Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
      {
          // some business logic
  
          if (valid)
          {
              return req.CreateResponse(HttpStatusCode.OK, true);
          }
          else
          {
               return req.CreateResponse(HttpStatusCode.BadRequest, "some error message");
          }            
      }
  }
  </code></pre>
  
  <p>In my test project I am reading the result like below:</p>
  
  <pre><code>var result = await MyHttpTriggerFunction.Run(req, log).ConfigureAwait(false);
  </code></pre>
  
  <p>After executing the function, when it try to return the response in result variable, the test method fails with exception.</p>
  
  <p>**</p>
  
  <blockquote>
    <p>System.InvalidOperationException: The request does not have an
    associated configuration object or the provided configuration was
    null.</p>
  </blockquote>
  
  <p>**</p>
  
  <p>I have made sure that test project has the same <code>System.Net.Http.HttpRequestMessageExtension</code> dll.</p>
  
  <p>If I change the function  code not to use <code>CreateResponse</code> extension method (this extension method is from the VS 2017 template's code )
  and return the response like below, I get the response in test method and  the test case  runs fine.</p>
  
  <pre><code>var res = new HttpResponseMessage();
  if (valid)
  {
      res.StatusCode = HttpStatusCode.OK;
      res.Content = new ObjectContent&lt;bool&gt;(true, new JsonMediaTypeFormatter());        
      return res;
  }
  else
  {
       res.StatusCode = HttpStatusCode.BadRequest;
       res.Content = new ObjectContent&lt;string&gt;("some error message", new JsonMediaTypeFormatter());
       return res;
  }
  </code></pre>
  
  <p>Below is the stacktrace of error</p>
  
  <blockquote>
    <p>Result StackTrace:     at
    System.Net.Http.HttpRequestMessageExtensions.CreateResponse[T](HttpRequestMessage
    request, HttpStatusCode statusCode, T value, HttpConfiguration
    configuration)    at
    System.Net.Http.HttpRequestMessageExtensions.CreateResponse[T](HttpRequestMessage
    request, HttpStatusCode statusCode, T value)    at
    MyFunctionApp.MyHttpTriggerFunction.d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---    at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)    at
    System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
    at
    MyFunctionAppUnitTest.MyHttpTriggerFunctionTest.d__2.MoveNext()
    in
    C:\Users\rsingh\Desktop\Git_Workspace\ActivationAPI\MyFunctionAppUnitTest\MyHttpTriggerFunctionTest.cs:line
    53
    --- End of stack trace from previous location where exception was thrown ---    at
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
    task)    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task)    at
    Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.ThreadOperations.ExecuteWithAbortSafety(Action
    action) Result Message:    Test method
    MyFunctionAppUnitTest.MyHttpTriggerFunctionTest.MyHttpTriggerFunction_SuccessResult
    threw exception:  System.InvalidOperationException: The request does
    not have an associated configuration object or the provided
    configuration was null.</p>
  </blockquote>
  
  <p>Am I missing something trivial</p>