locked
Cosmos Spatial Syntax Error RRS feed

  • Question

  • Receiving this Syntax error on basic cosmos spatial function. Creating this in Azure Function Portal. What am I missing?


    • Edited by DDL19 Saturday, August 17, 2019 11:56 AM typo
    Saturday, August 17, 2019 11:53 AM

All replies

  • Hi DDL19,

    Apologies for the delay in getting back to you with a response. We were having some issues with this platform which has since been resolved, and I am now able to respond to you.

    You need to update your client library to  Microsoft.Azure.Cosmos.

    Please let us know if you have any additional questions.

    Regards,

    Mike

    Friday, August 23, 2019 5:35 PM
  • Hello DDL19,

    You will need to reference the DocumentDB.Core assembly to make it work.

    Please add the below to your code and it should compile without any issues.

    #r "Microsoft.Azure.DocumentDB.Core"
    

    Do let us know if you have further issues.

    -

    If this answers your query, do click “Mark as Answer” and Up-Vote for the same which might be beneficial to other community members reading this thread .

    And, if you have any further query do let us know. 

    • Proposed as answer by Kalyan Chanumolu-MSFTMicrosoft employee Tuesday, August 27, 2019 4:12 AM
    • Marked as answer by DDL19 Tuesday, August 27, 2019 11:27 AM
    • Unmarked as answer by DDL19 Tuesday, August 27, 2019 2:28 PM
    • Unproposed as answer by DDL19 Tuesday, August 27, 2019 2:59 PM
    Tuesday, August 27, 2019 4:12 AM
  • Still receiving syntax error when attempting this code in the Azure Portal.... What is going on here and what am I missing?
    Tuesday, August 27, 2019 2:30 PM
  • Hi DDL19,

    Would you be willing to send me the entire run.csx file? If you could we would be able to repro this more thoroughly, and take a deeper look at this. If that is something you are wiling to do, you can send this to AzCommunity. Kalyan and I are with the same team, so either one of us will recieve this and be able to take a look. We would have to look at how Azure Functions deals with namespace. 

    Thanks,

    Mike

    Tuesday, August 27, 2019 4:29 PM
  • Hi DDL19,

    I provided you what I believe will get you past the compile errors. As for the serialization piece, this is handled directly by your code but is handled natively within .NET. Please see: Trigger and binding definitions

    In .NET, the parameter type defines the data type for input data. For instance, use string to bind to the text of a queue trigger, a byte array to read as binary and a custom type to de-serialize to an object.

    Regards,

    Mike


    Tuesday, August 27, 2019 8:18 PM
  • While creating a function from the Azure portal, the required Cosmos DB extension is not getting loaded and hence causing the compilation error.

    Did you create the Output Binding for CosmosDB already, if not please add one as shown below

    You should then be prompted to install the Extension


    Once done, You should see that the compilation error doesn't come up anymore.

    Mike has responded on the serialization issue.

    Please let us know if you need any further help.

    Wednesday, August 28, 2019 1:40 PM
  • I have deleted the Azure Cosmos DB in the Integration section and recreated it and WAS NOT prompted with "Extensions NOT Installed". What is going on here? Would it be possible to do a screen share?
    Wednesday, August 28, 2019 2:25 PM
  • Hi DDL,

    Just wanted to follow up to ensure all your questions have been addressed. I am detailing the feedback provided in the escalation to the product here, so others can use this information for their projects. If there was something specific that fixed/addressed the spatial issue, please do detail that information as well. Thank you!

    For the Azure Functions questions:

     

    1. First and foremost, do not use the Azure Portal to create Functions unless you are really doing a test. Use pre-compiled Functions created with IDE / CLI tools. Pre-compiled Functions have a better performance, not to mention that you can integrate them with CI/CD pipelines and repositories, and you can debug them locally.
      1. You can use Visual Studio https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs
      2. Visual Studio Code  https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code
      3. Or directly use the CLI if you want to work with other IDEs https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local
    2. For the First Function (Timer > Queue):
      1. Do not create Http-based clients (such as the WebClients) inside the Run implementation. See https://docs.microsoft.com/en-us/azure/azure-functions/manage-connections. Http-based clients need to use a Singleton pattern approach to avoid Connection / Sockets issues.
      2. To write information to a Queue, you can use the Queue Output Binding, using the ICollector interface, that will serialize the objects for you, see: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue#output---c-script-example
    3. For the Queue to Cosmos DB:
      1. To read from a Queue, you need to use the Queue Trigger, see https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue#trigger---usage. The Queue Trigger supports deserializing to a POCO class, so you can either deserialize to a particular class or deserialize to CloudQueueMessage, and access the metadata to decide which type of object it refers to.
      2. To write to Cosmos DB you can use the Cosmos DB Output binding: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2#queue-trigger-write-one-doc-c , there are several samples in that link for different scenarios (write one doc, write multiple docs).


    Friday, September 6, 2019 4:28 PM