Skip to content

Instantly share code, notes, and snippets.

@johndowns
Created February 1, 2019 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndowns/bf2cdd67c0e7df8a4e8d4d04a486c375 to your computer and use it in GitHub Desktop.
Save johndowns/bf2cdd67c0e7df8a4e8d4d04a486c375 to your computer and use it in GitHub Desktop.
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertEmailAddress": {
"type": "string",
"metadata": {
"description": "The email address to receive any alerts."
}
},
"appServiceName": {
"type": "string",
"defaultValue": "[uniqueString(subscription().subscriptionId, resourceGroup().name)]",
"metadata": {
"description": "The name to use when creating the app service. This must be globally unique."
}
}
},
"variables": {
"appServicePlanName": "AppServicePlan",
"actionGroupName": "MyApplicationErrors"
},
"resources": [
{
"name": "[variables('appServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"kind": "app",
"sku": {
"name": "F1",
"tier": "Free",
"size": "F1",
"family": "F",
"capacity": 1
},
"properties": {
"name": "[variables('appServicePlanName')]",
"numberOfWorkers": 1
}
},
{
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"kind": "web",
"properties": {
"name": "[parameters('appServiceName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"minTlsVersion": "1.2"
},
"httpsOnly": true,
"clientAffinityEnabled": false
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
]
},
{
"name": "[variables('actionGroupName')]",
"type": "Microsoft.Insights/actionGroups",
"location": "global",
"apiVersion": "2018-03-01",
"properties": {
"groupShortName": "App Service",
"enabled": true,
"emailReceivers": [
{
"name": "Account Owner",
"emailAddress": "[parameters('alertEmailAddress')]"
}
]
}
},
{
"name": "HttpExceptions",
"type": "Microsoft.Insights/metricAlerts",
"location": "global",
"apiVersion": "2018-03-01",
"properties": {
"description": "[concat('The number of HTTP 5xx responses has increased beyond the specified threshold.')]",
"severity": 2,
"enabled": true,
"scopes": [
"[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]"
],
"evaluationFrequency": "PT5M",
"windowSize": "PT1H",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "HTTP 5xx greater than 3",
"metricName": "Http5xx",
"operator": "GreaterThan",
"threshold": 3,
"timeAggregation": "Maximum"
}
]
},
"actions": [
{
"actionGroupId": "[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]"
}
],
"dependsOn": [
"[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]",
"[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]"
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment