Skip to content

Commit dc617f5

Browse files
committed
Synchronize repo from Repoman
1 parent 3905c94 commit dc617f5

File tree

6 files changed

+786
-439
lines changed

6 files changed

+786
-439
lines changed

infra/app/api-appservice-avm.bicep

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
param name string
2+
param location string = resourceGroup().location
3+
param tags object = {}
4+
5+
param allowedOrigins array = []
6+
param appCommandLine string?
7+
param appInsightResourceId string
8+
param appServicePlanId string
9+
@secure()
10+
param appSettings object = {}
11+
param siteConfig object = {}
12+
param serviceName string = 'api'
13+
14+
@description('Required. Type of site to deploy.')
15+
param kind string
16+
17+
@description('Optional. If client affinity is enabled.')
18+
param clientAffinityEnabled bool = true
19+
20+
@description('Optional. Required if app of kind functionapp. Resource ID of the storage account to manage triggers and logging function executions.')
21+
param storageAccountResourceId string?
22+
23+
module api 'br/public:avm/res/web/site:0.6.0' = {
24+
name: '${name}-app-module'
25+
params: {
26+
kind: kind
27+
name: name
28+
serverFarmResourceId: appServicePlanId
29+
tags: union(tags, { 'azd-service-name': serviceName })
30+
location: location
31+
appInsightResourceId: appInsightResourceId
32+
clientAffinityEnabled: clientAffinityEnabled
33+
storageAccountResourceId: storageAccountResourceId
34+
managedIdentities: {
35+
systemAssigned: true
36+
}
37+
siteConfig: union(siteConfig, {
38+
cors: {
39+
allowedOrigins: union(['https://portal.azure.com', 'https://ms.portal.azure.com'], allowedOrigins)
40+
}
41+
appCommandLine: appCommandLine
42+
})
43+
appSettingsKeyValuePairs: union(
44+
appSettings,
45+
{ ENABLE_ORYX_BUILD: true, ApplicationInsightsAgent_EXTENSION_VERSION: contains(kind, 'linux') ? '~3' : '~2' }
46+
)
47+
logsConfiguration: {
48+
applicationLogs: { fileSystem: { level: 'Verbose' } }
49+
detailedErrorMessages: { enabled: true }
50+
failedRequestsTracing: { enabled: true }
51+
httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
52+
}
53+
}
54+
}
55+
56+
output SERVICE_API_IDENTITY_PRINCIPAL_ID string = api.outputs.systemAssignedMIPrincipalId
57+
output SERVICE_API_NAME string = api.outputs.name
58+
output SERVICE_API_URI string = 'https://${api.outputs.defaultHostname}'

infra/app/db-avm.bicep

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
param location string = resourceGroup().location
2+
3+
@description('Application user name')
4+
param appUser string
5+
6+
@description('SQL Server administrator name')
7+
param sqlAdmin string = 'sqlAdmin'
8+
9+
@description('The name for sql database ')
10+
param sqlDatabaseName string = ''
11+
12+
@description('Resource name for sql service')
13+
param sqlServiceName string
14+
15+
@secure()
16+
@description('SQL Server administrator password')
17+
param sqlAdminPassword string
18+
19+
@secure()
20+
@description('Application user password')
21+
param appUserPassword string
22+
23+
param tags object = {}
24+
25+
var defaultDatabaseName = 'Todo'
26+
var actualDatabaseName = !empty(sqlDatabaseName) ? sqlDatabaseName : defaultDatabaseName
27+
28+
module sqlServer 'br/public:avm/res/sql/server:0.2.0' = {
29+
name: 'sqlservice'
30+
params: {
31+
name: sqlServiceName
32+
administratorLogin: sqlAdmin
33+
administratorLoginPassword: sqlAdminPassword
34+
location: location
35+
tags: tags
36+
publicNetworkAccess: 'Enabled'
37+
databases: [
38+
{
39+
name: actualDatabaseName
40+
}
41+
]
42+
firewallRules: [
43+
{
44+
name: 'Azure Services'
45+
startIpAddress: '0.0.0.1'
46+
endIpAddress: '255.255.255.254'
47+
}
48+
]
49+
}
50+
}
51+
52+
module deploymentScript 'br/public:avm/res/resources/deployment-script:0.1.3' = {
53+
name: 'deployment-script'
54+
params: {
55+
kind: 'AzureCLI'
56+
name: 'deployment-script'
57+
azCliVersion: '2.37.0'
58+
location: location
59+
retentionInterval: 'PT1H'
60+
timeout: 'PT5M'
61+
cleanupPreference: 'OnSuccess'
62+
environmentVariables:{
63+
secureList: [
64+
{
65+
name: 'APPUSERNAME'
66+
value: appUser
67+
}
68+
{
69+
name: 'APPUSERPASSWORD'
70+
secureValue: appUserPassword
71+
}
72+
{
73+
name: 'DBNAME'
74+
value: actualDatabaseName
75+
}
76+
{
77+
name: 'DBSERVER'
78+
value: '${sqlServer.outputs.name}${environment().suffixes.sqlServerHostname}'
79+
}
80+
{
81+
name: 'SQLCMDPASSWORD'
82+
secureValue: sqlAdminPassword
83+
}
84+
{
85+
name: 'SQLADMIN'
86+
value: sqlAdmin
87+
}
88+
]
89+
}
90+
scriptContent: '''
91+
wget https://github.com/microsoft/go-sqlcmd/releases/download/v0.8.1/sqlcmd-v0.8.1-linux-x64.tar.bz2
92+
tar x -f sqlcmd-v0.8.1-linux-x64.tar.bz2 -C .
93+
94+
cat <<SCRIPT_END > ./initDb.sql
95+
drop user if exists ${APPUSERNAME}
96+
go
97+
create user ${APPUSERNAME} with password = '${APPUSERPASSWORD}'
98+
go
99+
alter role db_owner add member ${APPUSERNAME}
100+
go
101+
SCRIPT_END
102+
103+
./sqlcmd -S ${DBSERVER} -d ${DBNAME} -U ${SQLADMIN} -i ./initDb.sql
104+
'''
105+
}
106+
}
107+
108+
output databaseName string = actualDatabaseName
109+
output sqlServerName string = sqlServer.outputs.name

infra/app/web-appservice-avm.bicep

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
param name string
2+
param location string = resourceGroup().location
3+
param tags object = {}
4+
param serviceName string = 'web'
5+
param appCommandLine string = 'pm2 serve /home/site/wwwroot --no-daemon --spa'
6+
param appInsightResourceId string
7+
param appServicePlanId string
8+
param linuxFxVersion string
9+
param kind string = 'app,linux'
10+
11+
module web 'br/public:avm/res/web/site:0.6.0' = {
12+
name: '${name}-deployment'
13+
params: {
14+
kind: kind
15+
name: name
16+
serverFarmResourceId: appServicePlanId
17+
tags: union(tags, { 'azd-service-name': serviceName })
18+
location: location
19+
appInsightResourceId: appInsightResourceId
20+
siteConfig: {
21+
appCommandLine: appCommandLine
22+
linuxFxVersion: linuxFxVersion
23+
alwaysOn: true
24+
}
25+
logsConfiguration: {
26+
applicationLogs: { fileSystem: { level: 'Verbose' } }
27+
detailedErrorMessages: { enabled: true }
28+
failedRequestsTracing: { enabled: true }
29+
httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
30+
}
31+
appSettingsKeyValuePairs: { ApplicationInsightsAgent_EXTENSION_VERSION: contains(kind, 'linux') ? '~3' : '~2' }
32+
}
33+
}
34+
35+
output SERVICE_WEB_IDENTITY_PRINCIPAL_ID string = web.outputs.systemAssignedMIPrincipalId
36+
output SERVICE_WEB_NAME string = web.outputs.name
37+
output SERVICE_WEB_URI string = 'https://${web.outputs.defaultHostname}'

0 commit comments

Comments
 (0)