无法在 Azure 函数中引用 GeoSpatial 类型点

Can not reference GeoSpatial type Point in Azure functions

我想在 DocumentDB 中存储位置信息,因此使用 DocumentDB 中的 Point 类型。我有一个 class LocationInfo 来映射来自传入 post 请求的数据。

#r "Newtonsoft.Json"

using Newtonsoft.Json; 
using Microsoft.Azure.Documents.Spatial;

public class LocationInfo
{    
    [JsonProperty(PropertyName = "deviceId")]
    public string DeviceId {get; set;}

    [JsonProperty(PropertyName = "location")]
    public Point Location {get; set;}

    [JsonProperty(PropertyName = "activityId")]
    public string ActivityId {get; set;}

    [JsonProperty(PropertyName = "type")]
    public string Type {get; set;}

    [JsonProperty(PropertyName = "dateTime")]
    public DateTime DateTime {get; set;}
}

我的函数没有编译,我收到以下错误。

error CS0234: The type or namespace name 'Documents' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?)
error CS0246: The type or namespace name 'Point' could not be found (are you missing a using directive or an assembly reference?)

如何在 Azure 函数中引用 using Microsoft.Azure.Documents.Spatial;

您需要将 Document DB nuget 包添加到您的函数中,请参阅此答案:

  1. In the function's develop section, click on view files
  2. Click on the option to create a file (you can also click on the option to upload a file if you have a previously created project.json file on your machine
  3. Name the file project.json and define your package references (you can use the example above as a template).