{
“type”: “Microsoft.StreamAnalytics/StreamingJobs”,
“apiVersion”: “2016-03-01”,
“name”: “[variables(‘streamAnalyticsChartHourJobName’)]”,
“location”: “[resourceGroup().location]”,
“properties”: {
“sku”: {
“name”: “standard”
},
“inputs”: [
{
“name”: “equipmentdatapoint”,
“type”: “Microsoft.StreamAnalytics/streamingjobs/inputs”,

“properties”: {
“type”: “stream”,
“datasource”: {
“type”: “Microsoft.ServiceBus/EventHub”,
“properties”: {
“eventHubName”: “[parameters(‘equipmentEventsEventHubName’)]”,
“serviceBusNamespace”: “[variables(‘eventHubNamespaceName’)]”,
“sharedAccessPolicyName”: “[variables(‘defaultSASKeyName’)]”,
“sharedAccessPolicyKey”: “[listKeys(resourceId(‘Microsoft.Eventhub/namespaces/authorizationRules’, variables(‘eventHubNamespaceName’), variables(‘defaultSASKeyName’)), ‘2014-09-01’).primaryKey]”,
“consumerGroupName”: “[variables(‘ehHourConsumerGroup’)]”

}
},
“serialization”: {
“type”: “JSON”,
“properties”: { “encoding”: “UTF8” }
}
}
},
{
“name”: “tagreference”,
“type”: “Microsoft.StreamAnalytics/streamingjobs/inputs”,

“properties”: {
“type”: “Reference”,
“datasource”: {
“type”: “Microsoft.Storage/Blob”,
“properties”: {
“storageAccounts”: [
{
“accountName”: “[variables(‘storageAccountName’)]”,
“accountKey”: “[listKeys(variables(‘storageAccountid’),’2015-05-01-preview’).key1]”
}
],
“container”: “tagconfig”,
“pathPattern”: “tags.json”,
“dateFormat”: “yyyy-MM-dd”,
“timeFormat”: “HH”

 

}
},
“serialization”: {
“type”: “JSON”,
“properties”: { “encoding”: “UTF8” }
}
}
}
],
“transformation”: {
“name”: “Transformation”,
“properties”: {
“streamingUnits”: 1,
“query”: “with A AS\r\n (\r\n SELECT\r\n CONCAT(a.equipmentId,’.’,a.dataPoint.name,’.’,CAST(DATEPART (hh,a.dateTime)as nvarchar(max))) as primaryKey,\r\n CAST(DATEPART (hh,a.dateTime)as nvarchar(max)) as hournum,\r\n a.equipmentId,\r\n a.dataPoint.name,\r\n AVG (a.dataPoint.tagValue) as average\r\n FROM\r\n [equipmentdatapoint] a\r\n Partition By PartitionId\r\n WHERE TRY_CAST( a.dataPoint.tagValue AS float) IS NOT NULL\r\n GROUP BY a.equipmentId,a.dataPoint.name,CAST(DATEPART (hh,a.dateTime)as nvarchar(max)),TUMBLINGWINDOW(hh, 1),PartitionId\r\n )\r\n SELECT\r\n primaryKey,\r\n hournum,\r\n equipmentId,\r\n name,\r\n AVG (average) as average,\r\n SYSTEM.TIMESTAMP as createTIme\r\n INTO\r\n [houraggregate]\r\n FROM\r\n A\r\n GROUP BY primaryKey,equipmentId,name,hournum,TUMBLINGWINDOW(hh, 1)”
}

},
“outputs”: [
{
“name”: “houraggregate”,
“properties”: {
“type”: “Microsoft.StreamAnalytics/streamingjobs/outputs”,
“datasource”: {
“type”: “Microsoft.Storage/DocumentDB”,
“properties”: {
“AccountId”: “[variables(‘cosmosDBName’)]”,
“CollectionNamePattern”: “chartdata-hour”,
“Database”: “ar-poc”,
“AccountKey”: “[listKeys(resourceId(‘Microsoft.DocumentDb/databaseAccounts’, variables(‘cosmosDBName’)), ‘2015-04-08’).primaryMasterKey]”,
“DocumentId”: “primaryKey”
}
},
“serialization”: {
“type”: “JSON”,
“properties”: { “encoding”: “UTF8” }
}

}

}
]

},
“dependsOn”: [
“[resourceId(‘Microsoft.DocumentDb/databaseAccounts’, variables(‘cosmosDBName’))]”,
“[resourceId(‘Microsoft.EventHub/namespaces’, variables(‘eventHubNamespaceName’))]”
]
}