Search code examples
azure-resource-managerazure-servicebus-subscriptions

Using parameters in Azure Service Bus Subscription SqlFilter expression


I am using an ARM template to try and deploy a subscription to an Azure Service Bus Topic which filters messages based on the To system property. I would like to pull the value for the filter from an ARM template parameter, but I can't seem to get the template to resolve the param in the SqlExpression.

Below is the template I have been messing around with. I thought I could maybe just toggle the requiresPreprocessing switch to get it to resolve the param on deployment, but no dice. I also played with trying to escape it using double square brackets or colons as shown in the link below

https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter#propertyname

{
 "apiVersion": "2017-04-01",
 "name": "[concat(parameters('mynamespace'), '/', parameters('topic'), '/', parameters('myVariable'),'/direct')]",
 "type": "Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
 "dependsOn": [
   "[resourceId('Microsoft.ServiceBus/namespaces', parameters('mynamespace'))]",
   "[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('mynamespace'), parameters('topic'))]",
   "[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('mynamespace'), parameters('topic'), parameters('myVariable'))]"
 ],
 "properties": {
   "filterType": "SqlFilter",
   "sqlFilter": {
     "sqlExpression": "sys.To=[parameters('myVariable')] OR sys.To IS NULL",
     "requiresPreprocessing": true
     }
}

What I am getting is the string exactly as it is displayed in the sqlExpression, but I would like to get the value that the variable resolves to in a single quoted string.


Solution

  • This topic subscription rules may only get static values. Maybe you can try with a static value instead of [parameters('myVariable')]. This problem might because of giving dynamic value to the property sys.To.