Delen via


Microsoft.Devices IotHubs 2019-11-04

Bicep resource definition

The IotHubs resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Devices/IotHubs resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Devices/IotHubs@2019-11-04' = {
  etag: 'string'
  location: 'string'
  name: 'string'
  properties: {
    authorizationPolicies: [
      {
        keyName: 'string'
        primaryKey: 'string'
        rights: 'string'
        secondaryKey: 'string'
      }
    ]
    cloudToDevice: {
      defaultTtlAsIso8601: 'string'
      feedback: {
        lockDurationAsIso8601: 'string'
        maxDeliveryCount: int
        ttlAsIso8601: 'string'
      }
      maxDeliveryCount: int
    }
    comments: 'string'
    enableFileUploadNotifications: bool
    eventHubEndpoints: {
      {customized property}: {
        partitionCount: int
        retentionTimeInDays: int
      }
    }
    features: 'string'
    ipFilterRules: [
      {
        action: 'string'
        filterName: 'string'
        ipMask: 'string'
      }
    ]
    messagingEndpoints: {
      {customized property}: {
        lockDurationAsIso8601: 'string'
        maxDeliveryCount: int
        ttlAsIso8601: 'string'
      }
    }
    routing: {
      endpoints: {
        eventHubs: [
          {
            connectionString: 'string'
            name: 'string'
            resourceGroup: 'string'
            subscriptionId: 'string'
          }
        ]
        serviceBusQueues: [
          {
            connectionString: 'string'
            name: 'string'
            resourceGroup: 'string'
            subscriptionId: 'string'
          }
        ]
        serviceBusTopics: [
          {
            connectionString: 'string'
            name: 'string'
            resourceGroup: 'string'
            subscriptionId: 'string'
          }
        ]
        storageContainers: [
          {
            batchFrequencyInSeconds: int
            connectionString: 'string'
            containerName: 'string'
            encoding: 'string'
            fileNameFormat: 'string'
            maxChunkSizeInBytes: int
            name: 'string'
            resourceGroup: 'string'
            subscriptionId: 'string'
          }
        ]
      }
      enrichments: [
        {
          endpointNames: [
            'string'
          ]
          key: 'string'
          value: 'string'
        }
      ]
      fallbackRoute: {
        condition: 'string'
        endpointNames: [
          'string'
        ]
        isEnabled: bool
        name: 'string'
        source: 'string'
      }
      routes: [
        {
          condition: 'string'
          endpointNames: [
            'string'
          ]
          isEnabled: bool
          name: 'string'
          source: 'string'
        }
      ]
    }
    storageEndpoints: {
      {customized property}: {
        connectionString: 'string'
        containerName: 'string'
        sasTtlAsIso8601: 'string'
      }
    }
  }
  sku: {
    capacity: int
    name: 'string'
  }
  tags: {
    {customized property}: 'string'
  }
}

Property values

CloudToDeviceProperties

Name Description Value
defaultTtlAsIso8601 The default time to live for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
feedback The properties of the feedback queue for cloud-to-device messages. FeedbackProperties
maxDeliveryCount The max delivery count for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100

EnrichmentProperties

Name Description Value
endpointNames The list of endpoints for which the enrichment is applied to the message. string[] (required)
key The key or name for the enrichment property. string (required)
value The value for the enrichment property. string (required)

EventHubProperties

Name Description Value
partitionCount The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. int
retentionTimeInDays The retention time for device-to-cloud messages in days. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages int

FallbackRouteProperties

Name Description Value
condition The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. string[] (required)
isEnabled Used to specify whether the fallback route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string
source The source to which the routing rule is to be applied to. For example, DeviceMessages 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

FeedbackProperties

Name Description Value
lockDurationAsIso8601 The lock duration for the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message on the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string

IotHubProperties

Name Description Value
authorizationPolicies The shared access policies you can use to secure a connection to the IoT hub. SharedAccessSignatureAuthorizationRule[]
cloudToDevice The IoT hub cloud-to-device messaging properties. CloudToDeviceProperties
comments IoT hub comments. string
enableFileUploadNotifications If True, file upload notifications are enabled. bool
eventHubEndpoints The Event Hub-compatible endpoint properties. The only possible keys to this dictionary is events. This key has to be present in the dictionary while making create or update calls for the IoT hub. IotHubPropertiesEventHubEndpoints
features The capabilities and features enabled for the IoT hub. 'DeviceManagement'
'None'
ipFilterRules The IP filter rules. IpFilterRule[]
messagingEndpoints The messaging endpoint properties for the file upload notification queue. IotHubPropertiesMessagingEndpoints
routing The routing related properties of the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging RoutingProperties
storageEndpoints The list of Azure Storage endpoints where you can upload files. Currently you can configure only one Azure Storage account and that MUST have its key as $default. Specifying more than one storage account causes an error to be thrown. Not specifying a value for this property when the enableFileUploadNotifications property is set to True, causes an error to be thrown. IotHubPropertiesStorageEndpoints

IotHubPropertiesEventHubEndpoints

Name Description Value

IotHubPropertiesMessagingEndpoints

Name Description Value

IotHubPropertiesStorageEndpoints

Name Description Value

IotHubSkuInfo

Name Description Value
capacity The number of provisioned IoT Hub units. See: /azure/azure-subscription-service-limits#iot-hub-limits. int
name The name of the SKU. 'B1'
'B2'
'B3'
'F1'
'S1'
'S2'
'S3' (required)

IpFilterRule

Name Description Value
action The desired action for requests captured by this rule. 'Accept'
'Reject' (required)
filterName The name of the IP filter rule. string (required)
ipMask A string that contains the IP address range in CIDR notation for the rule. string (required)

MessagingEndpointProperties

Name Description Value
lockDurationAsIso8601 The lock duration. See: /azure/iot-hub/iot-hub-devguide-file-upload. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message. See: /azure/iot-hub/iot-hub-devguide-file-upload. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-file-upload. string

Microsoft.Devices/IotHubs

Name Description Value
etag The Etag field is not required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. string
location The resource location. string (required)
name The resource name string (required)
properties IotHub properties IotHubProperties
sku IotHub SKU info IotHubSkuInfo (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates

ResourceTags

Name Description Value

RouteProperties

Name Description Value
condition The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. string[] (required)
isEnabled Used to specify whether a route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
source The source that the routing rule is to be applied to, such as DeviceMessages. 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

RoutingEndpoints

Name Description Value
eventHubs The list of Event Hubs endpoints that IoT hub routes messages to, based on the routing rules. This list does not include the built-in Event Hubs endpoint. RoutingEventHubProperties[]
serviceBusQueues The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. RoutingServiceBusQueueEndpointProperties[]
serviceBusTopics The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. RoutingServiceBusTopicEndpointProperties[]
storageContainers The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. RoutingStorageContainerProperties[]

RoutingEventHubProperties

Name Description Value
connectionString The connection string of the event hub endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the event hub endpoint. string
subscriptionId The subscription identifier of the event hub endpoint. string

RoutingProperties

Name Description Value
endpoints The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. RoutingEndpoints
enrichments The list of user-provided enrichments that the IoT hub applies to messages to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid EnrichmentProperties[]
fallbackRoute The properties of the route that is used as a fall-back route when none of the conditions specified in the 'routes' section are met. This is an optional parameter. When this property is not set, the messages which do not meet any of the conditions specified in the 'routes' section get routed to the built-in eventhub endpoint. FallbackRouteProperties
routes The list of user-provided routing rules that the IoT hub uses to route messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and a maximum of 5 routing rules are allowed for free hubs. RouteProperties[]

RoutingServiceBusQueueEndpointProperties

Name Description Value
connectionString The connection string of the service bus queue endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus queue endpoint. string
subscriptionId The subscription identifier of the service bus queue endpoint. string

RoutingServiceBusTopicEndpointProperties

Name Description Value
connectionString The connection string of the service bus topic endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus topic endpoint. string
subscriptionId The subscription identifier of the service bus topic endpoint. string

RoutingStorageContainerProperties

Name Description Value
batchFrequencyInSeconds Time interval at which blobs are written to storage. Value should be between 60 and 720 seconds. Default value is 300 seconds. int

Constraints:
Min value = 60
Max value = 720
connectionString The connection string of the storage account. string (required)
containerName The name of storage container in the storage account. string (required)
encoding Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. 'Avro'
'AvroDeflate'
'JSON'
fileNameFormat File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be reordered. string
maxChunkSizeInBytes Maximum number of bytes for each blob written to storage. Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). int

Constraints:
Min value = 10485760
Max value = 524288000
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the storage account. string
subscriptionId The subscription identifier of the storage account. string

SharedAccessSignatureAuthorizationRule

Name Description Value
keyName The name of the shared access policy. string (required)
primaryKey The primary key. string
rights The permissions assigned to the shared access policy. 'DeviceConnect'
'RegistryRead'
'RegistryRead, DeviceConnect'
'RegistryRead, RegistryWrite'
'RegistryRead, RegistryWrite, DeviceConnect'
'RegistryRead, RegistryWrite, ServiceConnect'
'RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect'
'RegistryRead, ServiceConnect'
'RegistryRead, ServiceConnect, DeviceConnect'
'RegistryWrite'
'RegistryWrite, DeviceConnect'
'RegistryWrite, ServiceConnect'
'RegistryWrite, ServiceConnect, DeviceConnect'
'ServiceConnect'
'ServiceConnect, DeviceConnect' (required)
secondaryKey The secondary key. string

StorageEndpointProperties

Name Description Value
connectionString The connection string for the Azure Storage account to which files are uploaded. string (required)
containerName The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. string (required)
sasTtlAsIso8601 The period of time for which the SAS URI generated by IoT Hub for file upload is valid. See: /azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. string

Quickstart samples

The following quickstart samples deploy this resource type.

Bicep File Description
Create an IoT Hub and a Device to Cloud Consumer Group This template enables you to deploy an IoT Hub instance with device to cloud and cloud to device messaging configurations and a device to cloud consumer group.
Create an IoT Hub Device Provisioning Service This template enables you to create an IoT hub and an IoT Hub Device Provisioning Service, and link the two services together.
Create Device Update for IoT Hub account, instance, IoT Hub This template creates an account, and an instance and a hub to link the instance with. It configures the hub with the necessary access polices, routes, and consumer group.
Deploy the MedTech service including an Azure IoT Hub The MedTech service is one of the Azure Health Data Services designed to ingest device data from multiple devices, transform the device data into FHIR Observations, which are then persisted in the Azure Health Data Services FHIR service.
Use ARM template to create IoT Hub, route and view messages Use this template to deploy an IoT Hub and a storage account. Run an app to send messages to the hub that are routed to storage, then view the results.

ARM template resource definition

The IotHubs resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Devices/IotHubs resource, add the following JSON to your template.

{
  "type": "Microsoft.Devices/IotHubs",
  "apiVersion": "2019-11-04",
  "name": "string",
  "etag": "string",
  "location": "string",
  "properties": {
    "authorizationPolicies": [
      {
        "keyName": "string",
        "primaryKey": "string",
        "rights": "string",
        "secondaryKey": "string"
      }
    ],
    "cloudToDevice": {
      "defaultTtlAsIso8601": "string",
      "feedback": {
        "lockDurationAsIso8601": "string",
        "maxDeliveryCount": "int",
        "ttlAsIso8601": "string"
      },
      "maxDeliveryCount": "int"
    },
    "comments": "string",
    "enableFileUploadNotifications": "bool",
    "eventHubEndpoints": {
      "{customized property}": {
        "partitionCount": "int",
        "retentionTimeInDays": "int"
      }
    },
    "features": "string",
    "ipFilterRules": [
      {
        "action": "string",
        "filterName": "string",
        "ipMask": "string"
      }
    ],
    "messagingEndpoints": {
      "{customized property}": {
        "lockDurationAsIso8601": "string",
        "maxDeliveryCount": "int",
        "ttlAsIso8601": "string"
      }
    },
    "routing": {
      "endpoints": {
        "eventHubs": [
          {
            "connectionString": "string",
            "name": "string",
            "resourceGroup": "string",
            "subscriptionId": "string"
          }
        ],
        "serviceBusQueues": [
          {
            "connectionString": "string",
            "name": "string",
            "resourceGroup": "string",
            "subscriptionId": "string"
          }
        ],
        "serviceBusTopics": [
          {
            "connectionString": "string",
            "name": "string",
            "resourceGroup": "string",
            "subscriptionId": "string"
          }
        ],
        "storageContainers": [
          {
            "batchFrequencyInSeconds": "int",
            "connectionString": "string",
            "containerName": "string",
            "encoding": "string",
            "fileNameFormat": "string",
            "maxChunkSizeInBytes": "int",
            "name": "string",
            "resourceGroup": "string",
            "subscriptionId": "string"
          }
        ]
      },
      "enrichments": [
        {
          "endpointNames": [ "string" ],
          "key": "string",
          "value": "string"
        }
      ],
      "fallbackRoute": {
        "condition": "string",
        "endpointNames": [ "string" ],
        "isEnabled": "bool",
        "name": "string",
        "source": "string"
      },
      "routes": [
        {
          "condition": "string",
          "endpointNames": [ "string" ],
          "isEnabled": "bool",
          "name": "string",
          "source": "string"
        }
      ]
    },
    "storageEndpoints": {
      "{customized property}": {
        "connectionString": "string",
        "containerName": "string",
        "sasTtlAsIso8601": "string"
      }
    }
  },
  "sku": {
    "capacity": "int",
    "name": "string"
  },
  "tags": {
    "{customized property}": "string"
  }
}

Property values

CloudToDeviceProperties

Name Description Value
defaultTtlAsIso8601 The default time to live for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
feedback The properties of the feedback queue for cloud-to-device messages. FeedbackProperties
maxDeliveryCount The max delivery count for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100

EnrichmentProperties

Name Description Value
endpointNames The list of endpoints for which the enrichment is applied to the message. string[] (required)
key The key or name for the enrichment property. string (required)
value The value for the enrichment property. string (required)

EventHubProperties

Name Description Value
partitionCount The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. int
retentionTimeInDays The retention time for device-to-cloud messages in days. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages int

FallbackRouteProperties

Name Description Value
condition The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. string[] (required)
isEnabled Used to specify whether the fallback route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string
source The source to which the routing rule is to be applied to. For example, DeviceMessages 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

FeedbackProperties

Name Description Value
lockDurationAsIso8601 The lock duration for the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message on the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string

IotHubProperties

Name Description Value
authorizationPolicies The shared access policies you can use to secure a connection to the IoT hub. SharedAccessSignatureAuthorizationRule[]
cloudToDevice The IoT hub cloud-to-device messaging properties. CloudToDeviceProperties
comments IoT hub comments. string
enableFileUploadNotifications If True, file upload notifications are enabled. bool
eventHubEndpoints The Event Hub-compatible endpoint properties. The only possible keys to this dictionary is events. This key has to be present in the dictionary while making create or update calls for the IoT hub. IotHubPropertiesEventHubEndpoints
features The capabilities and features enabled for the IoT hub. 'DeviceManagement'
'None'
ipFilterRules The IP filter rules. IpFilterRule[]
messagingEndpoints The messaging endpoint properties for the file upload notification queue. IotHubPropertiesMessagingEndpoints
routing The routing related properties of the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging RoutingProperties
storageEndpoints The list of Azure Storage endpoints where you can upload files. Currently you can configure only one Azure Storage account and that MUST have its key as $default. Specifying more than one storage account causes an error to be thrown. Not specifying a value for this property when the enableFileUploadNotifications property is set to True, causes an error to be thrown. IotHubPropertiesStorageEndpoints

IotHubPropertiesEventHubEndpoints

Name Description Value

IotHubPropertiesMessagingEndpoints

Name Description Value

IotHubPropertiesStorageEndpoints

Name Description Value

IotHubSkuInfo

Name Description Value
capacity The number of provisioned IoT Hub units. See: /azure/azure-subscription-service-limits#iot-hub-limits. int
name The name of the SKU. 'B1'
'B2'
'B3'
'F1'
'S1'
'S2'
'S3' (required)

IpFilterRule

Name Description Value
action The desired action for requests captured by this rule. 'Accept'
'Reject' (required)
filterName The name of the IP filter rule. string (required)
ipMask A string that contains the IP address range in CIDR notation for the rule. string (required)

MessagingEndpointProperties

Name Description Value
lockDurationAsIso8601 The lock duration. See: /azure/iot-hub/iot-hub-devguide-file-upload. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message. See: /azure/iot-hub/iot-hub-devguide-file-upload. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-file-upload. string

Microsoft.Devices/IotHubs

Name Description Value
apiVersion The api version '2019-11-04'
etag The Etag field is not required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. string
location The resource location. string (required)
name The resource name string (required)
properties IotHub properties IotHubProperties
sku IotHub SKU info IotHubSkuInfo (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates
type The resource type 'Microsoft.Devices/IotHubs'

ResourceTags

Name Description Value

RouteProperties

Name Description Value
condition The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. string[] (required)
isEnabled Used to specify whether a route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
source The source that the routing rule is to be applied to, such as DeviceMessages. 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

RoutingEndpoints

Name Description Value
eventHubs The list of Event Hubs endpoints that IoT hub routes messages to, based on the routing rules. This list does not include the built-in Event Hubs endpoint. RoutingEventHubProperties[]
serviceBusQueues The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. RoutingServiceBusQueueEndpointProperties[]
serviceBusTopics The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. RoutingServiceBusTopicEndpointProperties[]
storageContainers The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. RoutingStorageContainerProperties[]

RoutingEventHubProperties

Name Description Value
connectionString The connection string of the event hub endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the event hub endpoint. string
subscriptionId The subscription identifier of the event hub endpoint. string

RoutingProperties

Name Description Value
endpoints The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. RoutingEndpoints
enrichments The list of user-provided enrichments that the IoT hub applies to messages to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid EnrichmentProperties[]
fallbackRoute The properties of the route that is used as a fall-back route when none of the conditions specified in the 'routes' section are met. This is an optional parameter. When this property is not set, the messages which do not meet any of the conditions specified in the 'routes' section get routed to the built-in eventhub endpoint. FallbackRouteProperties
routes The list of user-provided routing rules that the IoT hub uses to route messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and a maximum of 5 routing rules are allowed for free hubs. RouteProperties[]

RoutingServiceBusQueueEndpointProperties

Name Description Value
connectionString The connection string of the service bus queue endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus queue endpoint. string
subscriptionId The subscription identifier of the service bus queue endpoint. string

RoutingServiceBusTopicEndpointProperties

Name Description Value
connectionString The connection string of the service bus topic endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus topic endpoint. string
subscriptionId The subscription identifier of the service bus topic endpoint. string

RoutingStorageContainerProperties

Name Description Value
batchFrequencyInSeconds Time interval at which blobs are written to storage. Value should be between 60 and 720 seconds. Default value is 300 seconds. int

Constraints:
Min value = 60
Max value = 720
connectionString The connection string of the storage account. string (required)
containerName The name of storage container in the storage account. string (required)
encoding Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. 'Avro'
'AvroDeflate'
'JSON'
fileNameFormat File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be reordered. string
maxChunkSizeInBytes Maximum number of bytes for each blob written to storage. Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). int

Constraints:
Min value = 10485760
Max value = 524288000
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the storage account. string
subscriptionId The subscription identifier of the storage account. string

SharedAccessSignatureAuthorizationRule

Name Description Value
keyName The name of the shared access policy. string (required)
primaryKey The primary key. string
rights The permissions assigned to the shared access policy. 'DeviceConnect'
'RegistryRead'
'RegistryRead, DeviceConnect'
'RegistryRead, RegistryWrite'
'RegistryRead, RegistryWrite, DeviceConnect'
'RegistryRead, RegistryWrite, ServiceConnect'
'RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect'
'RegistryRead, ServiceConnect'
'RegistryRead, ServiceConnect, DeviceConnect'
'RegistryWrite'
'RegistryWrite, DeviceConnect'
'RegistryWrite, ServiceConnect'
'RegistryWrite, ServiceConnect, DeviceConnect'
'ServiceConnect'
'ServiceConnect, DeviceConnect' (required)
secondaryKey The secondary key. string

StorageEndpointProperties

Name Description Value
connectionString The connection string for the Azure Storage account to which files are uploaded. string (required)
containerName The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. string (required)
sasTtlAsIso8601 The period of time for which the SAS URI generated by IoT Hub for file upload is valid. See: /azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. string

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Create a Pay As You Go (PAYG) Environment with an IoT Hub

Deploy to Azure
This template enables you to deploy a Pay As You Go (PAYG) Time Series Insights environment that is configured to consume events from an IoT Hub.
Create an IoT Hub and a Device to Cloud Consumer Group

Deploy to Azure
This template enables you to deploy an IoT Hub instance with device to cloud and cloud to device messaging configurations and a device to cloud consumer group.
Create an IOT Hub and Ubuntu edge simulator

Deploy to Azure
This template creates an IOT Hub and Virtual Machine Ubuntu edge simulator.
Create an IoT Hub Device Provisioning Service

Deploy to Azure
This template enables you to create an IoT hub and an IoT Hub Device Provisioning Service, and link the two services together.
Create Device Update for IoT Hub account, instance, IoT Hub

Deploy to Azure
This template creates an account, and an instance and a hub to link the instance with. It configures the hub with the necessary access polices, routes, and consumer group.
Deploy the MedTech service including an Azure IoT Hub

Deploy to Azure
The MedTech service is one of the Azure Health Data Services designed to ingest device data from multiple devices, transform the device data into FHIR Observations, which are then persisted in the Azure Health Data Services FHIR service.
Use ARM template to create IoT Hub, route and view messages

Deploy to Azure
Use this template to deploy an IoT Hub and a storage account. Run an app to send messages to the hub that are routed to storage, then view the results.

Terraform (AzAPI provider) resource definition

The IotHubs resource type can be deployed with operations that target:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Devices/IotHubs resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Devices/IotHubs@2019-11-04"
  name = "string"
  etag = "string"
  location = "string"
  body = jsonencode({
    properties = {
      authorizationPolicies = [
        {
          keyName = "string"
          primaryKey = "string"
          rights = "string"
          secondaryKey = "string"
        }
      ]
      cloudToDevice = {
        defaultTtlAsIso8601 = "string"
        feedback = {
          lockDurationAsIso8601 = "string"
          maxDeliveryCount = int
          ttlAsIso8601 = "string"
        }
        maxDeliveryCount = int
      }
      comments = "string"
      enableFileUploadNotifications = bool
      eventHubEndpoints = {
        {customized property} = {
          partitionCount = int
          retentionTimeInDays = int
        }
      }
      features = "string"
      ipFilterRules = [
        {
          action = "string"
          filterName = "string"
          ipMask = "string"
        }
      ]
      messagingEndpoints = {
        {customized property} = {
          lockDurationAsIso8601 = "string"
          maxDeliveryCount = int
          ttlAsIso8601 = "string"
        }
      }
      routing = {
        endpoints = {
          eventHubs = [
            {
              connectionString = "string"
              name = "string"
              resourceGroup = "string"
              subscriptionId = "string"
            }
          ]
          serviceBusQueues = [
            {
              connectionString = "string"
              name = "string"
              resourceGroup = "string"
              subscriptionId = "string"
            }
          ]
          serviceBusTopics = [
            {
              connectionString = "string"
              name = "string"
              resourceGroup = "string"
              subscriptionId = "string"
            }
          ]
          storageContainers = [
            {
              batchFrequencyInSeconds = int
              connectionString = "string"
              containerName = "string"
              encoding = "string"
              fileNameFormat = "string"
              maxChunkSizeInBytes = int
              name = "string"
              resourceGroup = "string"
              subscriptionId = "string"
            }
          ]
        }
        enrichments = [
          {
            endpointNames = [
              "string"
            ]
            key = "string"
            value = "string"
          }
        ]
        fallbackRoute = {
          condition = "string"
          endpointNames = [
            "string"
          ]
          isEnabled = bool
          name = "string"
          source = "string"
        }
        routes = [
          {
            condition = "string"
            endpointNames = [
              "string"
            ]
            isEnabled = bool
            name = "string"
            source = "string"
          }
        ]
      }
      storageEndpoints = {
        {customized property} = {
          connectionString = "string"
          containerName = "string"
          sasTtlAsIso8601 = "string"
        }
      }
    }
  })
  sku = {
    capacity = int
    name = "string"
  }
  tags = {
    {customized property} = "string"
  }
}

Property values

CloudToDeviceProperties

Name Description Value
defaultTtlAsIso8601 The default time to live for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
feedback The properties of the feedback queue for cloud-to-device messages. FeedbackProperties
maxDeliveryCount The max delivery count for cloud-to-device messages in the device queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100

EnrichmentProperties

Name Description Value
endpointNames The list of endpoints for which the enrichment is applied to the message. string[] (required)
key The key or name for the enrichment property. string (required)
value The value for the enrichment property. string (required)

EventHubProperties

Name Description Value
partitionCount The number of partitions for receiving device-to-cloud messages in the Event Hub-compatible endpoint. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. int
retentionTimeInDays The retention time for device-to-cloud messages in days. See: /azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages int

FallbackRouteProperties

Name Description Value
condition The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. string[] (required)
isEnabled Used to specify whether the fallback route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string
source The source to which the routing rule is to be applied to. For example, DeviceMessages 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

FeedbackProperties

Name Description Value
lockDurationAsIso8601 The lock duration for the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message on the feedback queue. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. string

IotHubProperties

Name Description Value
authorizationPolicies The shared access policies you can use to secure a connection to the IoT hub. SharedAccessSignatureAuthorizationRule[]
cloudToDevice The IoT hub cloud-to-device messaging properties. CloudToDeviceProperties
comments IoT hub comments. string
enableFileUploadNotifications If True, file upload notifications are enabled. bool
eventHubEndpoints The Event Hub-compatible endpoint properties. The only possible keys to this dictionary is events. This key has to be present in the dictionary while making create or update calls for the IoT hub. IotHubPropertiesEventHubEndpoints
features The capabilities and features enabled for the IoT hub. 'DeviceManagement'
'None'
ipFilterRules The IP filter rules. IpFilterRule[]
messagingEndpoints The messaging endpoint properties for the file upload notification queue. IotHubPropertiesMessagingEndpoints
routing The routing related properties of the IoT hub. See: /azure/iot-hub/iot-hub-devguide-messaging RoutingProperties
storageEndpoints The list of Azure Storage endpoints where you can upload files. Currently you can configure only one Azure Storage account and that MUST have its key as $default. Specifying more than one storage account causes an error to be thrown. Not specifying a value for this property when the enableFileUploadNotifications property is set to True, causes an error to be thrown. IotHubPropertiesStorageEndpoints

IotHubPropertiesEventHubEndpoints

Name Description Value

IotHubPropertiesMessagingEndpoints

Name Description Value

IotHubPropertiesStorageEndpoints

Name Description Value

IotHubSkuInfo

Name Description Value
capacity The number of provisioned IoT Hub units. See: /azure/azure-subscription-service-limits#iot-hub-limits. int
name The name of the SKU. 'B1'
'B2'
'B3'
'F1'
'S1'
'S2'
'S3' (required)

IpFilterRule

Name Description Value
action The desired action for requests captured by this rule. 'Accept'
'Reject' (required)
filterName The name of the IP filter rule. string (required)
ipMask A string that contains the IP address range in CIDR notation for the rule. string (required)

MessagingEndpointProperties

Name Description Value
lockDurationAsIso8601 The lock duration. See: /azure/iot-hub/iot-hub-devguide-file-upload. string
maxDeliveryCount The number of times the IoT hub attempts to deliver a message. See: /azure/iot-hub/iot-hub-devguide-file-upload. int

Constraints:
Min value = 1
Max value = 100
ttlAsIso8601 The period of time for which a message is available to consume before it is expired by the IoT hub. See: /azure/iot-hub/iot-hub-devguide-file-upload. string

Microsoft.Devices/IotHubs

Name Description Value
etag The Etag field is not required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. string
location The resource location. string (required)
name The resource name string (required)
properties IotHub properties IotHubProperties
sku IotHub SKU info IotHubSkuInfo (required)
tags Resource tags Dictionary of tag names and values.
type The resource type "Microsoft.Devices/IotHubs@2019-11-04"

ResourceTags

Name Description Value

RouteProperties

Name Description Value
condition The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: /azure/iot-hub/iot-hub-devguide-query-language string
endpointNames The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. string[] (required)
isEnabled Used to specify whether a route is enabled. bool (required)
name The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
source The source that the routing rule is to be applied to, such as DeviceMessages. 'DeviceJobLifecycleEvents'
'DeviceLifecycleEvents'
'DeviceMessages'
'Invalid'
'TwinChangeEvents' (required)

RoutingEndpoints

Name Description Value
eventHubs The list of Event Hubs endpoints that IoT hub routes messages to, based on the routing rules. This list does not include the built-in Event Hubs endpoint. RoutingEventHubProperties[]
serviceBusQueues The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. RoutingServiceBusQueueEndpointProperties[]
serviceBusTopics The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. RoutingServiceBusTopicEndpointProperties[]
storageContainers The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. RoutingStorageContainerProperties[]

RoutingEventHubProperties

Name Description Value
connectionString The connection string of the event hub endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the event hub endpoint. string
subscriptionId The subscription identifier of the event hub endpoint. string

RoutingProperties

Name Description Value
endpoints The properties related to the custom endpoints to which your IoT hub routes messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. RoutingEndpoints
enrichments The list of user-provided enrichments that the IoT hub applies to messages to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid EnrichmentProperties[]
fallbackRoute The properties of the route that is used as a fall-back route when none of the conditions specified in the 'routes' section are met. This is an optional parameter. When this property is not set, the messages which do not meet any of the conditions specified in the 'routes' section get routed to the built-in eventhub endpoint. FallbackRouteProperties
routes The list of user-provided routing rules that the IoT hub uses to route messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and a maximum of 5 routing rules are allowed for free hubs. RouteProperties[]

RoutingServiceBusQueueEndpointProperties

Name Description Value
connectionString The connection string of the service bus queue endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus queue endpoint. string
subscriptionId The subscription identifier of the service bus queue endpoint. string

RoutingServiceBusTopicEndpointProperties

Name Description Value
connectionString The connection string of the service bus topic endpoint. string (required)
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the service bus topic endpoint. string
subscriptionId The subscription identifier of the service bus topic endpoint. string

RoutingStorageContainerProperties

Name Description Value
batchFrequencyInSeconds Time interval at which blobs are written to storage. Value should be between 60 and 720 seconds. Default value is 300 seconds. int

Constraints:
Min value = 60
Max value = 720
connectionString The connection string of the storage account. string (required)
containerName The name of storage container in the storage account. string (required)
encoding Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. 'Avro'
'AvroDeflate'
'JSON'
fileNameFormat File name format for the blob. Default format is {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be reordered. string
maxChunkSizeInBytes Maximum number of bytes for each blob written to storage. Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). int

Constraints:
Min value = 10485760
Max value = 524288000
name The name that identifies this endpoint. The name can only include alphanumeric characters, periods, underscores, hyphens and has a maximum length of 64 characters. The following names are reserved: events, fileNotifications, $default. Endpoint names must be unique across endpoint types. string

Constraints:
Pattern = ^[A-Za-z0-9-._]{1,64}$ (required)
resourceGroup The name of the resource group of the storage account. string
subscriptionId The subscription identifier of the storage account. string

SharedAccessSignatureAuthorizationRule

Name Description Value
keyName The name of the shared access policy. string (required)
primaryKey The primary key. string
rights The permissions assigned to the shared access policy. 'DeviceConnect'
'RegistryRead'
'RegistryRead, DeviceConnect'
'RegistryRead, RegistryWrite'
'RegistryRead, RegistryWrite, DeviceConnect'
'RegistryRead, RegistryWrite, ServiceConnect'
'RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect'
'RegistryRead, ServiceConnect'
'RegistryRead, ServiceConnect, DeviceConnect'
'RegistryWrite'
'RegistryWrite, DeviceConnect'
'RegistryWrite, ServiceConnect'
'RegistryWrite, ServiceConnect, DeviceConnect'
'ServiceConnect'
'ServiceConnect, DeviceConnect' (required)
secondaryKey The secondary key. string

StorageEndpointProperties

Name Description Value
connectionString The connection string for the Azure Storage account to which files are uploaded. string (required)
containerName The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. string (required)
sasTtlAsIso8601 The period of time for which the SAS URI generated by IoT Hub for file upload is valid. See: /azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. string