forked from AzureCosmosDB/cosmos-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazuredeploy.bicep
137 lines (125 loc) · 3.12 KB
/
azuredeploy.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
param location string = resourceGroup().location
@description('Name of the chat application. Needs to be unique for Cosmos DB & App Service')
param chatAppName string
@description('Specifies App Service Sku (F1 = Free Tier)')
param appServicesSkuName string = 'F1'
@description('Specifies App Service capacity')
param appServicesSkuCapacity int = 1
@description('Enable Cosmos DB Free Tier')
param cosmosFreeTier bool = true
@description('Cosmos DB Container Throughput (<1000 for free tier)')
param cosmosContainerThroughput int = 400
var cosmosDBAccountName = '${chatAppName}-cosmos'
var hostingPlanName = '${chatAppName}-hostingplan'
var webSiteName = '${chatAppName}-webapp'
var webSiteRepository = 'https://github.com/AzureCosmosDB/cosmos-chat.git'
var databaseName = 'ChatDatabase'
var containerName = 'ChatContainer'
resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = {
name: cosmosDBAccountName
location: location
kind: 'GlobalDocumentDB'
properties: {
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
databaseAccountOfferType: 'Standard'
enableFreeTier: cosmosFreeTier
locations: [
{
failoverPriority: 0
isZoneRedundant: false
locationName: location
}
]
}
}
resource cosmosDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-08-15' = {
parent: cosmosAccount
name: databaseName
properties: {
resource: {
id: databaseName
}
}
}
resource cosmosContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-08-15' = {
parent: cosmosDatabase
name: containerName
properties: {
resource: {
id: containerName
partitionKey: {
paths: [
'/ChatSessionId'
]
kind: 'Hash'
version: 2
}
indexingPolicy: {
indexingMode: 'Consistent'
automatic: true
includedPaths: [
{
path: '/ChatSessionId/?'
}
{
path: '/Type/?'
}
]
excludedPaths: [
{
path: '/*'
}
]
}
}
options: {
throughput: cosmosContainerThroughput
}
}
}
resource hostingPlan 'Microsoft.Web/serverfarms@2020-12-01' = {
name: hostingPlanName
location: location
sku: {
name: appServicesSkuName
capacity: appServicesSkuCapacity
}
}
resource webSite 'Microsoft.Web/sites@2020-12-01' = {
name: webSiteName
location: location
properties: {
serverFarmId: hostingPlan.id
siteConfig: {
appSettings: [
{
name: 'CosmosUri'
value: cosmosAccount.properties.documentEndpoint
}
{
name: 'CosmosKey'
value: cosmosAccount.listKeys().primaryMasterKey
}
{
name: 'CosmosDatabase'
value: databaseName
}
{
name: 'CosmosContainer'
value: containerName
}
]
}
}
}
resource source 'Microsoft.Web/sites/sourcecontrols@2020-12-01' = {
parent: webSite
name: 'web'
properties: {
repoUrl: webSiteRepository
branch: 'main'
isManualIntegration: true
}
}