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, 2019 in Azure by sabby
• 4,370 points
3,924 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, 2019 by Perry
• 17,100 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 11, 2018 in Azure by null_void
• 3,220 points
4,240 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
2,438 views
0 votes
1 answer

How to add a body to a HttpWebRequest that is being used with the Azure Service management API?

The following code should help: byte[] buf = ...READ MORE

answered Apr 3, 2019 in Azure by Prerna
• 1,960 points
2,653 views
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, 2019 in Azure by Prerna
• 1,960 points
2,576 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

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

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,787 views
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,709 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

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

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,766 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, 2019 in Azure by Prerna
• 1,960 points
12,571 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 28, 2019 in Azure by Perry
• 17,100 points
2,762 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, 2019 in Azure by Perry
• 17,100 points
3,570 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP