-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
102 lines (96 loc) · 2.74 KB
/
main.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// from quickstart docs for IOT: https://docs.microsoft.com/en-us/azure/iot-hub/horizontal-arm-route-messages
@minLength(1)
@maxLength(11)
param projectName string = 'contoso'
param location string = resourceGroup().location
param skuName string = 'S1'
param skuUnits int = 1
param d2cPartitions int = 4 // partitions used for the event stream
var unique = uniqueString(resourceGroup().id)
var iotHubName = '${projectName}Hub${unique}'
var storageAccountName = '${toLower(projectName)}${unique}'
var storageEndpoint = '${projectName}StorageEndpoint'
var storageContainerName = '${toLower(projectName)}results'
resource stg 'microsoft.storage/storageAccounts@2019-06-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'Storage'
}
resource blob 'microsoft.storage/storageAccounts/blobServices/containers@2019-06-01' = {
name: '${stg.name}/default/${storageContainerName}'
properties: {
publicAccess: 'None'
}
}
resource iot 'microsoft.devices/iotHubs@2020-03-01' = {
name: iotHubName
location: location
sku: {
name: skuName
capacity: skuUnits
}
properties: {
eventHubEndpoints: {
events: {
retentionTimeInDays: 1
partitionCount: d2cPartitions
}
}
routing: {
endpoints: {
storageContainers: [
{
// really need a listConnectionString() function
connectionString: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${stg.listKeys().keys[0].value}'
containerName: storageContainerName
fileNameFormat: '{iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}'
batchFrequencyInSeconds: 100
maxChunkSizeInBytes: 104857600
encoding: 'JSON'
name: storageEndpoint
}
]
}
routes: [
{
name: 'ContosoStorageRoute'
source: 'DeviceMessages'
condition: 'level="storage"'
endpointNames: [
storageEndpoint
]
isEnabled: true
}
]
fallbackRoute: {
name: '$fallback'
source: 'DeviceMessages'
condition: 'true' // todo - does this need to be a string?
endpointNames: [
'events'
]
isEnabled: true
}
}
messagingEndpoints: {
fileNotifications: {
lockDurationAsIso8601: 'PT1M'
ttlAsIso8601: 'PT1H'
maxDeliveryCount: 10
}
}
enableFileUploadNotifications: false
cloudToDevice: {
maxDeliveryCount: 10
defaultTtlAsIso8601: 'PT1H'
feedback: {
lockDurationAsIso8601: 'PT1M'
ttlAsIso8601: 'PT1H'
maxDeliveryCount: 10
}
}
}
}