1

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.

gwoody1984
  • 315
  • 3
  • 16

2 Answers2

0

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.

  • 1
    I was looking to have the parameter value resolve when it was being deployed. This would mean that the ARM template had the variable but not the actual deployed filter. In any event, I did wind up putting a static value in the filter – gwoody1984 Jun 06 '19 at 13:29
0

You could use: "[concat('sys.To=',[parameters('myVariable')],' OR sys.To IS NULL')]".

You cannot use inline expressions in an ARM template I think, therefor you should make the whole thing an expression and in this case use concat to glue the parts together.

Hint: including single quotes is difficult, so a variable like this might come in handy:

"SQ": "'"

Edwin
  • 527
  • 7
  • 15