/
webapp.bicep
83 lines (74 loc) · 2.17 KB
/
webapp.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
param location string = resourceGroup().location
param frontendWebAppName string
param storageAccountUrl string
param webappSku string = 'S1'
var urlStoreGrainAppsettings = {
name: 'UrlStoreGrain:ServiceUrl'
value: storageAccountUrl
}
resource frontendAppServicePlan 'Microsoft.Web/serverfarms@2020-12-01' = {
name: 'urlshortener-frontend-app-plan'
location: location
sku: {
name: webappSku
capacity: 1
}
}
resource frontend 'Microsoft.Web/sites@2018-11-01' = {
name: frontendWebAppName
location: location
tags: {
'hidden-related:${resourceGroup().id}/providers/Microsoft.Web/serverfarms/appServicePlan': 'Resource'
}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentity.id}': {}
}
}
properties: {
serverFarmId: frontendAppServicePlan.id
siteConfig: {
netFrameworkVersion: 'v6.0'
}
}
}
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' = {
name: frontendWebAppName
location: location
}
resource frontendAppSetting 'Microsoft.Web/sites/config@2022-03-01' = {
name: 'web'
parent: frontend
properties: {
appSettings: [
{
name: 'APPINSIGHTS_CONNECTION_STRING'
value: frontendAppInsight.properties.ConnectionString
}
{
name: 'UrlStoreGrain:ManagedIdentityClientId'
value: managedIdentity.properties.clientId
}
(!empty(storageAccountUrl)) ? urlStoreGrainAppsettings : {}
]
}
}
resource webappMetaData 'Microsoft.Web/sites/config@2021-03-01' = {
name: 'metadata'
kind: 'string'
parent: frontend
properties: {
// Trick to enable use .NET Core or .NET 5+ : https://www.coderperfect.com/how-to-configure-runtime-stack-to-azure-app-service-with-bicep-bicep-version-0-4/
CURRENT_STACK: 'dotnetcore'
}
}
resource frontendAppInsight 'Microsoft.Insights/components@2020-02-02-preview' = {
name: 'urlshortener-frontend-app-insight'
location: location
kind: 'web'
properties: {
Application_Type: 'web'
}
}
output webAppManagedIdentity string = managedIdentity.properties.principalId