Last active
November 5, 2019 13:05
-
-
Save timabell/ad51ef7ab1525ad2c4d929f427c535df to your computer and use it in GitHub Desktop.
schema explorer ARM deploy based on https://github.com/DFE-Digital/manage-courses-backend/blob/master/azure/template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"resourceEnvironmentName": { | |
"value": "" | |
}, | |
"customHostName": { | |
"value": "" | |
}, | |
"serviceName": { | |
"value": "schema-explorer-test" | |
}, | |
"displayName": { | |
"value": "Publish QA (test)" | |
}, | |
"databaseServerHostName": { | |
"value": "" | |
}, | |
"databaseName": { | |
"value": "" | |
}, | |
"databaseUsername": { | |
"value": "" | |
}, | |
"databasePassword": { | |
"value": "" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"resourceEnvironmentName": { | |
"type": "string", | |
"metadata": { | |
"description": "The prefix and environment of the resource." | |
} | |
}, | |
"serviceName": { | |
"type": "string", | |
"metadata": { | |
"description": "The abbreviation of the service name to be used when naming a resource." | |
} | |
}, | |
"keyVaultName": { | |
"type": "string", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The name of the key vault." | |
} | |
}, | |
"keyVaultResourceGroup": { | |
"type": "string", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The resource group for the key vault." | |
} | |
}, | |
"customHostName": { | |
"type": "string", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The custom hostname to add to the app service." | |
} | |
}, | |
"certificateName": { | |
"type": "string", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The name of the certificate in key vault." | |
} | |
}, | |
"databaseName": { | |
"type": "string", | |
"metadata": { | |
"description": "The name of the database that the app will connect to." | |
} | |
}, | |
"databaseServerHostName": { | |
"type": "string", | |
"metadata": { | |
"description": "The fqdn of the psql server hosting the database." | |
} | |
}, | |
"databasePort": { | |
"type": "string", | |
"defaultValue": "5432", | |
"metadata": { | |
"description": "The default port for the psql server." | |
} | |
}, | |
"databaseUsername": { | |
"type": "string", | |
"metadata": { | |
"description": "The username used to connect to the database." | |
} | |
}, | |
"databasePassword": { | |
"type": "string", | |
"metadata": { | |
"description": "The password used to connect to the database." | |
} | |
}, | |
"databaseServiceName": { | |
"type": "string", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The abbreviation of the service that contains the database used by this application." | |
} | |
}, | |
"displayName": { | |
"type": "string", | |
"metadata": { | |
"description": "Human readable name to show in the user interface to indicate which database is being displayed, e.g. 'Publish-QA'" | |
} | |
}, | |
"appServicePlanSize": { | |
"type": "string", | |
"allowedValues": [ | |
"1", | |
"2", | |
"3" | |
], | |
"defaultValue": "1" | |
}, | |
"appServicePlanInstances": { | |
"type": "int", | |
"defaultValue": 1 | |
}, | |
"containerCPUCores": { | |
"type": "string", | |
"defaultValue": "1", | |
"metadata": { | |
"description": "The number of CPU cores for Azure Container Instance." | |
} | |
}, | |
"containerMemory": { | |
"type": "string", | |
"defaultValue": "1.5", | |
"metadata": { | |
"description": "The number of memory in GB for Azure Container Instance." | |
} | |
} | |
}, | |
"variables": { | |
"deploymentUrlBase": "https://raw.githubusercontent.com/DFE-Digital/bat-platform-building-blocks/master/templates/", | |
"deploymentUrlBaseDas": "https://raw.githubusercontent.com/SkillsFundingAgency/das-platform-building-blocks/master/templates/", | |
"resourceNamePrefix": "[toLower(concat(parameters('resourceEnvironmentName'),'-', parameters('serviceName')))]", | |
"keyvaultCertificateName": "[if(greater(length(parameters('certificateName')),0), parameters('certificateName'), replace(parameters('customHostName'), '.', '-'))]", | |
"appServiceName": "[concat(variables('resourceNamePrefix'), '-as')]", | |
"appServicePlanName": "[concat(variables('resourceNamePrefix'), '-asp')]", | |
"databaseResourceNamePrefix": "[toLower(concat(parameters('resourceEnvironmentName'),'-', parameters('databaseServiceName')))]", | |
"databaseServerName": "[concat(variables('databaseResourceNamePrefix'), '-psql')]", | |
"databaseResourceGroup": "[concat(variables('databaseResourceNamePrefix'), '-rg')]" | |
}, | |
"resources": [ | |
{ | |
"name": "app-service-plan", | |
"type": "Microsoft.Resources/deployments", | |
"apiVersion": "2017-05-10", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'), 'app-service-plan.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"appServicePlanName": { | |
"value": "[variables('appServicePlanName')]" | |
}, | |
"appServicePlanSize": { | |
"value": "[parameters('appServicePlanSize')]" | |
}, | |
"appServicePlanInstances": { | |
"value": "[parameters('appServicePlanInstances')]" | |
} | |
} | |
} | |
}, | |
{ | |
"condition": "[greater(length(parameters('customHostName')), 0)]", | |
"name": "app-service-certificate", | |
"type": "Microsoft.Resources/deployments", | |
"apiVersion": "2017-05-10", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'), 'app-service-certificate.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"keyVaultCertificateName": { | |
"value": "[variables('keyVaultCertificateName')]" | |
}, | |
"keyVaultName": { | |
"value": "[parameters('keyVaultName')]" | |
}, | |
"keyVaultResourceGroup": { | |
"value": "[parameters('keyVaultResourceGroup')]" | |
} | |
} | |
} | |
}, | |
{ | |
"name": "app-service", | |
"type": "Microsoft.Resources/deployments", | |
"apiVersion": "2017-05-10", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'), 'app-service-linux.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"appServiceName": { | |
"value": "[variables('appServiceName')]" | |
}, | |
"appServicePlanResourceGroup": { | |
"value": "[resourceGroup().name]" | |
}, | |
"appServicePlanName": { | |
"value": "[variables('appServicePlanName')]" | |
}, | |
"runtimeStack": { | |
"value": "DOCKER|timabell/sdv" | |
}, | |
"appServiceAppSettings": { | |
"value": [ | |
{ | |
"name": "schemaexplorer_listen_on_port", | |
"value": "8080" | |
}, | |
{ | |
"name": "schemaexplorer_driver", | |
"value": "pg" | |
}, | |
{ | |
"name": "schemaexplorer_display_name", | |
"value": "[parameters('displayName')]" | |
}, | |
{ | |
"name": "schemaexplorer_pg_host", | |
"value": "[parameters('databaseServerHostName')]" | |
}, | |
{ | |
"name": "schemaexplorer_pg_port", | |
"value": "[parameters('databasePort')]" | |
}, | |
{ | |
"name": "schemaexplorer_pg_database", | |
"value": "[parameters('databaseName')]" | |
}, | |
{ | |
"name": "schemaexplorer_pg_user", | |
"value": "[parameters('databaseUsername')]" | |
}, | |
{ | |
"name": "schemaexplorer_pg_password", | |
"value": "[parameters('databasePassword')]" | |
} | |
] | |
}, | |
"customHostName": { | |
"value": "[parameters('customHostName')]" | |
}, | |
"certificateThumbprint": { | |
"value": "[if(greater(length(parameters('customHostname')), 0), reference('app-service-certificate', '2018-11-01').outputs.certificateThumbprint.value, '')]" | |
} | |
} | |
}, | |
"dependsOn": [ | |
"app-service-plan" | |
] | |
}, | |
{ | |
"name": "app-service-logs", | |
"type": "Microsoft.Resources/deployments", | |
"apiVersion": "2017-05-10", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'), 'app-service-logs.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"appServiceName": { | |
"value": "[variables('appServiceName')]" | |
}, | |
"httpLoggingEnabled": { | |
"value": true | |
} | |
} | |
}, | |
"dependsOn": [ | |
"app-service" | |
] | |
}, | |
{ | |
"condition": "[greater(length(parameters('databaseServiceName')),0)]", | |
"apiVersion": "2017-05-10", | |
"name": "schema-explorer-postgresql-server-firewall-rules", | |
"type": "Microsoft.Resources/deployments", | |
"resourceGroup": "[variables('databaseResourceGroup')]", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'),'postgresql-server-firewall-rules.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"firewallRuleNamePrefix": { | |
"value": "[concat(variables('appServicePlanName'),'-AZURE_IP-')]" | |
}, | |
"ipAddresses": { | |
"value": "[reference('app-service').outputs.possibleOutboundIpAddresses.value]" | |
}, | |
"serverName": { | |
"value": "[variables('databaseServerName')]" | |
} | |
} | |
}, | |
"dependsOn": [] | |
}, | |
{ | |
"apiVersion": "2017-05-10", | |
"name": "app-insights", | |
"type": "Microsoft.Resources/deployments", | |
"properties": { | |
"mode": "Incremental", | |
"templateLink": { | |
"uri": "[concat(variables('deploymentUrlBase'), 'application-insights.json')]", | |
"contentVersion": "1.0.0.0" | |
}, | |
"parameters": { | |
"appInsightsName": { | |
"value": "[variables('appServiceName')]" | |
}, | |
"attachedService": { | |
"value": "[variables('appServiceName')]" | |
} | |
} | |
} | |
} | |
], | |
"outputs": { | |
"AppServiceName": { | |
"type": "string", | |
"value": "[variables('appServiceName')]" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set these env vars before running: | |
#sub - find name/id with `az account list` | |
#rg - make one of these manually in the portal to put your resources in | |
echo "deploying to sub $sub & rg $rg ..." | |
az group deployment create --subscription "$sub" --resource-group "$rg" --name tim-deploys-things --template-file schema-explorer-template.json --parameters @schema-explorer-parameters.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment