使用Azure函数时,我遇到了很多System.Net.Http
库问题。如果我在门户中创建一个全新的httptrigger函数,它工作正常。但是,我想用我自己的precompiled assembly。当我这样做时,我会遇到各种各样的问题。Azure函数 - System.Net.Http
我看到的一个症状是传入的HttpRequestMessage
没有详细信息。 RequestUri是空的,加上任何其他属性 - 例如。头文件等。请注意,该参数不是空 - 它似乎还没有被填充任何东西。
另一个症状是,当它试图调用GetQueryNameValuePairs
,它没有说:
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)'.
下面是我的.csproj文件的内容:
<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>
的Microsoft.AspNet.WebApi.Core
NuGet包包含system.net.http
库。我已经尝试了与此相关的各种nuget软件包的各种组合 - 但没有运气。
有谁知道我应该用什么软件包来实现这个功能?
这似乎现在工作。不幸的是,这不包括GetQueryNameValuePairs方法,所以我只是使用正则表达式来分析查询字符串。也不得不将所有其他库降级到46(来自.net核心),因为那里成为链依赖性错误。希望Azure函数能很快支持.NET Core(https://github.com/Azure/Azure-Functions/issues/98)。 – Dan