Creating Service Bus Topic Subscription with SQL Filter using ARM Template.

0 votes

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 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": {
  }
}
Jul 3 in Azure by sabby
• 4,350 points
258 views

1 answer to this question.

0 votes

To create SQL Filter and Action, add this into your code:

,"resources": [{ 

   "apiVersion": "[variables('sbVersion')]", 

  "name": "$Default", 

  "type": "Rules", 

  "dependsOn": ["[parameters('serviceBusSubscriptionName')]"], 

  "properties": { 

    "filterType": "SqlFilter", 

    "sqlFilter": { 

        "sqlExpression": "1=1", 

        "requiresPreprocessing": false 

        }, 

    "action": { 

        "sqlExpression": "set something = 'something'" 

         } 

      } 

  }]
answered Jul 3 by Perry
• 17,020 points

Related Questions In Azure

0 votes
1 answer

How can I use “Azure File Storage” with Web App Service?

If you're looking for mapping a drive ...READ MORE

answered Aug 10, 2018 in Azure by null_void
• 3,220 points
1,394 views
0 votes
1 answer

How to import Azure SQL backup (.bacpac) to LocalDB using Visual Studio?

If you have this folder on your ...READ MORE

answered Sep 24, 2018 in Azure by null_void
• 3,220 points
330 views
0 votes
1 answer
0 votes
1 answer

Getting an error when trying to authenticate using REST API Dynamics CRM with Azure AD.

Dynamics 365 has started to support Server-to-Server ...READ MORE

answered Apr 25 in Azure by Prerna
• 1,940 points
219 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 6 in Azure by Prerna
• 1,940 points
349 views
0 votes
1 answer

Azure Storage Emulator shows error.

This blog might help with your query: http://blog.smarx.com/posts/windows-azure-storage-emulator-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process Also, ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
167 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
67 views
0 votes
1 answer

How to create a sub directory in a blob container?

There are two ways:  using the GetDirectoryReference looping through a containers ...READ MORE

answered Mar 26 in Azure by Prerna
• 1,940 points
1,243 views
0 votes
1 answer

StackExchange.Redis with Azure Redis shows error

Hey, check out the Azure Redis Cache documentation This ...READ MORE

answered Jun 27 in Azure by Perry
• 17,020 points
141 views
0 votes
1 answer

Configure Windows Azure For URL rewrite using WordPress.

You need to understand that the configuration is ...READ MORE

answered Jun 28 in Azure by Perry
• 17,020 points
220 views