Skip to content

Instantly share code, notes, and snippets.

@ealsur ealsur/run.csx
Last active Jan 19, 2018

What would you like to do?
Azure Cosmos DB + Functions Cookbook - HTTP query csx
#r "System.Runtime.Serialization"
using System.Net;
using System.Runtime.Serialization;
// Define the class that will get sent on the HTTP body
// DataContract is used to support XML
[DataContract(Name = "Query", Namespace = "http://functions")]
public class Query {
public string Name { get; set; }
public string City { get; set; }
public static async Task<HttpResponseMessage> Run(Query query, HttpRequestMessage req, IEnumerable<dynamic> documents, TraceWriter log)
int totalDocuments = documents.Count();
log.Info($"Found {totalDocuments} documents");
if(totalDocuments == 0){
return req.CreateResponse(HttpStatusCode.NotFound);
return req.CreateResponse(HttpStatusCode.OK, documents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.