Skip to content

Instantly share code, notes, and snippets.

@johndowns
Created September 17, 2018 09:53
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 johndowns/6fe30a1c8cafcde1999f53c4468c90e9 to your computer and use it in GitHub Desktop.
Save johndowns/6fe30a1c8cafcde1999f53c4468c90e9 to your computer and use it in GitHub Desktop.
try
{
var cosmosDBClient = new DocumentClient(
new Uri(ConfigurationManager.AppSettings["CosmosDBAccountEndpoint"]),
ConfigurationManager.AppSettings["CosmosDBAccountKey"]);
await cosmosDBClient.GetDatabaseAccountAsync();
}
catch (DocumentClientException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized)
{
return req.CreateResponse(HttpStatusCode.InternalServerError, "The Cosmos DB account key is not valid.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment