Azure ARM: Create Event Grid with Service Bus Queue Subscription

Create an Event Grid Custom Topic and Service Bus Queue Subscription on Azure with ARM Template

Table of Contents

1 Objective
2 ARM Template
3 Deployment
4 Event Grid in Azure Portal

1 Objective

Messages have to be distributed to different receivers asynchronously.

Azure Event Grid Topic receives the message and the Azure Event Grid Subscription forwards it to Azure Service Bus Queue.

2 ARM Template

The Azure ARM Template creates an Event Grid Topic with a dependency to the Service Bus. Please find a detailed description at Microsoft.EventGrid topics template reference.

{
  "name": "[parameters('eventGridTopicName')]",
  "type": "Microsoft.EventGrid/topics",
  "location": "[parameters('location')]",
  "apiVersion": "2020-06-01",
  "dependsOn": [
    "[resourceId('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
  ]
}

The following extract creates the Event Grid Subscription with the ServiceBusQueue endpoint. Please find a detailed description at Microsoft.EventGrid eventSubscriptions template reference.

{
  "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
  "name": "[concat(parameters('eventGridTopicName'), '/Microsoft.EventGrid/', parameters('eventGridSubscriptionName'))]",
  "apiVersion": "2020-01-01-preview",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[resourceId('Microsoft.EventGrid/topics/', parameters('eventGridTopicName'))]"
  ],
  "properties": {
    "destination": {
      "endpointType": "ServiceBusQueue",
      "properties": {
        "resourceId": "[resourceId('Microsoft.ServiceBus/namespaces/queues/', parameters('serviceBusNamespaceName'),  parameters('serviceBusQueueName'))]"
      }
    },
    "eventDeliverySchema": "EventGridSchema",
    "filter": {
      "isSubjectCaseSensitive": false
    }
  }
}

The complete ARM Template can be found in the GitHub Azure / azure-quickstart-templates.

3 Deployment

Azure CLI:

az deployment group create --resource-group "EvalGrid" --name grid  --template-file .\azuredeploy.json --parameters "@azuredeploy.parameters.json"

Deploy To Azure

4 Event Grid in Azure Portal

The Event Grid can found in Azure Portal.

grid-queue.png

No Comments Yet