【发布时间】:2017-04-08 18:40:49
【问题描述】:
在使用 Azure Functions 时,我在使用 System.Net.Http 库时遇到了很多麻烦。如果我在门户中创建一个全新的 httptrigger 函数,它可以正常工作。但是,我想使用我自己的precompiled assembly。当我这样做时,我会遇到各种各样的问题。
我看到的一个症状是传入的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 包的各种组合 - 但没有运气。
有谁知道我应该使用什么包来让它工作?
【问题讨论】:
标签: c# .net azure nuget azure-functions