generator-csebot
Version:
Generates a bot (Microsoft Bot Framework) with CI/CD in Team Services
411 lines (410 loc) • 17.9 kB
JSON
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webSiteName": {
"type": "string",
"minLength": 1
},
"botMSAppID": {
"type": "string",
"minLength": 1
},
"botMSAppPasswd": {
"type": "string",
"minLength": 1
},
"skuName": {
"type": "string",
"defaultValue": "F1",
"allowedValues": [
"F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P4"
],
"metadata": {
"description": "Describes plan's pricing tier and capacity. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"skuCapacity": {
"type": "int",
"defaultValue": 1,
"minValue": 1,
"metadata": {
"description": "Describes plan's instance count"
}
}
},
"variables": {
"webSiteName": "[toLower(parameters('webSiteName'))]",
"hostingPlanName": "[concat(variables('webSiteName'), '-hostingplan')]",
"botRegistrationName": "[concat(variables('webSiteName'), '-registration')]",
"appInsightsName": "[concat(variables('webSiteName'), '-insights')]",
"botTagNamePrefix": "[variables('webSiteName')]"
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "[variables('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "HostingPlan",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-hostingplan')]"
},
"sku": {
"name": "[parameters('skuName')]",
"capacity": "[parameters('skuCapacity')]"
},
"properties": {
"name": "[variables('hostingPlanName')]"
}
},
{
"apiVersion": "2018-02-01",
"name": "[variables('webSiteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]":"Resource",
"displayName": "Website"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"properties": {
"name": "[variables('webSiteName')]",
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]"
},
"resources": [
{
"name": "[concat(variables('webSiteName'), '/', 'appsettings')]",
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-02-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('webSiteName'))]",
"[concat('Microsoft.Insights/components/', variables('appInsightsName'))]"
],
"tags": {
"displayName": "WebAppSettings",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-appsettings')]"
},
"properties": {
"MicrosoftAppId": "[parameters('botMSAppID')]",
"MicrosoftAppPassword": "[parameters('botMSAppPasswd')]",
"ApplicationInsightsIntrumentationKey": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').InstrumentationKey]"
}
},
{
"name": "[concat(variables('webSiteName'), '/', 'connectionstrings')]",
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-02-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"tags": {
"displayName": "WebAppConnectionStrings",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-connectionstrings')]"
},
"properties": {
"StorageConnectionString": {
"value":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('webSiteName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('webSiteName')), '2015-05-01-preview').key1)]",
"type": "Custom"
}
}
}
]
},
{
"apiVersion": "2015-04-01",
"name": "[concat(variables('hostingPlanName'),'-autoscalesettings')]",
"type": "Microsoft.Insights/autoscalesettings",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]":
"Resource",
"displayName": "AutoScaleSettings",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-autoscalesettings')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"properties": {
"profiles": [
{
"name": "Default",
"capacity": {
"minimum": 1,
"maximum": 2,
"default": 1
},
"rules": [
{
"metricTrigger": {
"metricName": "CpuPercentage",
"metricResourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"timeGrain": "PT1M",
"statistic": "Average",
"timeWindow": "PT10M",
"timeAggregation": "Average",
"operator": "GreaterThan",
"threshold": 80.0
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": 1,
"cooldown": "PT10M"
}
},
{
"metricTrigger": {
"metricName": "CpuPercentage",
"metricResourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"timeGrain": "PT1M",
"statistic": "Average",
"timeWindow": "PT1H",
"timeAggregation": "Average",
"operator": "LessThan",
"threshold": 60.0
},
"scaleAction": {
"direction": "Decrease",
"type": "ChangeCount",
"value": 1,
"cooldown": "PT1H"
}
}
]
}
],
"enabled": false,
"name": "[concat(variables('hostingPlanName'),'-autoscalesettings')]",
"targetResourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
}
},
{
"apiVersion": "2016-03-01",
"name": "[concat(variables('appInsightsName'),'-servererrors')]",
"type": "Microsoft.Insights/alertrules",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('webSiteName'))]":
"Resource",
"displayName": "ServerErrorsAlertRule",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-servererrors')]"
},
"properties": {
"name": "[concat(variables('appInsightsName'),'-servererrors')]",
"description": "[concat(variables('webSiteName'), ' has some server errors, status code 5xx.')]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('webSiteName'))]",
"metricName": "Http5xx"
},
"operator": "GreaterThan",
"threshold": 0.0,
"windowSize": "PT5M"
},
"action": {
"odata.type":
"Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
}
},
{
"apiVersion": "2016-03-01",
"name": "[concat(variables('appInsightsName'),'-forbiddenrequests')]",
"type": "Microsoft.Insights/alertrules",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('webSiteName'))]":
"Resource",
"displayName": "ForbiddenRequestsAlertRule",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-forbiddenrequests')]"
},
"properties": {
"name": "[concat(variables('appInsightsName'),'-forbiddenrequests')]",
"description": "[concat(variables('webSiteName'), ' has some requests that are forbidden, status code 403.')]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('webSiteName'))]",
"metricName": "Http403"
},
"operator": "GreaterThan",
"threshold": 0,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
}
},
{
"apiVersion": "2016-03-01",
"name": "[concat(variables('hostingPlanName'),'-cpuhigh')]",
"type": "Microsoft.Insights/alertrules",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]":
"Resource",
"displayName": "CPUHighAlertRule",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-cpuhigh')]"
},
"properties": {
"name": "[concat(variables('hostingPlanName'),'-cpuhigh')]",
"description": "[concat('The average CPU is high across all the instances of ', variables('hostingPlanName'))]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"metricName": "CpuPercentage"
},
"operator": "GreaterThan",
"threshold": 90,
"windowSize": "PT15M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
}
},
{
"apiVersion": "2016-03-01",
"name": "[concat(variables('hostingPlanName'),'-longhttpqueue')]",
"type": "Microsoft.Insights/alertrules",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]":
"Resource",
"displayName": "LongHttpQueueAlertRule",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-longhttpqueue')]"
},
"properties": {
"name": "[concat(variables('hostingPlanName'),'-longhttpqueue')]",
"description": "[concat('The HTTP queue for the instances of ', variables('hostingPlanName'), ' has a large number of pending requests.')]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"metricName": "HttpQueueLength"
},
"operator": "GreaterThan",
"threshold": 100.0,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
}
},
{
"comments": "Storage Account supporting chatbot, namelly for bot state",
"name": "[variables('webSiteName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2018-02-01",
"tags": {
"displayName": "[variables('webSiteName')]"
},
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
},
"properties": {},
"dependsOn": []
},
{
"apiVersion": "2015-05-01",
"name": "[variables('appInsightsName')]",
"type": "Microsoft.Insights/components",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('webSiteName'))]":
"Resource",
"Solution": "variables('botTagNamePrefix')",
"Tier": "[concat(variables('botTagNamePrefix'), '-FE')]",
"Resource": "[concat(variables('botTagNamePrefix'), '-appInsights')]"
},
"properties": {
"applicationId": "[variables('webSiteName')]"
}
}
],
"outputs": {
"appinsights-instrumentation-key": {
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').InstrumentationKey]",
"type" : "string"
},
"appinsights-appid": {
"value": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').AppId]",
"type" : "string"
},
"appinsightsname": {
"value": "[variables('appInsightsName')]",
"type" : "string"
},
"storage-account-key": {
"value": "[first(listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('webSiteName')), '2018-02-01').keys).value]",
"type" : "string"
}
}
}