I'm having quite a lot of trouble with the System.Net.Http
libraries when using Azure Functions. If I create a brand new httptrigger Function in the portal, it works fine. However, I want to use my own precompiled assembly. When I do this, I get all sorts of issues.
One symptom I'm seeing is that the HttpRequestMessage
that gets passed in has no details in it. RequestUri is empty, plus any of the other properties - eg. headers, etc. Note that the parameter is not null - it just seems to have not been populated with anything.
Another symptom is that when it tries to call GetQueryNameValuePairs
, it fails saying:
Exception while executing function: Functions.WebHookSync. mscorlib: Exception has been thrown by the target of an invocation. MyFunctionName.Functions: Method not found: 'System.Collections.Generic.IEnumerable`1<System.Collections.Generic.KeyValuePair`2<System.String,System.String>> System.Net.Http.HttpRequestMessageExtensions.GetQueryNameValuePairs(System.Net.Http.HttpRequestMessage)'.
Below is the contents of my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyOtherAssembly\MyOtherAssembly.csproj" />
</ItemGroup>
</Project>
The Microsoft.AspNet.WebApi.Core
nuget package contains the system.net.http
libraries. I've tried various combinations of the different nuget packages that relate to this - but having no luck.
Does anyone know what packages I should be using to get this to work?