Created
November 12, 2018 12:57
-
-
Save ealsur/69d013ce39dd3cda821827c963303b16 to your computer and use it in GitHub Desktop.
Azure Cosmos DB + Functions Cookbook - Multi master & preferred region
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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