Skip to content

Instantly share code, notes, and snippets.

@MarcusFelling
Last active June 25, 2021 15:44
Show Gist options
  • Save MarcusFelling/ae30217c537ce2578f6856e427bd1eac to your computer and use it in GitHub Desktop.
Save MarcusFelling/ae30217c537ce2578f6856e427bd1eac to your computer and use it in GitHub Desktop.
@minLength(1)
@maxLength(11)
param projectName string = 'demo'
param location string = resourceGroup().location
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}'
}
// Docs: https://docs.microsoft.com/en-us/azure/templates/microsoft.devices/2021-03-31/iothubs?tabs=bicep
resource iot 'Microsoft.Devices/IotHubs@2021-03-31' = {
name: iotHubName
location: location
sku: {
name: 'S1' // 400K Msgs Day per IoT Hub Unit
capacity: 1
}
properties: {
routing: {
endpoints: {
storageContainers: [
{
connectionString: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(stg.id, stg.apiVersion).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'
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
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment