Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created February 24, 2021 03:24
Show Gist options
  • Save PlagueHO/c10308beae322f28e422942225d81266 to your computer and use it in GitHub Desktop.
Save PlagueHO/c10308beae322f28e422942225d81266 to your computer and use it in GitHub Desktop.
ARM Template for Deploying Azure Database for PostgreSQL with read-only replica and no public network access.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "string",
"metadata": {
"description": "Server Name for Azure database for PostgreSQL"
}
},
"administratorLogin": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Database administrator login name"
}
},
"administratorLoginPassword": {
"type": "securestring",
"minLength": 8,
"metadata": {
"description": "Database administrator password"
}
},
"skuCapacity": {
"type": "int",
"defaultValue": 2,
"metadata": {
"description": "Azure database for PostgreSQL compute capacity in vCores (2,4,8,16,32)"
}
},
"skuName": {
"type": "string",
"defaultValue": "GP_Gen5_2",
"metadata": {
"description": "Azure database for PostgreSQL sku name "
}
},
"skuSizeMB": {
"type": "int",
"defaultValue": 51200,
"metadata": {
"description": "Azure database for PostgreSQL Sku Size "
}
},
"skuTier": {
"type": "string",
"defaultValue": "GeneralPurpose",
"metadata": {
"description": "Azure database for PostgreSQL pricing tier"
}
},
"skuFamily": {
"type": "string",
"defaultValue": "Gen5",
"metadata": {
"description": "Azure database for PostgreSQL sku family"
}
},
"postgresqlVersion": {
"type": "string",
"defaultValue": "11",
"allowedValues": [
"9.5",
"9.6",
"10",
"11"
],
"metadata": {
"description": "PostgreSQL version"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for primary database."
}
},
"locationReplica": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for replica database."
}
},
"backupRetentionDays": {
"type": "int",
"defaultValue": 7,
"metadata": {
"description": "PostgreSQL Server backup retention days"
}
},
"geoRedundantBackup": {
"type": "string",
"defaultValue": "Disabled",
"metadata": {
"description": "Geo-Redundant Backup setting"
}
}
},
"variables": {
},
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name": "[concat(parameters('serverName'),'-primary')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('skuName')]",
"tier": "[parameters('skuTier')]",
"capacity": "[parameters('skuCapacity')]",
"size": "[parameters('skuSizeMB')]",
"family": "[parameters('skuFamily')]"
},
"properties": {
"createMode": "Default",
"version": "[parameters('postgresqlVersion')]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"publicNetworkAccess": "Disabled",
"storageProfile": {
"storageMB": "[parameters('skuSizeMB')]",
"backupRetentionDays": "[parameters('backupRetentionDays')]",
"geoRedundantBackup": "[parameters('geoRedundantBackup')]"
}
}
},
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name": "[concat(parameters('serverName'),'-replica')]",
"location": "[parameters('locationReplica')]",
"sku": {
"name": "[parameters('skuName')]",
"tier": "[parameters('skuTier')]",
"capacity": "[parameters('skuCapacity')]",
"size": "[parameters('skuSizeMB')]",
"family": "[parameters('skuFamily')]"
},
"properties": {
"createMode": "Replica",
"sourceServerId": "[resourceId('Microsoft.DBforPostgreSQL/servers',concat(parameters('serverName'),'-primary'))]",
"publicNetworkAccess": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.DBforPostgreSQL/servers',concat(parameters('serverName'),'-primary'))]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment