Azure IoT Hub
Compatible with the Microsoft.Devices ARM management plane as the azurerm_iothub Terraform resource, the
azure-mgmt-iothub SDKs and the az iot hub and az iot hub policy commands use it. Floci AZ serves IoT hubs
with their shared access policies and keys. Devices, telemetry and message routing are not served yet: see
Notes & limitations.
Management plane only, for now. The device identity registry, the MQTT and AMQP device endpoints and message routing are not served. A hub's
hostNamedoes not answer requests yet.HTTP-only: no Docker. Hubs are in-process ARM state. There is no sidecar.
Features
- Hubs:
Microsoft.Devices/IotHubsCreateOrUpdate, Update (PATCH, tags only), Get, Delete, and List by resource group and by subscription. A hub isActiveandSucceededas soon as thePUTanswers; there is no provisioning delay - Shared access policies: a new hub has Azure's five default policies (
iothubowner,service,device,registryRead,registryReadWrite) with generated keys.listkeyslists them all andIotHubKeys/{keyName}/listkeysanswers one. Policies are added, changed and removed throughproperties.authorizationPolicieson aPUT, asaz iot hub policyandazurerm_iothub_shared_access_policydo - ETags: every write changes the hub's
etag. APUT,PATCHorDELETEwhoseIf-Matchnames an older one is refused with412 PreconditionFailed;*and noIf-Matchat all both pass. APUTwith an ETag for a hub that no longer exists is refused the same way, so a delayed update cannot bring a deleted hub back. AnauthorizationPoliciesthat is not a list of policy objects is refused with400 InvalidRequestContent;nullkeeps the policies - Name availability:
checkNameAvailabilityreports a taken name asAlreadyExistsand a malformed one asInvalid. Hub names are global, so a second hub with a taken name is refused with409 Conflictin any subscription - Consumer groups: the consumer groups of the built-in
eventsendpoint, asaz iot hub consumer-groupandazurerm_iothub_consumer_groupmanage them: create, show, list and delete. Every hub has$Defaultfrom its creation. The groups are names only for now: theeventsendpoint itself is not served, so nothing reads through them - Read-only views: a hub's valid SKUs (
skus), its quota metrics (quotaMetrics) and its registry statistics (IotHubStats), asaz iot hub list-skus,show-quota-metricsandshow-statsread them, and the provider's operations (/providers/Microsoft.Devices/operations) - Managed identity:
SystemAssigned,UserAssignedandSystemAssigned, UserAssigned, answered as Azure AI Search answers them. A hub without one answers"identity": {"type": "None"}
Endpoints
PUT/GET/PATCH/DELETE .../providers/Microsoft.Devices/IotHubs/{name}
GET /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Devices/IotHubs
GET /subscriptions/{sub}/providers/Microsoft.Devices/IotHubs
POST /subscriptions/{sub}/providers/Microsoft.Devices/checkNameAvailability
POST .../IotHubs/{name}/listkeys
POST .../IotHubs/{name}/IotHubKeys/{keyName}/listkeys
GET .../IotHubs/{name}/eventHubEndpoints/events/ConsumerGroups
PUT/GET/DELETE .../IotHubs/{name}/eventHubEndpoints/events/ConsumerGroups/{group}
GET .../IotHubs/{name}/skus
GET .../IotHubs/{name}/quotaMetrics
GET .../IotHubs/{name}/IotHubStats
GET /providers/Microsoft.Devices/operations
Every api-version Azure lists for Microsoft.Devices/IotHubs is accepted and served the same way.
Quickstart
Azure CLI
az group create -n my-rg -l eastus
az iot hub create -n my-hub -g my-rg --sku S1 --partition-count 2
az iot hub show -n my-hub -g my-rg --query properties.hostName -o tsv # my-hub.azure-devices.net
az iot hub policy list --hub-name my-hub -g my-rg
az iot hub policy create --hub-name my-hub -g my-rg -n backend --permissions RegistryRead ServiceConnect
az iot hub policy renew-key --hub-name my-hub -g my-rg -n backend --renew-key Primary
az iot hub update -n my-hub -g my-rg --retention-day 3
az iot hub consumer-group create --hub-name my-hub -g my-rg -n analytics
az iot hub consumer-group list --hub-name my-hub -g my-rg
az iot hub show-quota-metrics -n my-hub -g my-rg
az iot hub delete -n my-hub -g my-rg
Terraform / OpenTofu
resource "azurerm_iothub" "hub" {
name = "my-hub"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku {
name = "S1"
capacity = 1
}
}
resource "azurerm_iothub_consumer_group" "analytics" {
name = "analytics"
iothub_name = azurerm_iothub.hub.name
eventhub_endpoint_name = "events"
resource_group_name = azurerm_resource_group.rg.name
}
output "owner_key" {
value = one([for p in azurerm_iothub.hub.shared_access_policy : p.primary_key if p.key_name == "iothubowner"])
sensitive = true
}
Response shape
The shapes follow the resource-manager spec (2023-06-30) and the responses Azure gave the az CLI's iot
test recordings:
locationis the canonical name (westus2), andproperties.locationslists it as theprimaryby its display name. No secondary location is listedproperties.hostNameis{name}.azure-devices.net, from the cloud's own IoT Hub suffix underfloci-az.cloud. It is derived when the hub is read, not storedproperties.eventHubEndpoints.eventscarries thepartitionIds,pathandendpointAzure generates (sb://iothub-ns-{name}-{digits}-{hex}.servicebus.windows.net/). The names are fixed when the hub is created and kept across updates and restarts. The endpoint is not servedsubscriptionidandresourcegroupare answered as Azure answers them, in lower case- A
PUTanswers201for an update as well as a create, as Azure does. Azure answers it withprovisioningState: Acceptedand anAzure-AsyncOperationheader; floci-az completes the write first, so it answersSucceededwith no header, which ends the clients' polling at once.DELETEanswers200for a hub that existed and204for one that did not - A
GETnever carriesauthorizationPolicies: Azure sets security properties to null there, and the keys are read throughlistkeys - Connection strings the hub holds for other resources (the file-upload storage endpoint and the routing
endpoints) are answered with their secret masked, as Azure answers them:
AccountKey=****,SharedAccessKey=****andSharedAccessSignature=****. A Cosmos DB routing endpoint'sprimaryKeyandsecondaryKeyare answered as****. APUTthat sends a masked secret back keeps the stored one, which is whataz iot hub updaterelies on when it writes back the hub it read. A routing endpoint is matched by itsname, so a masked secret sent under a new name, or with nothing stored, is refused with400 InvalidRequestContentrather than stored as**** - A consumer group answers as Azure answered the az CLI:
properties.createdin RFC 1123 (Mon, 22 Sep 2025 10:49:41 GMT),etag: null, and the name URL-encoded in itsid(.../ConsumerGroups/%24Default). APUTtakes the body the spec requires,{"properties": {"name": "<name>"}}, with the path's name in any casing, and refuses any other body with400 InvalidRequestContent. Only aPUTechoes the body's name, underproperties.properties.name. The spec's examples show a stringetag; the recorded answers havenull. APUTanswers200, and aPUTof a group that exists answers it unchanged, with its creation time. Writing a group does not change the hub'setag, and a hubPUTkeeps the hub's groups - The
etagis in the body only, with noETagheader, as in Azure's recorded answers. It changes on every write, and a hub created again under a deleted hub's id never answers the deleted hub'setag
What a PUT keeps and replaces
A PUT replaces the hub. Each property it leaves out falls back to Azure's default: the events
endpoint (1 day, 4 partitions, 2 on F1), the $fallback route, an empty $default storage endpoint,
the cloud-to-device and file-notification settings, features: None, and no IP filter rules. A section
that is sent replaces its default whole, even when it is sent empty: azurerm_iothub sends
"storageEndpoints": {} for a hub without file upload, and reads a $default storage endpoint back as a
file_upload block. Read-only properties sent in the body (hostName, state, the endpoint's path)
are ignored.
The shared access policies are the exception, as az iot hub update relies on:
The PUT sends |
The policies afterwards |
|---|---|
no authorizationPolicies |
unchanged, keys included |
| a policy with its keys | that policy, with those keys |
| a policy without a key | that policy, with a new key in place of each one left out |
| a list without some existing policy | the list as sent: the missing policy is gone |
az iot hub policy renew-key relies on the third row: it sends the policy without the key to renew.
Errors
Errors the hub itself reports use the IoT Hub ErrorDetails shape with Azure's codes:
| Request | Answer |
|---|---|
F1 with a partition count other than 2, or a Basic or Standard SKU outside 2 to 32 (Learn's maximum; azurerm's own check allows 128). A hub saved by an earlier floci-az with more keeps its count, so an update that sends it back passes |
400 {"code": 400016, "httpStatusCode": 400, "message": "Invalid PartitionCount 4 - value must be between 2 and 2."} |
minTlsVersion other than 1.0 or 1.2 |
400 {"code": 400089, ...} |
The following are refused with ARM's {"error": {...}} envelope:
- a missing or unknown SKU, or more units than the SKU allows (1 on
F1, 10 onS3andB3, 200 on the others) - a SKU change Azure does not allow: a hub changes SKU within its tier, or from Basic to Standard, as
its
skuslist says - a
retentionTimeInDaysoutside 1 to 7 days (1 day onF1) - a partition count other than the one the hub was created with (a
PUTthat leaves it out keeps it) - an
identitytype outside the spec'sResourceIdentityTypevalues - rights outside the spec's
AccessRightsvalues, or a repeated policy name - a change of location
Under parity-overrides.strict-names, a hub name outside the spec's pattern (3 to 50 letters, digits and
hyphens, not all digits, no leading or trailing hyphen) is refused with 400 InvalidResourceName.
Configuration
floci-az:
services:
iothub:
enabled: true
storage:
services:
iothub:
mode: persistent # optional; follows floci-az.storage.mode by default
| Env var | Default | Description |
|---|---|---|
FLOCI_AZ_SERVICES_IOTHUB_ENABLED |
true |
Enable/disable the service |
FLOCI_AZ_STORAGE_SERVICES_IOTHUB_MODE |
global mode | Storage mode for hubs and their keys |
Notes & limitations
- No devices or messages yet. The device identity registry (
az iot hub device-identity), the device endpoints (MQTT, AMQP, HTTPS) and cloud-to-device messaging are not served, so a hub'shostNameand connection strings cannot be used by a device yet. - Routing is stored, not run.
properties.routingendpoints, routes and enrichments are kept and answered as they were sent, but nothing is routed and their references are not checked. - Consumer groups are management plane only. Nothing reads messages through them: the built-in
eventsendpoint (AMQP, asEventHubConsumerClient, the Functions IoT Hub trigger andaz iot hub monitor-eventsuse it) is not served. Only theeventsendpoint has groups: any other endpoint name answers404. A hub has at most 20,$Defaultincluded, as Learn states for every tier.$Defaultcannot be deleted. Group names are 1 to 50 letters, digits, hyphens, periods and underscores, and match ignoring case: the characters are azurerm's rule and the 50 is Event Hubs' AMQP limit, as IoT Hub's documentation states neither. - The read-only views count nothing yet.
IotHubStatsanswers zero devices and bothquotaMetricshave acurrentValueof 0, since there are no devices or messages to count. Their maximums follow the hub's SKU and units:TotalMessagesis the SKU's daily message quota per unit (8,000 onF1, 400,000 onS1andB1, 6,000,000 onS2andB2, 300,000,000 onS3andB3) times the units, andTotalDeviceCountis 1,000,000 (500 onF1).skuslists the SKUs the hub can move to, each with the units it allows: those of its own tier, as Azure answered for anS1hub (S1,S2,S3), and for a Basic hub the Standard ones after them. The Basic andF1answers (F1alone, with ascaleTypeofNone) are unrecorded.operationslists the IoT Hub entries of the spec's example, without the Device Provisioning Service's. - Not served: certificates, private endpoint connections, endpoint health, route testing, failover,
import and export of devices, and the Device Provisioning Service
(
Microsoft.Devices/provisioningServices). - Terraform waits about two minutes per hub write. After every create and update,
azurerm_iothub3.x waits a fixed minute before its firstGETand then polls once a minute, working around a404Azure can answer for a while after an update (azure-rest-api-specs#27183). That wait is in the provider, so it is the same against floci-az as against Azure. - Unverified answers. No public source gives Azure's answer to a duplicate hub name on
PUTor to a staleIf-Match, so ARM's generic409 Conflictand412 PreconditionFailedstand in. The answers to an unknown endpoint, a missing or badly named consumer group, a 21st group and a$Defaultdelete are unrecorded as well, so ARM'sNotFoundandInvalidRequestContentstand in. The codes for too many units, a SKU change Azure does not allow (any but within a tier or from Basic to Standard), a retention period out of range, a partition count change and an unknown policy onIotHubKeys/{keyName}/listkeysare unrecorded too, so ARM'sInvalidRequestContentandNotFoundstand in. Whether Azure masks Cosmos DB keys as****or leaves them out is also unrecorded.