2016-03-28 11 views
3

Azure Service Busのネームスペース、トピック、サブスクリプションを作成/管理してすべてのメッセージを受信するAzure ARMテンプレートをセットアップする方法を知ることができました。ただし、MicrosoftのドキュメントではARMテンポラリでは非常に不足しており、.NET SDKを使用して管理できるテンプレート内のサブスクリプションに対してSqlFilterを定義する方法を理解することはできません。Azure ARMテンプレートを使用して、Sqlフィルタを使用したサービスバストピックサブスクリプションを作成しますか?

ARMテンプレート内のサービスバストピックサブスクリプションにSQLフィルタを追加する方法を知っている人はいますか?

ここでSQLのフィルターなしでサービスバストピックおよびサブスクリプションを作成するための私が持っているARMテンプレートへのリンクです:

:また、ここで私が参照してるARMテンプレートのソースは

https://github.com/crpietschmann/azure-quickstart-templates/blob/101-servicebus-topic-subscription/101-servicebus-topic-subscription/azuredeploy.json

です

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/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 Service Bus Topic" 
     } 
    }, 
    "serviceBusTopicSubscriptionName": { 
     "type": "string", 
     "metadata": { 
     "description": "Name of the Service Bus Topic Subscription" 
     } 
    } 
    }, 
    "variables": { 
    "sbVersion": "2015-08-01" 
    }, 
    "resources": [ 
    { 
     "apiVersion": "[variables('sbVersion')]", 
     "name": "[parameters('serviceBusNamespaceName')]", 
     "type": "Microsoft.ServiceBus/namespaces", 
     "location": "[resourceGroup().location]", 
     "properties": { 
     }, 
     "resources": [ 
     { 
      "apiVersion": "[variables('sbVersion')]", 
      "name": "[parameters('serviceBusTopicName')]", 
      "type": "Topics", 
      "dependsOn": [ 
      "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]" 
      ], 
      "properties": { 
      "path": "[parameters('serviceBusTopicName')]" 
      }, 
      "resources": [ 
      { 
       "apiVersion": "[variables('sbVersion')]", 
       "name": "[parameters('serviceBusTopicSubscriptionName')]", 
       "type": "Subscriptions", 
       "dependsOn": [ 
       "[parameters('serviceBusTopicName')]" 
       ], 
       "properties": { 
       }, 
       "resources": [ 
       ] 
      } 
      ] 
     } 
     ] 
    } 
    ], 
    "outputs": { 
    } 
} 

答えて

3

Sqlフィルタはルール内にある必要があります。したがって、サービスバストピックサブスクリプション内にルールを作成する必要があります。たとえば:

 "resources": [ 
     { 
      "apiVersion": "[variables('sbVersion')]", 
      "name": "[parameters('serviceBusTopicSubscriptionName')]", 
      "type": "Subscriptions", 
      "dependsOn": [ 
      "[parameters('serviceBusTopicName')]" 
      ], 
      "properties": { 
      }, 
      "resources": [ 
      { 
       "apiVersion": "[variables('sbVersion')]", 
       "name": "[parameters('serviceBusTopicSubscriptionRuleName')]", 
       "type": "Rules", 
       "dependsOn": [ 
       "[parameters('serviceBusTopicSubscriptionName')]" 
       ], 
       "properties": { 
       }, 
       "resources": [ 
       ] 
      } 
      ] 
     } 
     ] 

私は、このテンプレートを展開しようとしましたが、私は次のエラーを取得:エラーメッセージから

New-AzureRmResourceGroupDeployment : InvalidTemplate: Deployment template validation failed: 'The template resource 'Microsoft.ServiceBus/namespaces/<serviceBusNamespaceName>/Topics/<serviceBusTopicName>/Subscriptions/<serviceBusTopicSubscriptionName>' cannot reference itself. Please see http://aka.ms/arm-template-expressions/#reference for usage details.'. 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment -Name ServiceBusTest -ResourceGrou ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : CloseError: (:) [New-AzureRmResourceGroupDeployment], CloudException 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand 

を、「「テンプレートリソースは、それ自体を参照することができない」、私は推測していますトピックサブスクリプションのSQLフィルタを作成することは、まだARMテンプレートに実装されていません。

もう少し掘り下げた後、私はトピック購読ルールがまだリソースマネージャによって管理できないと考えています。ここで私が試したことがあります。私はルールにトピックサブスクリプションを作成するためにthis PowerShell scriptを使用

  1. 。私は、ルールに名前を追加することによってスクリプトに若干の変更を加えました。$RuleDescription.Name = "rule1"

  2. トピックサブスクリプションは正常に作成され、次のPowerShellコマンドを使用してトピックサブスクリプションを取得できます。

    Get-AzureRmResource -ResourceGroupName Default-ServiceBus-EastUS ` 
            -ResourceType Microsoft.ServiceBus/namespaces/topics/Subscriptions ` 
            -ResourceName <namespace>/<topic>/<subscription> ` 
            -ApiVersion 2014-09-01 
    
  3. 私は同様のPowerShellコマンドを使用してトピックサブスクリプションのルールを取得しよう:私は$NamespaceManager.GetRules($TopicPath,$Name)を使用している場合、しかし、

    No HTTP resource was found that matches the request URI 
    'https://sbgm.windows.net/subscriptions/<subscriptionid>/resourceGroups/Default-ServiceBus-EastUS/providers/Microsoft.ServiceBus/namespaces/<namespace>/topics/<topic>/Subscriptions/<subscription>/Rules/rule1?api-version=2014-09-01' 
    
  4. Get-AzureRmResource -ResourceGroupName Default-ServiceBus-EastUS ` 
          -ResourceType Microsoft.ServiceBus/namespaces/topics/Subscriptions/Rules ` 
          -ResourceName <namespace>/<topic>/<subscription>/rule1 ` 
          -ApiVersion 2014-09-01 
    

    私は次のエラーを取得します、私は上記のルールを正常に取得します。つまり、ルールが正常に作成されます。

+0

ええ、それは私の知る限り...あまりにもこの上 –

2

現在、ARMテンプレートはAzure Service Busトピックサブスクリプションフィルタの作成/管理をサポートしていません。

+0

どれアップデートを入手することができたようですか?この機能が含まれているかどうかを知りたいと思っています。 –

+1

@MaheshJastiサービスバスチームがサービスバスにARMサポートを追加しようとしていることが発表されました。今年の終わりにも利用可能になるはずですから、すぐにService Bus ARMテンプレートのサポートを受けることになります。 –

1

これは、SQLフィルターを追加することを示し、次のクイックスタートテンプレートごとに可能になりました:

https://github.com/Azure/azure-quickstart-templates/blob/master/201-servicebus-create-topic-subscription-rule/azuredeploy.json

また、あなたは、ARM経由相関フィルタを追加するために探している場合は、私がすることができました次のようにRulesリソースを設定することで、そうする:

"resources": [ 
    { 
     "apiVersion": "[variables('sbVersion')]", 
     "name": "$Default", 
     "type": "Rules", 
     "dependsOn": [ 
     "[parameters('serviceBusSubscriptionName')]" 
     ], 
     "properties": { 
     "filter": { 
      "correlationId": "[parameters('correlationId')]" 
     } 
     } 
    } 
    ] 
3

ただ、SQLフィルターとアクションを作成するには、サブスクリプションのリソースに次の行を追加します。

,"resources": [{ "apiVersion": "[variables('sbVersion')]", "name": "$Default", "type": "Rules", "dependsOn": ["[parameters('serviceBusSubscriptionName')]"], "properties": { "filter": { "sqlExpression": "1=1" }, "action": { "sqlExpression": "set something = 'something'" } } }]

0

Sqlフィルタを追加するサブスクリプションの構文が最近変更されました。

<snip> 
"apiVersion": "2017-04-01", 
"name": "[parameters('serviceBusSubscriptionName')]", 
<snip> 
"resources": [ 
    { 
     "apiVersion": "2017-04-01", 
     "name": "[parameters('serviceBusRuleName')]", 
     "type": "Rules", 
     "dependsOn": [ 
     "[parameters('serviceBusSubscriptionName')]" 
     ], 
     "properties": { 
     "filterType": "SqlFilter", 
     "sqlFilter": { 
      "sqlExpression": "FilterTag = 'true'", 
      "requiresPreprocessing": "false" 
     } 
     } 
    } 
] 

あなたはこのARMテンプレートの最新の例を見つけることができます:
https://github.com/Azure/azure-quickstart-templates/blob/master/201-servicebus-create-topic-subscription-rule/azuredeploy.json

関連する問題