ARM Templates for Event Subscriptions
See original GitHub issueHi everyone,
I’m having an issue with ARM Templates. I’m adding an Event Subscription in IoT Hub, from the Events tab, to receive the Device Connected and Disconnected events.
That works fine, but I want to create the Event Subscriptions using an ARM Template.
From the resource group, the Automation Script is not updated after that the Event Subscription is created, so I cannot get the ARM template configuration that creates the event subscriptions.
What I tried as well, was to copy the configuration from the Advanced Editor when creating a new Event Subscription…:
…and added it as part of the ARM template:
"type": "Microsoft.EventGrid/eventSubscriptions",
"location": "westeurope",
"apiVersion": "2018-09-15-preview",
"name": "ConnectionStateEventSubscription",
"properties": {
"topic": "/subscriptions/xxxxx-xxxx-xxx-xxxxx/resourceGroups/resource-group/providers/Microsoft.Devices/IotHubs/iot-hub",
"destination": {
"endpointType": "WebHook",
"properties": {
"endpointUrl": "https://url-to.endpoint/webhook"
}
},
"filter": {
"includedEventTypes": [
"Microsoft.Devices.DeviceConnected",
"Microsoft.Devices.DeviceDisconnected"
],
"advancedFilters": []
},
"labels": [],
"eventDeliverySchema": "EventGridSchema"
But it was unsuccessful and when running the ARM template from Visual Studio (through Powershell) I’m receiving the following error:
How should the configuration in the ARM templates be set to create Event Subscriptions in an IoT Hub?
Thank you in advance, Clive
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top GitHub Comments
Hello @ciappara
Thanks for reporting this issue. I can see a couple of issue in the template you are using:
type should should be specified and have value: “Microsoft.Devices/IotHubs/providers/eventSubscriptions”,
name should take the format: “[IotHubName]/Microsoft.EventGrid/[EventSubscriptionName]” and not the event subscription name only
Please use the following template to create an Event Subscription to an IOT Hub (derived from this template for creating event subscription to storage account posted here: https://github.com/Azure/azure-quickstart-templates/blob/master/101-event-grid-subscription-and-storage/azuredeploy.json). This template uses event hub as destination but you can replace that with webhook too.
{ “$schema”: “https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”, “contentVersion”: “1.0.0.0”, “resources”: [ { “type”: “Microsoft.Devices/IotHubs/providers/eventSubscriptions”, “name”: “[IotHubName]/Microsoft.EventGrid/[EventSubscriptionName]”, “apiVersion”: “2018-01-01”, “properties”: { “topic”: “/subscriptions/[SubscriptionID]/resourcegroups/[ResourceGroup]/providers/Microsoft.Devices/IotHubs/[IotHubName]”, “destination”: { “endpointType”: “EventHub”, “properties”: { “resourceId”: “/subscriptions/[SubscriptionId]/resourceGroups/[ResourceGroup]/providers/Microsoft.EventHub/namespaces/[EventHubNameSpace]/eventhubs/[EventHubName]” } }, “filter”: { “subjectBeginsWith”: “xyz”, “subjectEndsWith”: “vwx”, “isSubjectCaseSensitive”: true, “includedEventTypes”: [ “Microsoft.Devices.DeviceCreated”, “Microsoft.Devices.DeviceDeleted” ], “advancedFilters”: [] }, “labels”: [], “eventDeliverySchema”: “EventGridSchema”
} } ] }
Please let us know if you still hit any more issues. thanks
Hi Clive Ciappara ,
Could you find any solution for this? I am also struggling with the same issue.