Home:ALL Converter>Use Azure ARM Template to create Service Bus Topic Subscription with Sql Filter?

Use Azure ARM Template to create Service Bus Topic Subscription with Sql Filter?

Ask Time:2016-03-29T03:48:08         Author:Chris Pietschmann

Json Formatter

I've been able to figure out how to setup an Azure ARM Template that creates/manages an Azure Service Bus Namespace, Topic and Subscription to receive all messages. However, the Microsoft documentation is extremely lacking still on ARM Tempates, and I am unable to figure out how to define a SqlFilter for the Subscription within the template that you can manage using the .NET SDK.

Does anyone know how to add a Sql Filter to a Service Bus Topic Subscription within an ARM Template?

Here's a link to the ARM Template I have for creating the Service Bus Topic and Subscription without Sql filter:

https://github.com/crpietschmann/azure-quickstart-templates/blob/101-servicebus-topic-subscription/101-servicebus-topic-subscription/azuredeploy.json

Also, here's the source of the ARM Template I'm referring to:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serviceBusNamespaceName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus Namespace"
      }
    },
    "serviceBusTopicName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus Topic"
      }
    },
    "serviceBusTopicSubscriptionName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus Topic Subscription"
      }
    }
  },
  "variables": {
    "sbVersion": "2015-08-01"
  },
  "resources": [
    {
      "apiVersion": "[variables('sbVersion')]",
      "name": "[parameters('serviceBusNamespaceName')]",
      "type": "Microsoft.ServiceBus/namespaces",
      "location": "[resourceGroup().location]",
      "properties": {
      },
      "resources": [
        {
          "apiVersion": "[variables('sbVersion')]",
          "name": "[parameters('serviceBusTopicName')]",
          "type": "Topics",
          "dependsOn": [
            "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
          ],
          "properties": {
            "path": "[parameters('serviceBusTopicName')]"
          },
          "resources": [
            {
              "apiVersion": "[variables('sbVersion')]",
              "name": "[parameters('serviceBusTopicSubscriptionName')]",
              "type": "Subscriptions",
              "dependsOn": [
                "[parameters('serviceBusTopicName')]"
              ],
              "properties": {
              },
              "resources": [
              ]
            }
          ]
        }
      ]
    }
  ],
  "outputs": {
  }
}

Author:Chris Pietschmann,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36269935/use-azure-arm-template-to-create-service-bus-topic-subscription-with-sql-filter
Nido :

Just add following into your subscription resource to create SQL Filter and Action:\n\n,\"resources\": [{\n \"apiVersion\": \"[variables('sbVersion')]\",\n \"name\": \"$Default\",\n \"type\": \"Rules\",\n \"dependsOn\": [\"[parameters('serviceBusSubscriptionName')]\"],\n \"properties\": {\n \"filterType\": \"SqlFilter\",\n \"sqlFilter\": {\n \"sqlExpression\": \"1=1\",\n \"requiresPreprocessing\": false\n },\n \"action\": {\n \"sqlExpression\": \"set something = 'something'\"\n }\n }\n }]",
2016-12-27T20:53:50
yy