0

I want to store location information in DocumentDB, hence using the Point type from DocumentDB. I have a class LocationInfo to map data from the incoming post request.

#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;}
}

My function isn't compiling and I am getting the error below.

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?)

How do I reference using Microsoft.Azure.Documents.Spatial; in an Azure Function.

Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66

1 Answers1

1

You'll need to add the Document DB nuget package to your function, see this answer: https://stackoverflow.com/a/36411537/5915331

  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).
Community
  • 1
  • 1
Matt Mason
  • 2,676
  • 9
  • 22