-
Notifications
You must be signed in to change notification settings - Fork 0
/
azuredeploy.bicep
218 lines (201 loc) · 5.8 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@description('Location where all resources will be deployed. This value defaults to the same location as the resource group.')
param location string = resourceGroup().location
@description('Unique name for the chat application. The name is required to be unique as it will be used as a prefix for the names of these resources: Azure Cosmos DB, Azure Static Web App, and Azure Functions. The name defaults to a unique string generated from the resource group identifier.')
@minLength(5)
@maxLength(15)
param name string = uniqueString(resourceGroup().id)
resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = {
name: '${name}nosql'
location: location
kind: 'GlobalDocumentDB'
properties: {
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
databaseAccountOfferType: 'Standard'
locations: [
{
failoverPriority: 0
isZoneRedundant: false
locationName: location
}
]
}
}
resource cosmosDbDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-08-15' = {
parent: cosmosDbAccount
name: 'cosmicworks'
properties: {
resource: {
id: 'cosmicworks'
}
options: {
throughput: 400
}
}
}
resource cosmosDbProductsContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-08-15' = {
parent: cosmosDbDatabase
name: 'products'
properties: {
resource: {
id: 'products'
partitionKey: {
paths: [
'/category'
]
}
}
}
}
resource cosmosDbPeopleContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-08-15' = {
parent: cosmosDbDatabase
name: 'people'
properties: {
resource: {
id: 'people'
partitionKey: {
paths: [
'/lastName'
]
}
}
}
}
resource cosmosDbChangeFeedLeaseContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2022-08-15' = {
parent: cosmosDbDatabase
name: 'changefeed-leases'
properties: {
resource: {
id: 'changefeed-leases'
partitionKey: {
paths: [
'/id'
]
}
}
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: '${name}insights'
location: location
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}
resource hostingPlan 'Microsoft.Web/serverfarms@2022-09-01' = {
name: '${name}plan'
location: location
sku: {
name: 'B1'
}
}
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: '${name}storage'
location: location
kind: 'Storage'
sku: {
name: 'Standard_LRS'
}
properties: {
supportsHttpsTrafficOnly: true
minimumTlsVersion: 'TLS1_2'
}
}
resource functionApp 'Microsoft.Web/sites@2022-09-01' = {
name: '${name}functions'
location: location
kind: 'functionapp'
properties: {
serverFarmId: hostingPlan.id
httpsOnly: true
siteConfig: {}
}
}
resource functionAppSettings 'Microsoft.Web/sites/config@2022-03-01' = {
parent: functionApp
name: 'appsettings'
kind: 'string'
properties: {
AzureWebJobsStorage: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
WEBSITE_CONTENTAZUREFILECONNECTIONSTRING: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
APPINSIGHTS_INSTRUMENTATIONKEY: applicationInsights.properties.InstrumentationKey
APPLICATIONINSIGHTS_CONNECTION_STRING: 'InstrumentationKey=${applicationInsights.properties.InstrumentationKey};IngestionEndpoint=https://eastus2-0.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/'
FUNCTIONS_EXTENSION_VERSION: '~4'
FUNCTIONS_WORKER_RUNTIME: 'dotnet'
PROJECT: 'Api/Cosmos.Example.Api.csproj'
WEBSITE_CONTENTSHARE: toLower('${name}functionshare')
AZURE_COSMOS_DB_CONNECTION_STRING: 'AccountEndpoint=${cosmosDbAccount.properties.documentEndpoint};AccountKey=${cosmosDbAccount.listKeys().primaryMasterKey};'
}
}
resource functionAppConfiguration 'Microsoft.Web/sites/config@2022-09-01' = {
parent: functionApp
name: 'web'
kind: 'string'
properties: {
netFrameworkVersion: 'v6.0'
minTlsVersion: '1.2'
alwaysOn: true
cors: {
allowedOrigins: [
'https://${webApp.properties.defaultHostName}'
'https://portal.azure.com'
]
}
}
}
resource functionAppDeployment 'Microsoft.Web/sites/sourcecontrols@2022-09-01' = {
parent: functionApp
dependsOn: [
functionAppSettings
functionAppConfiguration
]
name: 'web'
properties: {
repoUrl: 'https://github.com/seesharprun/blazor-wasm-codespaces-demo.git'
branch: 'main'
isManualIntegration: true
}
}
resource webApp 'Microsoft.Web/sites@2022-09-01' = {
name: '${name}web'
kind: 'app'
location: location
properties: {
serverFarmId: hostingPlan.id
httpsOnly: true
}
}
resource webAppConfiguration 'Microsoft.Web/sites/config@2022-09-01' = {
parent: webApp
name: 'web'
kind: 'string'
properties: {
minTlsVersion: '1.2'
netFrameworkVersion: 'v7.0'
}
}
resource webAppSettings 'Microsoft.Web/sites/config@2022-03-01' = {
parent: webApp
name: 'appsettings'
kind: 'string'
properties: {
API__ENDPOINT: 'https://${functionApp.properties.defaultHostName}/'
PROJECT: 'Client/Cosmos.Example.Client.csproj'
}
}
resource webAppDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = {
parent: webApp
dependsOn: [
webAppSettings
webAppConfiguration
]
name: 'web'
properties: {
repoUrl: 'https://github.com/seesharprun/blazor-wasm-codespaces-demo.git'
branch: 'main'
isManualIntegration: true
}
}