question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ARM Templates for Event Subscriptions

See original GitHub issue

Hi 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.

image

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…:

image

…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:

image

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:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
ahamad-MScommented, Aug 16, 2019

Hello @ciappara

Thanks for reporting this issue. I can see a couple of issue in the template you are using:

  1. type should should be specified and have value: “Microsoft.Devices/IotHubs/providers/eventSubscriptions”,

  2. 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

0reactions
syamkp1986commented, Jun 17, 2019

Hi Clive Ciappara ,

Could you find any solution for this? I am also struggling with the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.EventGrid eventSubscriptions
Creates an Azure Event Grid custom topic and a service bus topic subscription. Template originally authored by Markus Meyer.
Read more >
azure - Event subscription by ARM template for topic with ...
I am trying to create an event grid topic ...
Read more >
Azure Event Grid · Community
Support Event Grid subscriptions at Management Group level ... You can use this to create an ARM-style JSON template for the subscription.
Read more >
Deploying an Event Grid + WebHook with ARM
Being a fan of Azure Resource Manager templates, I soon tried to ... An Event Grid topic resource; A WebHook-based event subscription.
Read more >
ARM Template for Event Grid integration with a new Azure ...
I finally got the domain topic subscriptions to work. The key notes from this snippet is the name and type, the name must...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found