forked from Gordonby/nodejs-appsvc-cosmosdb-bottleneck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmos2021.bicep
72 lines (64 loc) · 1.86 KB
/
cosmos2021.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This file uses the newer API's for Cosmos, however the node app doesn't cope well
// Leaving the file here for reference, but know that it's not used by main.bicep
@description('Name of the CosmosDb Account')
param databaseAccountId string
param databaseAccountLocation string =resourceGroup().location
param databaseName string = 'sampledatabase'
param collectionName string = 'samplecollection'
resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = {
kind: 'MongoDB'
name: databaseAccountId
location: databaseAccountLocation
properties: {
databaseAccountOfferType: 'Standard'
locations: [
{
locationName: '${resourceGroup().location}'
failoverPriority:0
isZoneRedundant: false
}
]
}
}
output databaseAccountId string = cosmosDbAccount.id
resource cosmosDbThroughput 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections/throughputSettings@2021-06-15' = {
parent: cosmosDbCollection
name: 'default'
properties: {
resource: {
throughput: 400
}
}
}
resource cosmosDbDatabase 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases@2021-06-15' = {
parent: cosmosDbAccount
name: databaseName
properties: {
resource: {
id: databaseName
}
}
}
resource cosmosDbCollection 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections@2021-06-15' = {
parent: cosmosDbDatabase
name: collectionName
properties: {
resource: {
id: collectionName
shardKey: {
user_id: 'Hash'
}
indexes: [
{
key: {
keys: [
'_id'
]
}
}
]
}
}
}
output accountId string = cosmosDbDatabase.id
output connstr string = first(listConnectionStrings('Microsoft.DocumentDb/databaseAccounts/${databaseAccountId}', '2015-04-08').connectionStrings).connectionString