Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (13 sloc) 578 Bytes
import * as cosmos from "@azure/cosmos";
export async function getContainer(endpoint: string, masterKey: string, region: string) {
let connectionPolicy = new cosmos.ConnectionPolicy();
connectionPolicy.PreferredLocations = [region];
const client = new cosmos.CosmosClient({
endpoint,
auth: { masterKey: masterKey },
connectionPolicy,
});
const { database: db } = await client.databases.createIfNotExists({ id: "thedb" });
const { container } = await db.containers.createIfNotExists({ id: "urls" });
return container;
}
You can’t perform that action at this time.