generated from staticwebdev/angular-basic
-
Notifications
You must be signed in to change notification settings - Fork 11
/
deploy.bicep
396 lines (360 loc) · 10.6 KB
/
deploy.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
@description('Specifies the application name.')
param applicationName string
@description('Specifies the application name.')
param applicationContext string
@description('The Id of the subscription.')
param subscriptionId string
@description('Specifies all secrets {"secretName":"","secretValue":""} wrapped in a secure object.')
@secure()
param secretsObject object
@description('Specifies the location for server and database')
param location string = resourceGroup().location
var applicationFullName = '${applicationContext}-${applicationName}'
var apiSiteName = 'app-${toLower(applicationFullName)}'
var appServicePlanName = 'asp-${toLower(applicationFullName)}'
var storageAccountName = 'rvt2ifc${uniqueString(resourceGroup().id)}'
var keyVaultName = 'kv-${toLower(applicationFullName)}'
var applicationInsightsName = 'appi-${toLower(applicationFullName)}'
var userAssignedIdentitiesName = 'id-${toLower(applicationFullName)}'
var staticSiteName = 'stapp-${toLower(applicationFullName)}'
var apiUrl = '${toLower(applicationName)}.azurewebsites.net'
var scmUrl = '${toLower(applicationName)}.scm.azurewebsites.net'
var budgetName = 'bg-${toLower(applicationFullName)}'
resource userAssignedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-07-31-preview' = {
name: userAssignedIdentitiesName
location: 'francecentral'
}
// Configured federated identity credentials to allow Github Actions
resource userAssignedIdentities_app_bim42_prod_f_id_a382_name_simonmoreau_RevitToIFCApp_8b5a 'Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2023-07-31-preview' = {
parent: userAssignedIdentity
name: 'simonmoreau-RevitToIFCApp-8b5a'
properties: {
issuer: 'https://token.actions.githubusercontent.com'
subject: 'repo:simonmoreau/RevitToIFCApp:environment:production'
audiences: [
'api://AzureADTokenExchange'
]
}
}
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'Storage'
properties: {
supportsHttpsTrafficOnly: true
defaultToOAuthAuthentication: true
}
}
resource vault 'Microsoft.KeyVault/vaults@2021-11-01-preview' = {
name: keyVaultName
location: location
properties: {
accessPolicies:[]
enableRbacAuthorization: true
enableSoftDelete: true
softDeleteRetentionInDays: 90
enabledForDeployment: false
enabledForDiskEncryption: false
enabledForTemplateDeployment: false
tenantId: subscription().tenantId
sku: {
name: 'standard'
family: 'A'
}
networkAcls: {
defaultAction: 'Allow'
bypass: 'AzureServices'
}
}
}
resource key 'Microsoft.KeyVault/vaults/secrets@2024-04-01-preview' = [for secret in secretsObject.secrets: {
name: secret.secretName
parent: vault
properties: {
value: secret.secretValue
}
}]
resource hostingPlan 'Microsoft.Web/serverfarms@2023-12-01' = {
name: appServicePlanName
location: location
sku: {
name: 'F1'
tier: 'Free'
size: 'F1'
family:'F'
capacity: 0
}
properties: {
perSiteScaling:false
elasticScaleEnabled:false
maximumElasticWorkerCount:1
isSpot:false
reserved:true
isXenon:false
hyperV:false
targetWorkerCount:0
targetWorkerSizeId:0
zoneRedundant:false
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
Flow_Type: 'Bluefield'
Request_Source: 'rest'
RetentionInDays: 90
}
}
resource sites_revittoifcapp_api 'Microsoft.Web/sites@2023-12-01' = {
name: apiSiteName
location: location
kind: 'app,linux'
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/${userAssignedIdentity.name}': {}
}
}
properties: {
enabled: true
hostNameSslStates: [
{
name: apiUrl
sslState: 'Disabled'
hostType: 'Standard'
}
{
name: scmUrl
sslState: 'Disabled'
hostType: 'Repository'
}
]
serverFarmId: hostingPlan.id
reserved: true
isXenon: false
hyperV: false
dnsConfiguration: {}
vnetRouteAllEnabled: false
vnetImagePullEnabled: false
vnetContentShareEnabled: false
siteConfig: {
numberOfWorkers: 1
linuxFxVersion: 'DOTNETCORE|8.0'
acrUseManagedIdentityCreds: false
alwaysOn: false
http20Enabled: false
functionAppScaleLimit: 0
minimumElasticInstanceCount: 1
}
scmSiteAlsoStopped: false
clientAffinityEnabled: true
clientCertEnabled: false
clientCertMode: 'Required'
hostNamesDisabled: false
vnetBackupRestoreEnabled: false
customDomainVerificationId: '2F999EC75A4CD61B5FED9FB0E622419CB390238BE602CC038B2E1F3F7DA3F9C7'
containerSize: 0
dailyMemoryTimeQuota: 0
httpsOnly: true
redundancyMode: 'None'
publicNetworkAccess: 'Enabled'
storageAccountRequired: false
keyVaultReferenceIdentity: userAssignedIdentity.id
}
}
resource sites_revittoifcapp_name_ftp 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2023-12-01' = {
parent: sites_revittoifcapp_api
name: 'ftp'
properties: {
allow: false
}
}
resource sites_revittoifcapp_name_scm 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2023-12-01' = {
parent: sites_revittoifcapp_api
name: 'scm'
properties: {
allow: false
}
}
resource sites_revittoifcapp_name_static_site 'Microsoft.Web/staticSites@2022-09-01' = {
name: staticSiteName
location: 'westeurope'
sku:{
name: 'Free'
tier: 'Free'
}
properties: {
allowConfigFileUpdates: true
stagingEnvironmentPolicy:'Enabled'
provider: 'None'
enterpriseGradeCdnStatus:'Disabled'
}
}
var staticWebSiteUrl = sites_revittoifcapp_name_static_site.properties.defaultHostname
resource sites_revittoifcapp_name_web 'Microsoft.Web/sites/config@2023-12-01' = {
parent: sites_revittoifcapp_api
name: 'web'
properties: {
cors: {
allowedOrigins: ['http://localhost','https://${staticWebSiteUrl}']
}
appSettings: [
{
name: 'ManagedIdentityClientId'
value: userAssignedIdentity.properties.clientId
}
{
name: 'KeyVaultName'
value: keyVaultName
}
{
name: 'StorageAccountName'
value: storageAccountName
}
]
numberOfWorkers: 1
linuxFxVersion: 'DOTNETCORE|8.0'
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
'hostingstart.html'
]
requestTracingEnabled: false
remoteDebuggingEnabled: false
remoteDebuggingVersion: 'VS2022'
httpLoggingEnabled: false
acrUseManagedIdentityCreds: false
logsDirectorySizeLimit: 35
detailedErrorLoggingEnabled: false
publishingUsername: 'REDACTED'
scmType: 'None'
use32BitWorkerProcess: true
webSocketsEnabled: false
alwaysOn: false
appCommandLine: 'dotnet WebApp.dll'
managedPipelineMode: 'Integrated'
virtualApplications: [
{
virtualPath: '/'
physicalPath: 'site\\wwwroot'
preloadEnabled: false
}
]
loadBalancing: 'LeastRequests'
experiments: {
rampUpRules: []
}
autoHealEnabled: false
vnetRouteAllEnabled: false
vnetPrivatePortsCount: 0
publicNetworkAccess: 'Enabled'
localMySqlEnabled: false
managedServiceIdentityId: 6577
ipSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 2147483647
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 2147483647
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictionsUseMain: false
http20Enabled: false
minTlsVersion: '1.2'
scmMinTlsVersion: '1.2'
ftpsState: 'FtpsOnly'
preWarmedInstanceCount: 0
elasticWebAppScaleLimit: 0
functionsRuntimeScaleMonitoringEnabled: false
minimumElasticInstanceCount: 1
azureStorageAccounts: {}
}
}
@description('The total amount of cost or usage to track with the budget')
param amount int = 15
@description('The time covered by a budget. Tracking of the amount will be reset based on the time grain.')
@allowed([
'Monthly'
'Quarterly'
'Annually'
])
param timeGrain string = 'Monthly'
param startDate string = utcNow('2024-10-01')
var firstThreshold = 90
var secondThreshold = 110
var contactEmails = ['simon@bim42.com']
resource budget 'Microsoft.Consumption/budgets@2023-11-01' = {
name: budgetName
properties: {
timePeriod: {
startDate: startDate
}
timeGrain: timeGrain
amount: amount
category: 'Cost'
notifications: {
NotificationForExceededBudget1: {
enabled: true
operator: 'GreaterThan'
threshold: firstThreshold
contactEmails: contactEmails
}
NotificationForExceededBudget2: {
enabled: true
operator: 'GreaterThan'
threshold: secondThreshold
contactEmails: contactEmails
}
}
}
}
resource StorageTableDataContributorRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(subscription().id, 'bicep-roleassignments', 'StorageTableDataContributor')
scope: storageAccount
properties: {
principalId: userAssignedIdentity.properties.principalId
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')
principalType:'ServicePrincipal'
}
}
resource WebsiteContributorRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(subscription().id, 'bicep-roleassignments', 'WebsiteContributor')
scope: sites_revittoifcapp_api
properties: {
principalId: userAssignedIdentity.properties.principalId
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', 'de139f84-1756-47ae-9be6-808fbbe84772')
principalType:'ServicePrincipal'
}
}
resource KeyVaultSecretsUserRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(subscription().id, 'bicep-roleassignments', 'KeyVaultSecretsUser')
scope: vault
properties: {
principalId: userAssignedIdentity.properties.principalId
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', '4633458b-17de-408a-b874-0445c86b69e6')
principalType:'ServicePrincipal'
}
}
output AZUREAPPSERVICE_CLIENTID string = userAssignedIdentity.properties.clientId