Correlation filters with AND condition – Azure Service Bus

This is a short post showing how to deploy an Azure Service Bus topic and subscription with a complex correlation filter. I posted an article a few days ago showing a simpler version of the template. The example shows a correlation filter with a filter expression containing multiple system properties and a custom property. The AND operator is used to form a single condition using all the fields specified in the template.

The example is based on the ARM template sample found here.

Just showing the subscription resource for brevity. The correlation filter below is defined using two system properties correlationId and label. It also shows how to use a custom user defined property, in this case customProperty, in a filter condition. Replace the values of the filter condition to make this work for your application.

"resources": [
{
    "type": "subscriptions",
    "name": "[parameters('serviceBusTopicSubscriptionName')]",
    "apiVersion": "2017-04-01",
    "properties": {},
    "resources": [
        {
            "type": "Rules",
            "name": "[concat(parameters('serviceBusTopicSubscriptionName'), '-filter')]",
            "apiVersion": "2017-04-01",
            "properties": {
                "action": {},
                "filterType": "CorrelationFilter",
                "correlationFilter": {
                    "correlationId": "Id",
                    "label": "value",
                    "properties": {
                        "customProperty": "value"
                    }
                }
            },
            "dependsOn": [
                "[parameters('serviceBusTopicSubscriptionName')]"
            ]
        }
    ],
    "dependsOn": [
        "[parameters('serviceBusTopicName')]"
    ]
}

Leave a comment