param name string | |
param location string = resourceGroup().location | |
param tags object = {} | |
param postgresServerName string | |
var databaseSubnetName = 'database-subnet' | |
var webappSubnetName = 'webapp-subnet' | |
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = { | |
name: name | |
location: location | |
tags: tags | |
properties: { | |
addressSpace: { | |
addressPrefixes: [ | |
'10.0.0.0/16' | |
] | |
} | |
subnets: [ | |
{ | |
name: databaseSubnetName | |
properties: { | |
addressPrefix: '10.0.0.0/24' | |
delegations: [ | |
{ | |
name: '${name}-subnet-db' | |
properties: { | |
serviceName: 'Microsoft.DBforPostgreSQL/flexibleServers' | |
} | |
} | |
] | |
} | |
} | |
{ | |
name: webappSubnetName | |
properties: { | |
addressPrefix: '10.0.1.0/24' | |
delegations: [ | |
{ | |
name: '${name}-subnet-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: '${postgresServerName}.private.postgres.database.azure.com' | |
location: 'global' | |
tags: tags | |
dependsOn: [ | |
virtualNetwork | |
] | |
} | |
resource privateDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = { | |
parent: privateDnsZone | |
name: '${name}-link' | |
location: 'global' | |
properties: { | |
registrationEnabled: false | |
virtualNetwork: { | |
id: virtualNetwork.id | |
} | |
} | |
} | |
output databaseSubnetId string = virtualNetwork::databaseSubnet.id | |
output webSubnetId string = virtualNetwork::webappSubnet.id | |
output privateDnsZoneId string = privateDnsZone.id | |
output privateDnsZoneLink object = privateDnsZoneLink | |