Access Control Service を使用して、特定のサービス ID の特定の Service Bus サブスクリプションへのアクセスを承認しています。
サブスクリプションからセッションまたはメッセージを受信すると、サービス ID が承認され、必要に応じてメッセージを受信して完了または破棄できます。
ただし、UnauthorizedAccessException
サービス ID がアクセスできないサブスクリプションにアクセスしようとしても、ルール グループがそのサービス ID に対して要求を発行せず、依存している操作を実行しようとしても、この例外が表示されません。パーティー (メッセージの送信やトピックの作成など)。
代わりに、最終的にはTimeoutException - "The timeout elapsed upon attempting to obtain a token while accessing 'https://namespace-sb.accesscontrol.windows.net/WRAPv0.9/'"
. 内部例外はSecurityTokenException - "The token provider was unable to provide a security token while accessing 'https://namespace-sb.accesscontrol.windows.net/WRAPv0.9/'. Token provider returned message: 'The operation has timed out'"
. タイムアウト例外は一時的なものと見なされるため、これは RetryPolicy に問題を引き起こします。
しかし奇妙なことにUnauthorizedAccessException
、サブスクリプションの説明を受信しようとすると、 が表示されます。Rights Required for Service Bus Operationsに従って、 ...myTopic/Subscriptions/mySubscription スコープ内のリッスン クレームを持つサービス ID で使用できる必要があるもの。
私は次の設定をしています:
- サービス ID: testidentity
- ルール グループ:
- Service Bus の既定のルール グループ
- 3 つのルール、入力クレーム: 所有者、出力クレーム: 管理、送信、リッスン
- http://namespace.servicebus.windows.net/myTopicのルール グループ
- 何でもあり
- http://namespace.servicebus.windows.net/myTopic/Subscriptionsのルール グループ
- 何でもあり
- http://namespace.servicebus.windows.net/myTopic/Subscriptions/mySubscriptionのルール グループ
- 1 つのルール: 入力クレーム: testidentity、出力クレーム: Listen
- Service Bus の既定のルール グループ
- 依拠当事者アプリケーション:
- レルム: http://namespace.servicebus.windows.net/myTopic/Subscriptions/mySubscription
- トークン形式: SWT
- トークンの有効期間: 10800
- ID プロバイダー: なし (ACS)
- 上記のすべてのルール グループに関連付けられています
次の問題が発生しています。
var manager = NamespaceManager.CreateFromConnectionString("Endpoint=sb://namespace.servicebus.windows.net/;SharedSecretIssuer=testidentity;SharedSecretValue=SSdtIE5vdCBUZWxsaW5n=");
var description = manager.GetSubscription("myTopic","mySubscription");
結果として、UnauthoriszedAccessException - "The remote server returned an error: (401) Unauthorized."
この例外を受け取るのではなく、説明を取得できることが期待されます。興味深いのは、これが ID がアクセスできる唯一の領域であり、UnauthorizedAccessException が表示される唯一の時間であるということです。
var subscriptions = manager.GetSubscriptions("myTopic");
タイプTimeoutException
の内部例外を伴う になりSecurityTokenException
ます。ここに期待しUnauthorizedAccessException
ます。
var client = SubscriptionClient.CreateFromConnectionString("Endpoint=sb://namespace.servicebus.windows.net/;SharedSecretIssuer=testidentity;SharedSecretValue=SSdtIE5vdCBUZWxsaW5n=", "myTopic", "otherSubscription");
var message = client.Receive()
メッセージは になりますがnull
、やはり . が期待されますUnauthorizedAccessException
。出力を調べると、出力ウィンドウで例外が発生していることがわかりますが、クライアントによって飲み込まれています。
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.ServiceBus.TokenProviderHelper.InternalSecurityTokenException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.TimeoutException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.TimeoutException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.TimeoutException' occurred in Microsoft.ServiceBus.dll
A first chance exception of type 'System.TimeoutException' occurred in Microsoft.ServiceBus.dll
同様に、トピックの作成やメッセージの送信などを試みると、TimeoutException
.
サービス ID がアクセスできないレルムにアクセスしようとした場合、これは正しい動作UnauthorizedAccessException
でしょうか?
セットアップによって望ましい結果が得られたと思います。ID は、Listen ルールが関連付けられているサブスクリプション レルムによって識別されるサブスクリプション以外のサブスクリプションをリッスンできませんが、エラー フィードバックが明確でないことが懸念されます。継続的な再試行が発生します。
どんなアドバイスでも大歓迎です。