2018-11-14 13:13:15 +03:00
{
"$schema" : "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" ,
"contentVersion" : "1.0.0.0" ,
"parameters" : {
"name" : {
"defaultValue" : null ,
"type" : "string" ,
"minLength" : 5 ,
"maxLength" : 63 ,
"metadata" : {
2019-01-16 08:10:37 +03:00
"description" : "Unique name for the deployment, used for Postgres Server, Hasura and DNS label."
2018-11-14 13:13:15 +03:00
}
} ,
"postgresVersion" : {
"type" : "string" ,
"defaultValue" : "10" ,
"allowedValues" : [
"10" ,
"9.6" ,
"9.5"
] ,
"metadata" : {
"description" : "Version of PostgreSQL Server to be provisioned."
}
} ,
2019-01-16 08:10:37 +03:00
"postgresPricingTier" : {
2018-11-14 13:13:15 +03:00
"type" : "string" ,
"allowedValues" : [
"Basic" ,
"GeneralPurpose" ,
"MemoryOptimized"
] ,
"defaultValue" : "GeneralPurpose" ,
"metadata" : {
2019-01-16 08:10:37 +03:00
"description" : "Azure database for PostgreSQL pricing tier."
2018-11-14 13:13:15 +03:00
}
} ,
2019-01-16 08:10:37 +03:00
"postgresCPUCores" : {
2018-11-14 13:13:15 +03:00
"type" : "int" ,
"allowedValues" : [
2 ,
4 ,
8 ,
16 ,
32
] ,
"defaultValue" : 2 ,
"metadata" : {
"description" : "Azure database for PostgreSQL SKU capacity - number of cores."
}
} ,
2019-01-16 08:10:37 +03:00
"postgresDiskSizeInMB" : {
2018-11-14 13:13:15 +03:00
"type" : "int" ,
2019-04-02 05:18:56 +03:00
"minValue" : 5120 ,
"maxValue" : 4194304 ,
2018-11-14 13:13:15 +03:00
"defaultValue" : 10240 ,
"metadata" : {
"description" : "Azure database for PostgreSQL SKU storage size."
}
} ,
2019-01-16 08:10:37 +03:00
"postgresAdminUsername" : {
"type" : "string" ,
"defaultValue" : "hasura" ,
"minLength" : 4 ,
"maxLength" : 128 ,
"metadata" : {
"description" : "Administrator username for Postgres."
}
} ,
"postgresAdminPassword" : {
2018-11-14 13:13:15 +03:00
"type" : "securestring" ,
"defaultValue" : null ,
"minLength" : 8 ,
"maxLength" : 128 ,
"metadata" : {
"description" : "Administrator password for Postgres. Must be at least 8 characters in length, must contain characters from three of the following categories – English uppercase letters, English lowercase letters, numbers (0-9), and non-alphanumeric characters (!, $, #, %, etc.)."
}
} ,
2019-01-16 08:10:37 +03:00
"postgresDatabaseName" : {
"type" : "string" ,
"defaultValue" : "hasura" ,
"minLength" : 4 ,
2018-11-14 13:13:15 +03:00
"maxLength" : 128 ,
"metadata" : {
2019-01-16 08:10:37 +03:00
"description" : "Name of the database to be created."
2018-11-14 13:13:15 +03:00
}
}
} ,
"variables" : {
"serverName" : "[concat(parameters('name'), '-pg-server')]" ,
2019-01-16 08:10:37 +03:00
"adminUser" : "[parameters('postgresAdminUsername')]" ,
"adminPassword" : "[parameters('postgresAdminPassword')]" ,
"dbName" : "[parameters('postgresDatabaseName')]" ,
"dbSKUTier" : "[parameters('postgresPricingTier')]" ,
"dbSKUCapacity" : "[parameters('postgresCPUCores')]" ,
"dbSKUSizeInMB" : "[parameters('postgresDiskSizeInMB')]" ,
2018-11-14 13:13:15 +03:00
"firewallRuleName" : "allow-all-azure-firewall-rule" ,
"containerGroupName" : "[concat(parameters('name'), '-container-group')]" ,
"containerName" : "hasura-graphql-engine" ,
2019-12-02 10:32:46 +03:00
"containerImage" : "hasura/graphql-engine:v1.0.0-rc.1"
2018-11-14 13:13:15 +03:00
} ,
"resources" : [
{
"name" : "[variables('serverName')]" ,
"location" : "[resourceGroup().location]" ,
"type" : "Microsoft.DBforPostgreSQL/servers" ,
"apiVersion" : "2017-12-01" ,
"properties" : {
"createMode" : "Default" ,
"version" : "[parameters('postgresVersion')]" ,
2019-01-16 12:19:31 +03:00
"administratorLogin" : "[variables('adminUser')]" ,
2019-01-16 08:10:37 +03:00
"administratorLoginPassword" : "[variables('adminPassword')]" ,
2018-11-14 13:13:15 +03:00
"storageProfile" : {
2019-01-16 08:10:37 +03:00
"storageMB" : "[variables('dbSKUSizeInMB')]"
2018-11-14 13:13:15 +03:00
}
} ,
"sku" : {
2019-01-16 08:10:37 +03:00
"name" : "[concat(if(equals(variables('dbSKUTier'), 'Basic'), 'B', if(equals(variables('dbSKUTier'), 'GeneralPurpose'), 'GP', if(equals(variables('dbSKUTier'), 'MemoryOptimized'), 'MO', 'X'))), '_Gen5_', variables('dbSKUCapacity') )]" ,
"tier" : "[variables('dbSKUTier')]" ,
"capacity" : "[variables('dbSKUCapacity')]" ,
"size" : "[variables('dbSKUSizeInMB')]" ,
2018-11-14 13:13:15 +03:00
"family" : "Gen5"
} ,
"resources" : [
{
"name" : "[variables('dbName')]" ,
"type" : "databases" ,
"apiVersion" : "2017-12-01" ,
"properties" : {
"charset" : "UTF8" ,
"collation" : "English_United States.1252"
} ,
"dependsOn" : [
"[resourceId('Microsoft.DBforPostgreSQL/servers', variables('serverName'))]"
]
} ,
{
"type" : "firewallRules" ,
"name" : "[variables('firewallRuleName')]" ,
"apiVersion" : "2017-12-01" ,
"properties" : {
"startIpAddress" : "0.0.0.0" ,
"endIpAddress" : "0.0.0.0"
} ,
"dependsOn" : [
"[resourceId('Microsoft.DBforPostgreSQL/servers', variables('serverName'))]"
]
}
]
} ,
{
"type" : "Microsoft.ContainerInstance/containerGroups" ,
"name" : "[variables('containerGroupName')]" ,
2019-01-16 08:10:37 +03:00
"apiVersion" : "2018-10-01" ,
2018-11-14 13:13:15 +03:00
"location" : "[resourceGroup().location]" ,
"properties" : {
"containers" : [
{
"name" : "[variables('containerName')]" ,
"properties" : {
"image" : "[variables('containerImage')]" ,
"ports" : [
{
"protocol" : "TCP" ,
"port" : 80
}
] ,
2019-01-16 08:10:37 +03:00
"command" : [
"graphql-engine" ,
"--host" ,
"[reference(resourceId('Microsoft.DBforPostgreSQL/servers', variables('serverName'))).fullyQualifiedDomainName]" ,
"--port" ,
"5432" ,
"--user" ,
"[concat(variables('adminUser'), '@', variables('serverName'))]" ,
"--password" ,
"[variables('adminPassword')]" ,
"--dbname" ,
"[variables('dbName')]" ,
"serve" ,
"--server-port" ,
"80" ,
"--enable-console"
2018-11-14 13:13:15 +03:00
] ,
"resources" : {
"requests" : {
"memoryInGB" : 1 ,
"cpu" : 1
}
}
}
}
] ,
"restartPolicy" : "Always" ,
"ipAddress" : {
"ports" : [
{
"protocol" : "TCP" ,
"port" : 80
}
] ,
"type" : "Public" ,
"dnsNameLabel" : "[parameters('name')]"
} ,
"osType" : "Linux"
} ,
"dependsOn" : [
"[resourceId('Microsoft.DBforPostgreSQL/servers', variables('serverName'))]"
]
}
] ,
"outputs" : {
"fqdn" : {
"value" : "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', variables('containerGroupName'))).ipAddress.fqdn]" ,
"type" : "string"
} ,
"ipaddress" : {
"value" : "[reference(resourceId('Microsoft.ContainerInstance/containerGroups', variables('containerGroupName'))).ipAddress.ip]" ,
"type" : "string"
}
}
}