Skip to content

Instantly share code, notes, and snippets.

@johndowns johndowns/all-appinsights.json Secret
Last active Nov 28, 2018

Embed
What would you like to do?
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"instrumentationMode": {
"type": "string",
"allowedValues": [
"Development",
"NonProduction",
"Production"
],
"defaultValue": "Development",
"metadata": {
"description": "The level of instrumentation that should be deployed for these components."
}
},
"applicationInsightsLocation": {
"type": "string",
"defaultValue": "westus2",
"allowedValues": [
"eastus",
"southcentralus",
"westus2",
"northeurope",
"westeurope",
"southeastasia"
],
"metadata": {
"description": "The location in which to deploy Application Insights, since it supports a subset of Azure regions."
}
},
"alertsEmailAddress": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The email address to which alerts should be sent."
}
},
"apiManagementPublisherEmailAddress": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The email address of the owner of the API Management service."
}
},
"apiManagementPublisherName": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "The name of the owner of the API Management service."
}
},
"apiManagementSku": {
"type": "string",
"allowedValues": [
"Developer",
"Standard",
"Premium"
],
"defaultValue": "Developer",
"metadata": {
"description": "The pricing tier of the API Management service."
}
},
"apiManagementSkuCount": {
"type": "string",
"allowedValues": [
"1",
"2"
],
"defaultValue": "1",
"metadata": {
"description": "The instance size of the API Management service."
}
},
"appServicePlanSku": {
"type": "string",
"defaultValue": "S1",
"metadata": {
"description": "The SKU (pricing tier) of the app service plan."
}
},
"appServicePlanCapacity": {
"type": "int",
"defaultValue": 1,
"metadata": {
"description": "The number of instances of the app service plan."
}
},
"uniqueResourceNameSuffix": {
"type": "string",
"defaultValue": "[uniqueString(subscription().subscriptionId, resourceGroup().id)]",
"metadata": {
"description": "The suffix to add to resource names that require global uniqueness."
}
}
},
"variables": {
"applicationInsightsName": "AppInsights",
"applicationInsightsSmartDetections": [
"slowpageloadtime",
"slowserverresponsetime",
"longdependencyduration",
"degradationinserverresponsetime",
"degradationindependencyduration"
],
"apiManagementServiceName": "[concat('apiservice', parameters('uniqueResourceNameSuffix'))]",
"apiManagementLoggerName": "appinsights",
"apiManagementLoggerSamplingPercentage": "[if(equals(parameters('instrumentationMode'), 'Production'), '30', '100')]",
"appServicePlanName": "WebApps",
"appName": "[concat('web', parameters('uniqueResourceNameSuffix'))]",
"functionsStorageAccountName": "[concat('fn', parameters('uniqueResourceNameSuffix'))]",
"functionsStorageAccountResourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('functionsStorageAccountName'))]",
"functionsAppServicePlanName": "FunctionsApps",
"functionsAppName": "[concat('fn', parameters('uniqueResourceNameSuffix'))]"
},
"resources": [
{
"name": "[variables('applicationInsightsName')]",
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"location": "[parameters('applicationInsightsLocation')]",
"kind": "other",
"properties": {
"applicationId": "[variables('applicationInsightsName')]"
}
},
{
"comments": "Reconfigure Application Insights' default alerts to go to the right place (or disable if not needed)",
"name": "[concat(variables('applicationInsightsName'), '/', variables('applicationInsightsSmartDetections')[copyIndex()])]",
"type": "Microsoft.Insights/components/proactiveDetectionConfigs",
"location": "[resourceGroup().location]",
"apiVersion": "2018-05-01-preview",
"copy": {
"name": "applicationInsightsSmartDetections",
"count": "[length(variables('applicationInsightsSmartDetections'))]"
},
"properties": {
"name": "[variables('applicationInsightsSmartDetections')[copyIndex()]]",
"sendEmailsToSubscriptionOwners": false,
"customEmails": [
"[parameters('alertsEmailAddress')]"
],
"enabled": "[equals(parameters('instrumentationMode'), 'Production')]"
},
"dependsOn": [
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
},
{
"name": "[variables('apiManagementServiceName')]",
"type": "Microsoft.ApiManagement/service",
"apiVersion": "2017-03-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('apiManagementSku')]",
"capacity": "[parameters('apiManagementSkuCount')]"
},
"properties": {
"publisherEmail": "[parameters('apiManagementPublisherEmailAddress')]",
"publisherName": "[parameters('apiManagementPublisherName')]"
},
"resources": [
{
"name": "[variables('apiManagementLoggerName')]",
"type": "loggers",
"apiVersion": "2018-06-01-preview",
"properties": {
"loggerType": "applicationInsights",
"resourceId": "[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]",
"credentials": {
"instrumentationKey": "[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').instrumentationKey]"
}
},
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]",
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
},
{
"name": "applicationinsights",
"type": "diagnostics",
"apiVersion": "2018-06-01-preview",
"properties": {
"alwaysLog": "allErrors",
"loggerId": "[resourceId('Microsoft.ApiManagement/service/loggers', variables('apiManagementServiceName'), variables('apiManagementLoggerName'))]",
"enableHttpCorrelationHeaders": true,
"sampling": {
"samplingType": "fixed",
"percentage": "[variables('apiManagementLoggerSamplingPercentage')]"
}
},
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', variables('apiManagementServiceName'))]",
"[resourceId('Microsoft.ApiManagement/service/loggers', variables('apiManagementServiceName'), variables('apiManagementLoggerName'))]"
]
}
]
},
{
"name": "[variables('appServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"kind": "app",
"sku": {
"name": "S1",
"tier": "Standard",
"size": "S1",
"family": "S",
"capacity": 1
},
"properties": {
"name": "[variables('appServicePlanName')]",
"numberOfWorkers": 1
}
},
{
"name": "[variables('appName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"kind": "web",
"properties": {
"name": "[variables('appName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"httpsOnly": true,
"clientAffinityEnabled": false,
"siteConfig": {
"alwaysOn": true,
"ftpsState": "Disabled"
}
},
"resources": [
{
"name": "appsettings",
"type": "config",
"apiVersion": "2014-11-01",
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').instrumentationKey]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('appName'))]",
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
},
{
"name": "Microsoft.ApplicationInsights.AzureWebSites",
"type": "siteextensions",
"apiVersion": "2015-08-01",
"properties": {},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('appName'))]",
"[resourceId('Microsoft.Web/sites/config', variables('appName'), 'appsettings')]",
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
]
},
{
"name": "[variables('functionsStorageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2018-02-01",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"blob": {
"enabled": true
}
},
"keySource": "Microsoft.Storage"
}
}
},
{
"name": "[variables('functionsAppServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"apiVersion": "2016-09-01",
"sku": {
"name": "Y1",
"tier": "Dynamic",
"size": "Y1",
"family": "Y",
"capacity": 0
},
"kind": "functionapp",
"properties": {
"workerTierName": null,
"adminSiteName": null,
"hostingEnvironmentProfile": null,
"perSiteScaling": false,
"reserved": false,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0
}
},
{
"name": "[variables('functionsAppName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2016-08-01",
"kind": "functionapp",
"properties": {
"enabled": true,
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('functionsAppServicePlanName'))]",
"reserved": false,
"siteConfig": {
"ftpsState": "Disabled"
}
},
"resources": [
{
"name": "appsettings",
"type": "config",
"apiVersion": "2014-11-01",
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').instrumentationKey]",
"AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('functionsStorageAccountName'), ';AccountKey=', listKeys(variables('functionsStorageAccountResourceId'),'2015-05-01-preview').key1)]",
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('functionsStorageAccountName'), ';AccountKey=', listKeys(variables('functionsStorageAccountResourceId'),'2015-05-01-preview').key1)]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionsAppName'))]",
"[variables('functionsStorageAccountResourceId')]",
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
]
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('functionsAppServicePlanName'))]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.