[英]ARM template : Multiple rules(filters) with in an subscription
Hi I am working on creating service bus, topics, subscription and filters using ARM template.您好我正在使用 ARM 模板创建服务总线、主题、订阅和过滤器。 I have created all but the issue I am facing is in creating multiple filter with in an subscription.我已经创建了所有内容,但我面临的问题是在订阅中创建多个过滤器。 here is the snippet from template that I am using这是我正在使用的模板的片段
"copy": {
"name": "subscriptions-outer-loop",
"count": "[length(parameters('topics'))]"
},
"name": "[concat(parameters('serviceBus').name,'-subscriptions')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-10-01",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"parameters": {
"serviceBus": {
"value": "[parameters('serviceBus').name]"
},
"currentTopic": {
"value": "[parameters('topics')[copyIndex()]]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBus": { "type": "string" },
"currentTopic": { "type": "object" }
},
"resources": [
{
"copy": {
"name": "subscriptions-inner-loop",
"count": "[length(parameters('currentTopic').subscriptions)]"
},
"name": "[concat(
parameters('serviceBus'),'/',
parameters('currentTopic').name, '/',
parameters('currentTopic').subscriptions[copyIndex()].name)]",
"type": "Microsoft.ServiceBus/namespaces/topics/subscriptions",
"apiVersion": "2017-04-01",
"properties": {
"forwardTo":"[parameters('currentTopic').subscriptions[copyIndex()].queueName]"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('currentTopic').subscriptions[copyIndex()].name,'1234')]",
"type": "Rules",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions',
parameters('serviceBus'),
parameters('currentTopic').name, parameters('currentTopic').subscriptions[copyIndex()].name)]"
],
"properties": {
"filterType": "CorrelationFilter",
"correlationFilter": {
"correlationId":"[parameters('currentTopic').subscriptions[copyIndex()].filter]"
}
}
}
]
}
]
}
},
"dependsOn": [ "topics-loop" ]
},
It is able to crate single filter, but I am not able to manage it for the multiple filters.它能够创建单个过滤器,但我无法为多个过滤器管理它。
below is how my parameter file looks like:下面是我的参数文件的样子:
"value": [
{
"name": "ka-integration",
"subscriptions": [
{
"name":"email_notify",
"queueName":"notification",
"filter":["email_notification"]
},
{
"name":"onboard-organization",
"queueName":"onboard-organization",
"filter":["onboard_organization"]
},
{
"name":"sync-user",
"queueName":"sync-user",
"filter":["sync_user"]
},
{
"name":"master-data",
"queueName":"sync-master-data",
"filter":["sync_master_data"]
},
{
"name":"onboard_user",
"queueName":"onboard-user",
"filter":["user_onboard","onboard-organization"]
}
]
}
]
}
In working stage above filter is string, but as I want it multiple I have changed this to an array, but not able to implement loop.在上面的工作阶段,过滤器是字符串,但由于我想要它多个,我已将其更改为数组,但无法实现循环。
Any help or path suggestion are welcome.欢迎任何帮助或路径建议。
Thanks谢谢
@robo98 You need to add multiple properties of type Microsoft.ServiceBus/namespaces/topics/subscriptions/rules for the same subscription. @robo98 您需要为同一订阅添加多个Microsoft.ServiceBus/namespaces/topics/subscriptions/rules类型的属性。
In the below example I have define two rules for the same subscription 'mysubscriptionname' for the topic 'mytopicname'.在下面的示例中,我为主题“mytopicname”的同一订阅“mysubscriptionname”定义了两个规则。
The filter1 if of type SqlFilter type and filter2 is of type CorrelationFilter. filter1 if 属于 SqlFilter 类型,而 filter2 属于 CorrelationFilter 类型。 Similarly, you can define n number of filters just by defining properties of type Microsoft.ServiceBus/namespaces/topics/subscriptions/rules同样,您只需定义 Microsoft.ServiceBus/namespaces/topics/subscriptions/rules 类型的属性即可定义 n 个过滤器
{
"type":"Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
"apiVersion":"2021-06-01-preview",
"name":"[concat(parameters('namespaces_name'), '/mytopicname/mysubscriptionname/filter1')]",
"location":"UK West",
"dependsOn":[
"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('namespaces_name'), 'mytopicname', 'mysubscriptionname')]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('namespaces_name'), 'mytopicname')]",
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_name'))]"
],
"properties":{mysubscriptionname
"action":{
},
"filterType":"SqlFilter",
"sqlFilter":{
"sqlExpression":"1=1",
"compatibilityLevel":20
}
}
},
{
"type":"Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
"apiVersion":"2021-06-01-preview",
"name":"[concat(parameters('namespaces_name'), '/mytopicname/mysubscriptionname/filter2')]",
"location":"UK West",
"dependsOn":[
"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('namespaces_name'), 'mytopicname', 'mysubscriptionname')]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('namespaces_name'), 'mytopicname')]",
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_name'))]"
],
"properties":{
"action":{
},
"filterType":"CorrelationFilter",
"correlationFilter":{
"correlationId":"mycorrelationId",
"label":"mylabelname",
"properties":{
}
}
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.