Azure中的Contentful.Csharp Nuget包

时间:2017-09-19 22:50:39

标签: c# azure nuget

所以我已成功将nuget包上传到我的azure函数中,但它一直给我这个错误:

  

“无法找到类型或命名空间名称'ContentfulClient'(您是否缺少using指令或程序集引用?)”

我已从project.json文件安装了nuget包。

这是我的代码:

using System.Net;
using System.Net.Http;


private static HttpClient httpClient;
private static ContentfulClient contentfulClient;
private static ContentfulClient contentfulPreviewClient;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, 
 TraceWriter log){
    log.Info("C# HTTP trigger function processed a request.");
    httpClient = new HttpClient();
    contentfulClient = new ContentfulClient(httpClient, 
   "f802e4676d16fc1476580e4a50c8f3b180b875eaffad0680a55139f3338d5ac3","i6w3gtjaaewo");
    contentfulPreviewClient = new ContentfulClient(httpClient, 
   "e9da3ff45bc38a213c41ac768732c0ac75df5c453a2ed651bfd946cb5f226c5f", "i6w3gtjaaewo", true);

     log.Info("C# HTTP trigger function processed a request.");

    // parse query parameter
     string name = req.GetQueryNameValuePairs()
    .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
    .Value;

  // Get request body
  dynamic data = await req.Content.ReadAsAsync<object>();

  // Set name to query string or body data
  name = name ?? data?.name;

   return name == null
    ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on 
    the query string or in the request body")
    : req.CreateResponse(HttpStatusCode.OK, "Hello " + name);
}

1 个答案:

答案 0 :(得分:0)

所以我通过引用nuget包中的直接dll找到了解决方法。事实证明,Azure功能目前不支持高于NetStandard 1.3的库。很快将发布更新以解决此问题。您可以在此处跟踪对话:https://github.com/Azure/Azure-Functions/issues/98