Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
543 lines (488 sloc) 18.2 KB
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"EnvironmentSuffix": {
"type": "string"
},
"RegionSuffix": {
"type": "string"
},
"WEBSITE_NODE_DEFAULT_VERSION": {
"type": "string"
},
"DATA_ACCESS_CS": {
"type": "string"
},
"STORAGE_QUEUE_CS": {
"type": "string"
},
"APPINSIGHTS_INSTRUMENTATIONKEY": {
"type": "string"
},
"METRIC_STORAGE_CS": {
"type": "string"
},
"METADATA_STORAGE_CS": {
"type": "string"
}
},
"variables": {
"location": "[resourceGroup().location]",
"application_name": "myappname",
"serverfarms_AppServicePlan_name": "AppServicePlan",
"serverfarms_WebJobsPlan_name": "WebJobsPlan",
"namespace_name": "[concat(variables('application_name'),parameters('EnvironmentSuffix'), parameters('RegionSuffix'))]",
"auth_rule_name": "RootManageSharedAccessKey",
"namespace_auth_rule_id": "[resourceId('Microsoft.Eventhub/namespaces/authorizationRules', variables('namespace_name'), variables('auth_rule_name'))]",
"namespace_api_version": "[providers('Microsoft.Eventhub', 'namespaces').apiVersions[0]]",
"eventhubs_name1": "convertedmetrics",
"eventhubs_name2": "convertedmetricaverages",
"consumergroups_name1": "convertedmetrics",
"consumergroups_name2": "convertedmetricaverages",
"eventhubprocessorsite_name": "[concat(variables('application_name'), 'eventhubprocessor', parameters('EnvironmentSuffix'), parameters('RegionSuffix'))]",
"webapp_name": "[concat(variables('application_name'),parameters('EnvironmentSuffix'), parameters('RegionSuffix'))]",
"stream_analytics_job_name": "ConvertedAveragesMinutely",
"sa_input_name": "ConvertedMetrics1",
"sa_transformation_name": "CalculateAverage",
"sa_output_name": "ConvertedMetricAverages",
"event_hub_processor_storage": "[concat(variables('application_name'), 'eh',parameters('EnvironmentSuffix', parameters('RegionSuffix'))]",
"event_hub_processor_storagetype": "Standard_LRS"
},
"resources": [
/* API Service Plan */
{
"type": "Microsoft.Web/serverfarms",
"sku": {
"name": "S1",
"tier": "Standard",
"size": "S1",
"family": "S",
"capacity": 1
},
"name": "[variables('serverfarms_AppServicePlan_name')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"name": "[variables('serverfarms_AppServicePlan_name')]",
"numberOfWorkers": 1
},
"resources": [ ],
"dependsOn": [ ]
},
/* Web Jobs Service Plan */
{
"type": "Microsoft.Web/serverfarms",
"sku": {
"name": "S1",
"tier": "Standard",
"size": "S1",
"family": "S",
"capacity": 1
},
"name": "[variables('serverfarms_WebJobsPlan_name')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"name": "[variables('serverfarms_WebJobsPlan_name')]",
"numberOfWorkers": 1
},
"resources": [ ],
"dependsOn": [ ]
},
/* Event Hub Processor Web App */
{
"type": "Microsoft.Web/sites",
"kind": "WebApp",
"name": "[variables('eventhubprocessorsite_name')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"name": "[variables('eventhubprocessorsite_name')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverfarms_WebJobsPlan_name'))]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('eventhubprocessorsite_name'))]"
],
"properties": {
"phpVersion": "5.5",
"netFrameworkVersion": "v4.0",
"use32BitWorkerProcess": false, /* 64-bit platform */
"webSocketsEnabled": true,
"alwaysOn": true,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2015"
}
},
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('eventhubprocessorsite_name'))]",
"[resourceId('Microsoft.EventHub/namespaces', variables('namespace_name'))]"
],
"properties": {
"WEBSITE_NODE_DEFAULT_VERSION": "[parameters('WEBSITE_NODE_DEFAULT_VERSION')]",
"DATA_ACCESS_CS": "[parameters('DATA_ACCESS_CS')]",
"STORAGE_QUEUE_CS": "[parameters('STORAGE_QUEUE_CS')]",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[parameters('APPINSIGHTS_INSTRUMENTATIONKEY')]",
"EVENT_HUB_CS": "[listKeys(variables('namespace_auth_rule_id'), '2015-08-01').primaryConnectionString ]",
"METRIC_STORAGE_CS": "[parameters('METRIC_STORAGE_CS')]",
"METADATA_STORAGE_CS": "[parameters('METADATA_STORAGE_CS')]",
"EVENT_HUB_STORAGE_CS": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('event_hub_processor_storage'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('event_hub_processor_storage')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]",
"DATA_ACCESS_PROVIDER": "dataAccess.azure.json",
"QUEUE_PROVIDER": "queueProvider.azure.json"
}
},
{
"apiVersion": "2015-08-01",
"name": "connectionstrings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('eventhubprocessorsite_name'))]"
],
"properties": {
}
},
{
"apiVersion": "2015-08-01",
"name": "logs",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('eventhubprocessorsite_name'))]"
],
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Warning"
}
},
"httpLogs": {
"fileSystem": {
"retentionInMb": 40,
"enabled": true
}
},
"failedRequestsTracing": {
"enabled": true
},
"detailedErrorMessages": {
"enabled": true
}
}
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('serverfarms_WebJobsPlan_name'))]"
]
},
/* API Web App */
{
"type": "Microsoft.Web/sites",
"name": "[variables('webapp_name')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"name": "[variables('webapp_name')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverfarms_AppServicePlan_name'))]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webapp_name'))]"
],
"properties": {
"phpVersion": "5.5",
"netFrameworkVersion": "v4.0",
"use32BitWorkerProcess": false, /* 64-bit platform */
"webSocketsEnabled": true,
"alwaysOn": true,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2015"
}
},
/* API App Settings */
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webapp_name'))]"
],
"properties": {
"WEBSITE_NODE_DEFAULT_VERSION": "[parameters('WEBSITE_NODE_DEFAULT_VERSION')]",
"DATA_ACCESS_CS": "[parameters('DATA_ACCESS_CS')]",
"STORAGE_QUEUE_CS": "[parameters('STORAGE_QUEUE_CS')]",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[parameters('APPINSIGHTS_INSTRUMENTATIONKEY')]",
"EVENT_HUB_CS": "[listKeys(variables('namespace_auth_rule_id'), '2015-08-01').primaryConnectionString ]",
"METRIC_STORAGE_CS": "[parameters('METRIC_STORAGE_CS')]",
"METADATA_STORAGE_CS": "[parameters('METADATA_STORAGE_CS')]",
"EVENT_HUB_STORAGE_CS": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('event_hub_processor_storage'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('event_hub_processor_storage')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]",
"DATA_ACCESS_PROVIDER": "dataAccess.azure.json",
"QUEUE_PROVIDER": "queueProvider.azure.json"
}
},
{
"apiVersion": "2015-08-01",
"name": "logs",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webapp_name'))]"
],
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Warning"
}
},
"httpLogs": {
"fileSystem": {
"retentionInMb": 40,
"enabled": true
}
},
"failedRequestsTracing": {
"enabled": true
},
"detailedErrorMessages": {
"enabled": true
}
}
},
{
"apiVersion": "2015-08-01",
"name": "slotconfignames",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webapp_name'))]"
],
"properties": {
"connectionStringNames": [ "ConnString1" ],
"appSettingNames": [ "AppSettingKey1" ]
}
},
{
"apiVersion": "2015-08-01",
"name": "Staging",
"type": "slots",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webapp_name'))]"
],
"properties": {
},
"resources": [
]
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('serverfarms_AppServicePlan_name'))]"
]
},
/* Event Hub Name Space */
{
"type": "Microsoft.EventHub/namespaces",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"name": "[variables('namespace_name')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"tags": { },
"properties": {
},
"resources": [
{
"type": "AuthorizationRules",
"name": "[variables('auth_rule_name')]",
"apiVersion": "2015-08-01",
"properties": {
"rights": [
"Listen",
"Manage",
"Send"
]
},
"resources": [ ],
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('namespace_name'))]",
"[concat('Microsoft.EventHub/namespaces/', variables('namespace_name'),'/eventhubs/',variables('eventhubs_name1'))]",
"[concat('Microsoft.EventHub/namespaces/', variables('namespace_name'),'/eventhubs/',variables('eventhubs_name2'))]",
"[concat('Microsoft.EventHub/namespaces/', variables('namespace_name'),'/eventhubs/',variables('eventhubs_name1'), '/consumerGroups/', variables('consumergroups_name1'))]",
"[concat('Microsoft.EventHub/namespaces/', variables('namespace_name'),'/eventhubs/',variables('eventhubs_name2'), '/consumerGroups/', variables('consumergroups_name2'))]"
]
},
/* Event Hub Converted metrics */
{
"type": "eventhubs",
"name": "[variables('eventhubs_name1')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 4
},
"resources": [
{
"type": "consumergroups",
"name": "[variables('consumergroups_name1')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"path": "[variables('consumergroups_name1')]"
},
"resources": [ ],
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('namespace_name'))]",
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('namespace_name'), variables('eventhubs_name1'))]"
]
}
],
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces',variables('namespace_name'))]"
]
},
/* Event Hub Converted Metric Averages */
{
"type": "eventhubs",
"name": "[variables('eventhubs_name2')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"properties": {
"messageRetentionInDays": 1,
"status": "Active",
"partitionCount": 2
},
"resources": [
{
"type": "consumergroups",
"name": "[variables('consumergroups_name2')]",
"apiVersion": "2015-08-01",
"location":"[resourceGroup().location]",
"resources": [ ],
"properties": {
"path": "[variables('consumergroups_name2')]"
},
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('namespace_name'))]",
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('namespace_name'), variables('eventhubs_name2'))]"
]
}
],
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces',variables('namespace_name'))]"
]
}
],
"dependsOn": [ ]
},
/* Streaming Analytics Jobs */
{
"apiVersion": "2015-06-01",
"type": "Microsoft.StreamAnalytics/streamingjobs",
"name": "[variables('stream_analytics_job_name')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('namespace_name'))]"
],
"properties": {
"sku": {
"name": "standard"
},
"outputStartMode": "JobStartTime",
"outputStartTime": null,
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
{
"Name": "[variables('sa_input_name')]",
"Properties": {
"DataSource": {
"Properties": {
"Name": "[variables('sa_input_name')]",
"EventHubName": "[variables('eventhubs_name1')]",
"consumerGroupName": "[variables('consumergroups_name1')]",
"ServiceBusNamespace": "[variables('namespace_name')]",
"SharedAccessPolicyKey": "[listkeys(variables('namespace_auth_rule_id'), variables('namespace_api_version')).primaryKey]",
"SharedAccessPolicyName": "[variables('auth_rule_name')]",
"PartitionKey": "PartitionId"
},
"Type": "Microsoft.ServiceBus/EventHub"
},
"Serialization": {
"Properties": {
"Encoding": "UTF8",
"Format": "Array"
},
"Type": "Json"
},
"Type": "Stream"
}
}
],
"Outputs": [
{
"Name": "ConvertedMetricAverage",
"Properties": {
"DataSource": {
"Properties": {
"EventHubName": "[variables('eventhubs_name2')]",
"consumerGroupName": "[variables('consumergroups_name2')]",
"ServiceBusNamespace": "[variables('namespace_name')]",
"SharedAccessPolicyKey": "[listkeys(variables('namespace_auth_rule_id'), variables('namespace_api_version')).primaryKey]",
"SharedAccessPolicyName": "[variables('auth_rule_name')]",
"PartitionKey": "PartitionId"
},
"Type": "Microsoft.ServiceBus/EventHub"
},
"Serialization": {
"Properties": {
"Encoding": "UTF8",
"Format": "Array"
},
"Type": "Json"
}
}
}
],
"Transformation": {
"Name": "[variables('sa_transformation_name')]",
"Properties": {
"Query": "SELECT\r\n System.Timestamp as TimeValue,\r\n SensorId,\r\n AVG(Value) as ValueAvg,\r\n COUNT(*) as ValueAvgCount,\r\n SUM(Value) as ValueAvgSum,\r\n MIN(Value) as ValueMin,\r\n MAX(Value) ValueMax,\r\n '5MINUTE' as 'AverageType'\r\nINTO\r\n ConvertedMetricAverages\r\nFROM\r\n ConvertedMetrics1\r\nTIMESTAMP BY CreatedUtc\r\nGROUP BY SensorId, TUMBLINGWINDOW(minute, 5)\r\n",
"StreamingUnits": 1
}
}
}
},
/* Event Hub Storage Account */
{
"name": "[variables('event_hub_processor_storage')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [ ],
"tags": {
"displayName": "[variables('event_hub_processor_storage')]"
},
"properties": {
"accountType": "[variables('event_hub_processor_storagetype')]"
}
}
],
"outputs": {
"DNSName": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Web/Sites', variables('webapp_name'))).hostNames[0]]"
}
}
}
You can’t perform that action at this time.