Skip to content

Instantly share code, notes, and snippets.

@ealsur
Created November 12, 2018 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ealsur/69d013ce39dd3cda821827c963303b16 to your computer and use it in GitHub Desktop.
Save ealsur/69d013ce39dd3cda821827c963303b16 to your computer and use it in GitHub Desktop.
Azure Cosmos DB + Functions Cookbook - Multi master & preferred region
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "HttpInputBindingByIdInRoute/{id}")] HttpRequestMessage req,
[CosmosDB(databaseName: "%CosmosDBDatabase%",
collectionName: "%CosmosDBCollection%",
ConnectionStringSetting = "CosmosDBConnectionString",
UseMultipleWriteLocations = true,
PreferredLocations = "Central US,North Central US"
Id = "{id}")] Document document,
ILogger log)
{
if (document == null)
{
return new HttpResponseMessage(HttpStatusCode.NotFound);
}
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(JsonConvert.SerializeObject(document), Encoding.UTF8, "application/json")
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment