Last active
December 22, 2021 09:32
-
-
Save andijakl/d5c0684dc9737cc7a2511699ea54cd83 to your computer and use it in GitHub Desktop.
Configure access to the Azure Cosmos DB
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
app.get('/', async (req, res) => { | |
// Import database node module | |
const CosmosClientInterface = require("@azure/cosmos").CosmosClient; | |
// Database and container IDs | |
const databaseId = "ToDoList"; | |
const containerId = "Items"; | |
// Configure database access URI and primary key | |
const endpoint = "https://<...>.documents.azure.com:443/"; | |
const authKey = "<...>"; | |
// Instantiate the cosmos client, based on the endpoint and authorization key | |
const cosmosClient = new CosmosClientInterface({ | |
endpoint: endpoint, | |
auth: { | |
masterKey: authKey | |
}, | |
consistencyLevel: "Session" | |
}); | |
// ... (we will add more code here!) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment