Paramters.json

я определил фрагмент шаблона ARM, который создает тему служебной шины, подписку и правило / фильтр. Правило применяется вместе с темой и подпиской, но значение фильтра равно 1 = 1. Почему выражение не будет применено?

{
    "apiVersion": "2017-04-01",
    "name": "[concat(parameters('serviceBusNamespaceName'), '/TOPIC-NAME')]",
    "type": "Microsoft.ServiceBus/namespaces/topics",
    "location": "[variables('location')]",
    "dependsOn": [
        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
    ],
    "properties": {
        "path": "TOPIC-NAME",
        "duplicateDetectionHistoryTimeWindow": "00:10:00",
        "enableBatchedOperations": false,
        "enablePartitioning": true,
        "enableSubscriptionPartitioning": false,
        "filteringMessagesBeforePublishing": false,
        "maxSizeInMegabytes": 5120
    },
    "resources": [
        {
            "apiVersion": "2017-04-01",
            "name": "SUB-NAME",
            "type": "subscriptions",
            "dependsOn": [
                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME')]"
            ],
            "properties": {},
            "resources": [
                {
                    "apiVersion": "2017-04-01",
                    "name": "SUB-NAME",
                    "type": "Rules",
                    "dependsOn": [
                        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME/subscriptions/SUB-NAME')]"
                    ],
                    "properties": {
                        "filter": {
                            "sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
                        },
                        "action": {
                            "sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
                        }
                    }
                }
            ]
        }
    ]
}

Ответы на вопрос(2)

Решение Вопроса

Ваше правило подписки должно быть определено следующим образом:

"resources": [
                {
                  "apiVersion": "2017-04-01",
                  "name": "SUB-NAME-FILTER",
                  "type": "Rules",
                  "dependsOn": [
                    "[parameters('serviceBusSubscriptionName')]"
                  ],
                  "properties": {
                    "filterType": "SqlFilter",
                    "sqlFilter": {
                      "sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
                      "requiresPreprocessing": "false"
                    },
                    "action": {
                        "sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
                    }
                  }
                }
              ]

он корректно работает на моей стороне. Более подробную информацию мы могли бы сослаться наСоздайте пространство имен служебной шины с темой, подпиской и правилом с помощью шаблона диспетчера ресурсов Azure.

Я проверяю это с помощью Azureслужебный автобус исследовать

Deploy.json

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/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 Topic"
      }
    },
    "serviceBusSubscriptionName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Subscription"
      }
    },
    "serviceBusRuleName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Rule"
      }
    }
  },
  "variables": {
    "location": "[resourceGroup().location]",
    "defaultSASKeyName": "RootManageSharedAccessKey",
    "authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('serviceBusNamespaceName'), variables('defaultSASKeyName'))]",
    "sbVersion": "2017-04-01"
  },
  "resources": [
    {
      "apiVersion": "2017-04-01",
      "name": "[parameters('serviceBusNamespaceName')]",
      "type": "Microsoft.ServiceBus/Namespaces",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "Standard"
      },
      "properties": {},
      "resources": [
        {
          "apiVersion": "2017-04-01",
          "name": "[parameters('serviceBusTopicName')]",
          "type": "Topics",
          "dependsOn": [
            "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
          ],
          "properties": {
            "defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
            "maxSizeInMegabytes": "1024",
            "requiresDuplicateDetection": "false",
            "duplicateDetectionHistoryTimeWindow": "PT10M",
            "enableBatchedOperations": "false",
            "supportOrdering": "false",
            "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
            "enablePartitioning": "false",
            "enableExpress": "false"
          },
          "resources": [
            {
              "apiVersion": "2017-04-01",
              "name": "[parameters('serviceBusSubscriptionName')]",
              "type": "Subscriptions",
              "dependsOn": [
                "[parameters('serviceBusTopicName')]"
              ],
              "properties": {
                "lockDuration": "PT1M",
                "requiresSession": "false",
                "defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
                "deadLetteringOnMessageExpiration": "false",
                "maxDeliveryCount": "10",
                "enableBatchedOperations": "false",
                "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S"
              },
              "resources": [
                {
                  "apiVersion": "2017-04-01",
                  "name": "[parameters('serviceBusRuleName')]",
                  "type": "Rules",
                  "dependsOn": [
                    "[parameters('serviceBusSubscriptionName')]"
                  ],
                  "properties": {
                    "filterType": "SqlFilter",
                    "sqlFilter": {
                      "sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1",
                      "requiresPreprocessing": "false"
                    },
                    "action": {
                      "sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
                    },
                    "CorrelationFilter": {}
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "outputs": {
    "NamespaceConnectionString": {
      "type": "string",
      "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
    },
    "SharedAccessPolicyPrimaryKey": {
      "type": "string",
      "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]"
    }
  }
}

Paramters.json

{ 
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serviceBusNamespaceName": {
      "value": "xxxx-test"
    },
    "serviceBusTopicName": {
      "value": "armtopipc-test"
    },
    "serviceBusSubscriptionName": {
      "value": "armsubscription-test"
    },
    "serviceBusRuleName": {
      "value": "filterRule-test"
    }
  }
}

Ваш ответ на вопрос