Azure函数-System.Net.Http [英] Azure Functions - System.Net.Http

查看:64
本文介绍了Azure函数-System.Net.Http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Azure Functions时,System.Net.Http库遇到很多麻烦.如果我在门户中创建一个全新的httptrigger Function,它将正常工作.但是,我想使用自己的预编译的程序集 .当我这样做时,我会遇到各种各样的问题.

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.

我看到的一个症状是,传入的HttpRequestMessage中没有详细信息. RequestUri为空,再加上其他任何属性-例如.标头等.请注意,该参数不是null-似乎没有填充任何东西.

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.

另一个症状是,当它尝试调用GetQueryNameValuePairs时,失败说:

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)'.

以下是我的.csproj文件的内容:

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>

Microsoft.AspNet.WebApi.Core nuget软件包包含system.net.http库.我尝试了与此相关的不同nuget软件包的各种组合-但没有运气.

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?

推荐答案

我在System.Net.Http中遇到MissingMethodExceptions问题.对我有用的是以下参考:

I had issues with MissingMethodExceptions in System.Net.Http. What worked for me was the following reference:

<package id="System.Net.Http" version="4.0.0" targetFramework="net461" />

这篇关于Azure函数-System.Net.Http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆