-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathpostgres.bicep
45 lines (41 loc) · 1.24 KB
/
postgres.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
param administratorLogin string = 'username'
@secure()
param administratorLoginPassword string = newGuid()
param firewallRuleIp string = '127.0.0.1'
param storageSizeGb int = 256
param location string = resourceGroup().location
var rand = substring(uniqueString(resourceGroup().id), 0, 6)
var postgresName = 'postgres-${rand}'
resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = {
name: postgresName
location: location
sku: {
name: 'Standard_B2s'
tier: 'Burstable'
}
properties: {
version: '13'
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
storage: {
storageSizeGB: storageSizeGb
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
highAvailability: {
mode: 'Disabled'
}
}
}
resource postgresFirewallRule 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2021-06-01' = {
parent: postgres
name: 'DefaultAllowRule'
properties: {
endIpAddress: firewallRuleIp
startIpAddress: firewallRuleIp
}
}
output postgresName string = postgresName
output postgresUrl string = 'postgres://${administratorLogin}:$PGPASSWORD@${postgresName}.postgres.database.azure.com/postgres?sslmode=require'