I am working on an Azure Function that runs on the CosmosDB trigger. Microsoft has created this example https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-cosmos-db-triggered-function which works out nicely concerning the trigger.
I am now asking myself how to parse the returned document in a smooth way. The data I get back from the trigger function is from the class Microsoft.Azure.Documents.Document (IReadOnlyList<Document> documents).
Any nice idea on how to parse those data into Json objects or comparable?
Thx!
Document can be deserialized to any type you want, for example:
foreach (Document document in documents)
{
MyClass myClass = JsonConvert.DeserializeObject<MyClass>(document.ToString());
}
You can also read any of its properties:
foreach (Document document in documents)
{
string myPropertyValue = document.GetPropertyValue<string>("myProperty");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With