forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pulumi#357 from pulumi/mikhailshilkov/fix-url-shor…
…tener Fix the URL shortener example
- Loading branch information
Showing
3 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
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, | ||
key: masterKey, | ||
connectionPolicy: { preferredLocations: [region] }, | ||
}); | ||
|
||
const { database: db } = await client.databases.createIfNotExists({ id: "thedb" }); | ||
const db = client.database("thedb"); | ||
const { container } = await db.containers.createIfNotExists({ id: "urls" }); | ||
return container; | ||
} |
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
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