Home:ALL Converter>Using parameters in Azure Service Bus Subscription SqlFilter expression

Using parameters in Azure Service Bus Subscription SqlFilter expression

Ask Time:2019-01-30T01:28:22         Author:gwoody1984

Json Formatter

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.

Author:gwoody1984,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/54426535/using-parameters-in-azure-service-bus-subscription-sqlfilter-expression
Nishanth Prabhakaran :

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. ",
2019-06-05T09:50:03
yy