Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in
This guide shows you how to provision an IoT Hub against Locally. As with the other guides we're going to use the Azure CLI, but the same resources can be provisioned with HashiCorp Terraform, Pulumi or Bicep too.
az) installed.Firstly, we need to launch Locally which we can do from a terminal by running:
$
locally build
Once Locally has started, the Locally Dashboard will open automatically:
Next we can create the Resource Group:
$
locally run az group create -n sample-resources -l berlin
There's two things to note here:
locally run.locally run when you do.With the Resource Group in place, we can create the IoT Hub. The partition count is fixed at creation, so it's worth thinking about up front:
$
locally run az iot hub create -g sample-resources -n sampleiothub1 -l berlin --sku F1 --partition-count 2
{
"hostname": "sampleiothub1.iothub.locally",
"name": "sampleiothub1",
"sku": "F1",
"state": "Active"
}
Note
That iothub.locally hostname is served by Locally's own DNS server and points at the IoT Hub Emulator running on your machine.
A hub with no devices doesn't do much, and Locally has built-in helpers for managing them:
$
locally iothub device create --hub sampleiothub1 --device sensor-01
$
locally iothub device list --hub sampleiothub1
Note
locally iothub is part of Locally itself rather than a tool being configured, so it doesn't take the locally run prefix. Every az command does.Each device has a twin - the document holding its desired and reported state - which you can inspect and update:
$
locally iothub twin show --hub sampleiothub1 --device sensor-01
We can also list the hubs in the Resource Group:
$
locally run az iot hub list -g sample-resources --query "[].{Name:name, Sku:sku.name, Hostname:properties.hostName}" -o table
Finally, we can tidy up. To remove the Resource Group and everything within it:
$
locally run az group delete -n sample-resources --yes
There's nothing billable to clean up, since everything ran on your machine, but it's still worth checking your teardown scripts work here before you run them against Azure.
Whilst this guide used the Azure CLI, IoT Hub works the same way through any of the tooling that Locally supports - a Microsoft.Devices/IotHubs resource in HashiCorp Terraform or OpenTofu, Pulumi, Bicep or an ARM Template all provision against Locally in the same way, with only the location changed.
Device telemetry lands in the hub's built-in endpoint, served by Event Hubs. The IoT Hub Emulator covers what else devices can do.
Should you encounter any issues, please take a look at the troubleshooting section.
Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in
Your Azure infrastructure, running on your machine. Deploy in seconds, break things freely, and ship to Azure when you're ready.