{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appName": { "type": "string", "minLength": 1, "metadata": { "description": "The name for the webapp. Must be globally unique." } }, "secretKey": { "type": "securestring", "minLength": 16, "metadata": { "description": "The value to use as the Django secret key." } }, "adminUserName": { "type": "string", "minLength": 1, "metadata": { "description": "The user name for the admin account." } }, "adminContactEmail": { "type": "string", "minLength": 1, "metadata": { "description": "The contact email address for the admin account." } }, "adminPassword": { "type": "securestring", "minLength": 16, "maxLength": 50, "metadata": { "description": "The password for the admin account." } }, "appServiceSku": { "type": "string", "defaultValue": "B2", "allowedValues": [ "B1", "B2", "B3", "S1", "S2", "S3" ], "metadata": { "description": "The SKU of the webapp hosting tier." } }, "sendgridSku": { "type": "string", "defaultValue": "free", "allowedValues": [ "free", "bronze", "silver", "gold", "platinum", "premier" ], "metadata": { "description": "The SKU of the Sendgrid email account." } }, "databaseCores": { "type": "int", "defaultValue": 2, "allowedValues": [ 2, 4, 8, 16, 32, 64 ], "metadata": { "description": "The number of vCores to provision for the PostgreSQL server." } }, "databaseSize": { "type": "int", "minValue": 51200, "defaultValue": 51200, "metadata": { "description": "The storage capacity to provision for the PostgreSQL server." } }, "databaseName": { "type": "string", "minLength": 1, "defaultValue": "doccano", "metadata": { "description": "The name of the database to provision on the PostgreSQL server." } }, "dockerImageName": { "type": "string", "minLength": 1, "defaultValue": "chakkiworks/doccano:latest", "metadata": { "description": "The Docker image to deploy." } }, "dockerRegistry": { "type": "string", "defaultValue": "", "metadata": { "description": "The registry of the Docker image." } }, "dockerRegistryUserName": { "type": "string", "defaultValue": "", "metadata": { "description": "The user name for the Docker registry." } }, "dockerRegistryPassword": { "type": "securestring", "defaultValue": "", "metadata": { "description": "The password for the Docker registry." } } }, "variables": { "location": "[resourceGroup().location]", "databaseSkuTier": "GeneralPurpose", "databaseSkuFamily": "Gen5", "databaseSkuName": "[concat('GP_', variables('databaseSkuFamily'), '_', parameters('databaseCores'))]", "databaseVersion": "9.6", "databaseServerPort": 5432, "databaseServerName": "[concat(parameters('appName'),'-state')]", "databaseUserCredentials" : "[concat(uriComponent(concat(parameters('adminUserName'), '@', variables('databaseServerName'))), ':', parameters('adminPassword'))]", "databaseFqdn" : "[concat( variables('databaseServerName'), '.postgres.database.azure.com:', variables('databaseServerPort'))]", "databaseConnectionString": "[concat('pgsql://', variables('databaseUserCredentials'), '@', variables('databaseFqdn'), '/', parameters('databaseName'))]", "sendgridAccountName": "[concat(parameters('appName'),'-email')]", "appServicePlanName": "[concat(parameters('appName'),'-hosting')]", "analyticsName": "[concat(parameters('appName'),'-analytics')]", "appFqdn": "[concat(parameters('appName'),'.azurewebsites.net')]" }, "resources": [ { "name": "[variables('sendgridAccountName')]", "type": "Sendgrid.Email/accounts", "apiVersion": "2015-01-01", "location": "[variables('location')]", "plan": { "name": "[parameters('sendgridSku')]", "publisher": "Sendgrid", "product": "sendgrid_azure", "promotionCode": "" }, "properties": { "acceptMarketingEmails": false, "email": "[parameters('adminContactEmail')]", "password": "[parameters('adminPassword')]" } }, { "type": "Microsoft.Insights/components", "apiVersion": "2015-05-01", "name": "[variables('analyticsName')]", "location": "[variables('location')]", "tags": {}, "kind": "web", "properties": { "Application_Type": "web" } }, { "apiVersion": "2017-08-01", "type": "Microsoft.Web/serverfarms", "kind": "linux", "name": "[variables('appServicePlanName')]", "location": "[variables('location')]", "properties": { "reserved": true }, "dependsOn": [], "sku": { "name": "[parameters('appServiceSku')]" } }, { "apiVersion": "2017-12-01", "type": "Microsoft.DBforPostgreSQL/servers", "location": "[variables('location')]", "name": "[variables('databaseServerName')]", "sku": { "name": "[variables('databaseSkuName')]", "tier": "[variables('databaseSkuTier')]", "family": "[variables('databaseSkuFamily')]", "capacity": "[parameters('databaseCores')]", "size": "[parameters('databaseSize')]" }, "properties": { "version": "[variables('databaseVersion')]", "administratorLogin": "[parameters('adminUserName')]", "administratorLoginPassword": "[parameters('adminPassword')]", "storageMB": "[parameters('databaseSize')]" }, "resources": [ { "name": "allowAzure", "type": "firewallrules", "apiVersion": "2017-12-01", "location": "[variables('location')]", "properties": { "startIpAddress": "0.0.0.0", "endIpAddress": "0.0.0.0" }, "dependsOn": [ "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]" ] }, { "name": "[parameters('databaseName')]", "type": "databases", "apiVersion": "2017-12-01", "properties": { "charset": "utf8", "collation": "English_United States.1252" }, "dependsOn": [ "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]" ] } ] }, { "type": "Microsoft.Web/sites", "apiVersion": "2016-08-01", "name": "[parameters('appName')]", "kind": "app,linux,container", "location": "[variables('location')]", "dependsOn": [ "[resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))]", "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]", "[resourceId('Microsoft.Insights/components', variables('analyticsName'))]", "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" ], "properties": { "name": "[parameters('appName')]", "siteConfig": { "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]", "alwaysOn": true, "appSettings": [ { "name": "WEBSITES_PORT", "value": "8000" }, { "name": "PORT", "value": "8000" }, { "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE", "value": "false" }, { "name": "DOCKER_REGISTRY_SERVER_URL", "value": "[parameters('dockerRegistry')]" }, { "name": "DOCKER_REGISTRY_SERVER_USERNAME", "value": "[parameters('dockerRegistryUserName')]" }, { "name": "DOCKER_REGISTRY_SERVER_PASSWORD", "value": "[parameters('dockerRegistryPassword')]" }, { "name": "AZURE_APPINSIGHTS_IKEY", "value": "[reference(resourceId('Microsoft.Insights/components', variables('analyticsName')), '2014-04-01').InstrumentationKey]" }, { "name": "GOOGLE_TRACKING_ID", "value": " " }, { "name": "ADMIN_USERNAME", "value": "[parameters('adminUserName')]" }, { "name": "ADMIN_EMAIL", "value": "[parameters('adminContactEmail')]" }, { "name": "ADMIN_PASSWORD", "value": "[parameters('adminPassword')]" }, { "name": "EMAIL_USE_TLS", "value": "True" }, { "name": "EMAIL_HOST", "value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).smtpServer]" }, { "name": "EMAIL_HOST_USER", "value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).username]" }, { "name": "EMAIL_HOST_PASSWORD", "value": "[parameters('adminPassword')]" }, { "name": "EMAIL_PORT", "value": "587" }, { "name": "DEBUG", "value": "False" }, { "name": "SECRET_KEY", "value": "[parameters('secretKey')]" }, { "name": "DATABASE_URL", "value": "[variables('databaseConnectionString')]" } ] }, "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" } } ], "outputs": { "appServer": { "type": "string", "value": "[concat(variables('appFqdn'))]" }, "databaseServer": { "type": "string", "value": "[variables('databaseFqdn')]" } } }