locked
Accessing Microsoft.Spatial for Azure Functions RRS feed

  • Question

  • I would like to make some spatial calls against a GeoJSON file from a Azure Function. My code errors on the Microsoft.Spatial using statement. What should I be using here?
    Thursday, November 8, 2018 4:41 PM

Answers

All replies

  • Are you authoring this in the portal or in Visual Studio?

    Brett Samblanet -- Azure Functions

    Thursday, November 8, 2018 5:18 PM
  • In the portal....
    Thursday, November 8, 2018 5:20 PM
  • Looking to use the Centroid function as well as locate nearest point from a point....
    Thursday, November 8, 2018 5:26 PM
  • You likely need to add the Microsoft.Spatial nuget package: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#using-nuget-packages

    I'd also recommend looking into developing this locally on Visual Studio as debugging issues like this will be easier. When using VS, you're building a normal .NET assembly and deploying it, which allows for easier source control, unit testing, debugging locally with the debugger, etc.


    Brett Samblanet -- Azure Functions

    • Marked as answer by DDL19 Thursday, November 8, 2018 6:39 PM
    Thursday, November 8, 2018 6:00 PM
  • Is there an easy way to take existing Azure Function on the Portal and bring it down into VS?
    Thursday, November 8, 2018 6:32 PM
  • There's no way to "turn this portal site into a C# project", no. But most of the code is just straight C#, so it's generally not too troublesome to migrate. Let me know if you run into any issues.

    Brett Samblanet -- Azure Functions

    Thursday, November 8, 2018 6:36 PM
  • Brett,

    just got back to this code.... I cant find doc to access  GetCentroid()

    using System;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Azure.WebJobs.Host;
    using Microsoft.Spatial;
    
    
    namespace SpatialTestFunction
    {
        public static class Function1
        {
            [FunctionName("Function1")]
            public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
            {
                // Create a GeometryMultiPolygon.
                GeometryPolygon multiPolygon = GeometryFactory.Polygon()
                    .Polygon().Ring(-5, -5).LineTo(0, -5).LineTo(0, -2)
                    .Polygon().Ring(-10, -10).LineTo(-5, -10).LineTo(-5, -7).LineTo(-5, -5).Build();
                multiPolygon.GetCentroid();
                log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
            }
        }
    }
    This is how it is done in the online map side of the house. How can I accomplish this in a Azure Function?
     https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/getcentroid

    Wednesday, November 21, 2018 8:44 PM
  • I'm not sure, but any .NET class should be callable from within an Azure Function. If you have a specific question about the library you're using, can you create a new question in the forum for that library?

    Brett Samblanet -- Azure Functions

    Tuesday, November 27, 2018 9:08 PM