File size: 4,844 Bytes
80db45a f28be2b 80db45a |
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 |
param name string
param location string
param resourceToken string
@secure()
param databasePassword string
param tags object
var prefix = '${name}-${resourceToken}'
var pgServerName = '${prefix}-postgres-server'
var databaseSubnetName = 'database-subnet'
var webappSubnetName = 'webapp-subnet'
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
name: '${prefix}-vnet'
location: location
tags: tags
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: databaseSubnetName
properties: {
addressPrefix: '10.0.0.0/24'
delegations: [
{
name: '${prefix}-subnet-delegation'
properties: {
serviceName: 'Microsoft.DBforPostgreSQL/flexibleServers'
}
}
]
}
}
{
name: webappSubnetName
properties: {
addressPrefix: '10.0.1.0/24'
delegations: [
{
name: '${prefix}-subnet-delegation-web'
properties: {
serviceName: 'Microsoft.Web/serverFarms'
}
}
]
}
}
]
}
resource databaseSubnet 'subnets' existing = {
name: databaseSubnetName
}
resource webappSubnet 'subnets' existing = {
name: webappSubnetName
}
}
resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
name: '${pgServerName}.private.postgres.database.azure.com'
location: 'global'
tags: tags
dependsOn: [
virtualNetwork
]
}
resource privateDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
parent: privateDnsZone
name: '${pgServerName}-link'
location: 'global'
properties: {
registrationEnabled: false
virtualNetwork: {
id: virtualNetwork.id
}
}
}
resource web 'Microsoft.Web/sites@2022-03-01' = {
name: '${prefix}-app-service'
location: location
tags: union(tags, { 'azd-service-name': 'web' })
kind: 'app,linux'
properties: {
serverFarmId: appServicePlan.id
siteConfig: {
alwaysOn: true
linuxFxVersion: 'PYTHON|3.10'
ftpsState: 'Disabled'
appCommandLine: 'python manage.py migrate'
}
httpsOnly: true
}
identity: {
type: 'SystemAssigned'
}
resource appSettings 'config' = {
name: 'appsettings'
properties: {
DBHOST: postgresServer.name
DBNAME: djangoDatabase.name
DBUSER: postgresServer.properties.administratorLogin
DBPASS: databasePassword
SCM_DO_BUILD_DURING_DEPLOYMENT: 'true'
}
}
resource logs 'config' = {
name: 'logs'
properties: {
applicationLogs: {
fileSystem: {
level: 'Verbose'
}
}
detailedErrorMessages: {
enabled: true
}
failedRequestsTracing: {
enabled: true
}
httpLogs: {
fileSystem: {
enabled: true
retentionInDays: 1
retentionInMb: 35
}
}
}
}
resource webappVnetConfig 'networkConfig' = {
name: 'virtualNetwork'
properties: {
subnetResourceId: virtualNetwork::webappSubnet.id
}
}
dependsOn: [virtualNetwork]
}
resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: '${prefix}-service-plan'
location: location
tags: tags
sku: {
name: 'B1'
}
properties: {
reserved: true
}
}
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
name: '${prefix}-workspace'
location: location
tags: tags
properties: any({
retentionInDays: 30
features: {
searchVersion: 1
}
sku: {
name: 'PerGB2018'
}
})
}
resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2022-01-20-preview' = {
location: location
tags: tags
name: pgServerName
sku: {
name: 'Standard_D2ds_v4'
tier: 'GeneralPurpose'
}
properties: {
version: '13'
administratorLogin: 'django'
administratorLoginPassword: databasePassword
availabilityZone: '1'
storage: {
storageSizeGB: 128
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
network: {
delegatedSubnetResourceId: virtualNetwork::databaseSubnet.id
privateDnsZoneArmResourceId: privateDnsZone.id
}
highAvailability: {
mode: 'Disabled'
}
maintenanceWindow: {
customWindow: 'Disabled'
dayOfWeek: 0
startHour: 0
startMinute: 0
}
}
dependsOn: [
privateDnsZoneLink
]
}
resource djangoDatabase 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2022-01-20-preview' = {
parent: postgresServer
name: 'django'
}
output WEB_URI string = 'https://${web.properties.defaultHostName}'
|