This post was most recently updated on June 13th, 2022.
2 min read.One more article before Christmas! 😁 This time, I’ll be fixing a function that’s triggering based on new messages received through my IoT Hub in my Azure Functions project. Technically speaking, this is super simple to implement – your function needs to define an IoTHubTrigger, with an Event Hub name and usually a Connection String (I don’t know why I’m Sentence Casing that, too, but I’ll stick to it!)
You can tap a practically unlimited number of Azure Function triggers to any Event Hubs (or Azure IoT Hubs), right? Well – yeah, that’s what it looks like, but actually, you can’t. Not without an additional configuration step, that is!
But before getting into the configuration, let’s take a better look at the actual error we’re running into!
Problem
So while trying to run your Azure Functions project with debugging enabled, you’ll run into an annoying issue where the function fails to start and throws an error somewhat like the below:
[2021-07-02T09:55:05.076Z] EventProcessorHost error (Action='Checking Leases', HostName='8cc55fad-d313-434d-b663-2b96bbc9efa1', PartitionId='1'). [2021-07-02T09:55:05.078Z] Microsoft.WindowsAzure.Storage: Server encountered an internal error. Please try again after some time. [2021-07-02T09:55:08.673Z] Host lock lease acquired by instance ID '000000000000000000000000D3CDE7D8'.
Or in the CLI itself:

What do?
Reason
Your Azure Functions are trying to tap into an IoT Hub to fire on an EventHubTrigger – and failing due to a conflict in Consumer Groups. See – each Azure Function trigger essentially needs a separate Consumer Group.
Yeah, it’s an absolutely abysmal error message. But that’s ok – you’re here now, and I’ve got the solution! ;)
Actually, I’ve got 2 solutions (because it could also be your storage emulator messing up). So listen up.
Solution
Below, I’m outlining the steps that have always helped me to fix this particular issue. The first step is just to restart your Azure Storage Emulator/Explorer (if you’re using one), and if that doesn’t help, (re)configure your IoT Hub’s Consumer Groups.
That said, let’s get to it!
Time needed: 30 minutes
How to fix “Microsoft.WindowsAzure.Storage: Server encountered an internal error.”?
- Restart your Azure Storage Explorer
Let’s get the obvious one first – if this works, you don’t need to go through all the rest of the steps!
If your Azure Storage Explorer (or Azurite, if that’s what you’re using) is borked, restart it. Maybe it’ll fix the issue and you’ll be good!
It didn’t? Thought it might not – check out the next steps, then! - Create a new Consumer Group for your Iot Hub
Navigate to Azure IoT Hub, and “Built-in Endpoints” under it. On that blade/tab, you should see something like below – create a new consumer group by entering a new alphanumeric value (hyphens supported) in the field and saving the changes.
- Add a new application setting for your Consumer Group
Now you’ll need to tell your Azure Function the name of the consumer group you want it to use.
Something like this:"Values": {
"AzureIoTHubConsumerGroupName": "MyCustomConsumerGroup"
} - Add the “ConsumerGroup” parameter to your trigger (if it doesn’t exist already)
In code, this will look somewhat like the below:
public static Task Run(
[IoTHubTrigger("events",
Connection = "EventHubConnectionAppSetting",
ConsumerGroup = "%AzureIoTHubConsumerGroupName%"
)] EventData myEventHubMessage)
And that should be it! Did it resolve your issue? Still, having issues? Let me know in the comments -section below!
References
- https://github.com/Azure/azure-functions-eventhubs-extension/issues/4
- https://www.codewithadam.com/trigger-azure-functions-on-event-hub/
- https://stackoverflow.com/questions/66043636/azure-iot-hub-azure-function-consumer-group-issue
- Dev Drive performance increase in real life scenarios? - February 4, 2025
- Join my session at CTTT25 this week: Level Up Your Teams Extensibility Game with Blazor | Session materials from Cloud Technology Townhall Tallinn 2025! - January 28, 2025
- How to identify which wifi band your Decos are using? - January 21, 2025