-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppServiceDataApiBuilder.bicep
225 lines (214 loc) · 4.7 KB
/
AppServiceDataApiBuilder.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
param appName string = ''
param location string = ''
param containerImage string = 'mcr.microsoft.com/azure-databases/data-api-builder:latest'
@secure()
param adminPassword string = ''
param storageAccountName string = ''
param publicIP string = ''
var appServicePlanName = '${appName}-plan'
var vnetName = '${appName}-vnet'
var subnetName = 'default'
var subnetId = resourceId('Microsoft.Network/virtualNetworks/subnets', vnetName, subnetName)
//
// App Service Plan
//
resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: appServicePlanName
location: location
sku: {
name: 'S1'
tier: 'Standard'
}
kind: 'linux'
properties: {
reserved: true
}
}
//
// Virtual Network
//
resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: vnetName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: '10.0.0.0/24'
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
{
service: 'Microsoft.Sql'
}
{
service: 'Microsoft.Web'
}
]
delegations: [
{
name: 'appServiceDelegation'
properties: {
serviceName: 'Microsoft.Web/serverFarms'
}
}
]
}
}
]
}
}
//
// Storage Account
//
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
networkAcls: {
defaultAction: 'Deny'
ipRules: [
{
value: publicIP
action: 'Allow'
}
]
virtualNetworkRules: [
{
id: subnetId
action: 'Allow'
}
]
}
}
dependsOn: [
vnet
]
}
//
// Blob Service and Container
//
resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2021-08-01' existing = {
parent: storageAccount
name: 'default'
}
resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-08-01' = {
parent: blobService
name: 'default'
properties: {
publicAccess: 'None'
}
dependsOn: [
storageAccount
]
}
//
// Web App
//
resource webApp 'Microsoft.Web/sites@2021-03-01' = {
name: appName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: appServicePlan.id
virtualNetworkSubnetId: subnetId
siteConfig: {
appSettings: [
{
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
value: 'false'
}
{
name: 'DOCKER_REGISTRY_SERVER_URL'
value: 'https://index.docker.io'
}
{
name: 'SQL_CONN_STRING'
value: 'Server=tcp:sqlserver-${appName}.database.windows.net,1433;User Id=sqladmin;Database=db-${appName};Password=${adminPassword};Trusted_Connection=False;Encrypt=Optional;'
}
{
name: 'ConfigFileName'
value: '/App/configs/dab-config.json'
}
{
name: 'WEBSITES_PORT'
value: '5000'
}
]
linuxFxVersion: 'DOCKER|${containerImage}'
logsDirectorySizeLimit: 35
detailedErrorLoggingEnabled: true
httpLoggingEnabled: true
requestTracingEnabled: true
ftpsState: 'FtpsOnly'
}
}
dependsOn: [
sqlServer
storageAccount
appServicePlan
vnet
]
}
resource webAppConfig 'Microsoft.Web/sites/config@2021-03-01' = {
parent: webApp
name: 'azurestorageaccounts'
properties: {
config: {
accountName: storageAccount.name
shareName: blobContainer.name
accessKey: storageAccount.listKeys().keys[0].value
mountPath: '/App/configs'
type: 'AzureBlob'
}
}
}
//
// SQL Server Module
//
module sqlServer 'br/public:avm/res/sql/server:0.6.0' = {
name: 'sql-${appName}'
params: {
name: 'sqlserver-${appName}'
administratorLogin: 'sqladmin'
administratorLoginPassword: adminPassword
location: location
restrictOutboundNetworkAccess: 'Disabled'
firewallRules: [
{
name: 'AllowPublicIP'
startIpAddress: publicIP
endIpAddress: publicIP
}
]
virtualNetworkRules: [
{
name: 'sql-${appName}'
virtualNetworkSubnetId: subnetId
ignoreMissingVnetServiceEndpoint: false
}
]
databases: [
{
name: 'db-${appName}'
skuName: 'S0'
skuTier: 'Standard'
maxSizeBytes: 268435456000
zoneRedundant: false
}
]
}
}