From 59b9d147e5b5f479663ce224df320f3b2a24b20c Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Wed, 18 Dec 2019 10:05:14 -0500 Subject: [PATCH] Add Sendgrid email backend to Azure deployment --- azuredeploy.json | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/azuredeploy.json b/azuredeploy.json index 7412346a..1f16cfcc 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -33,6 +33,7 @@ "adminPassword": { "type": "securestring", "minLength": 16, + "maxLength": 50, "metadata": { "description": "The password for the admin account." } @@ -52,6 +53,21 @@ "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, @@ -124,11 +140,29 @@ "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", @@ -207,6 +241,7 @@ "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'))]" @@ -261,6 +296,26 @@ "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"