|
1 | | -// Copyright (c) .NET Foundation. All rights reserved. |
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 |
|
4 | 4 | using System; |
5 | 5 | using System.Threading.Tasks; |
| 6 | +using Azure.Core; |
6 | 7 | using Azure.Messaging.ServiceBus; |
7 | 8 | using Microsoft.Extensions.Logging; |
8 | 9 |
|
@@ -58,6 +59,22 @@ public SubscriptionClientWrapper(string connectionString, string topicPath, stri |
58 | 59 | _logger = logger ?? throw new ArgumentNullException(nameof(logger)); |
59 | 60 | } |
60 | 61 |
|
| 62 | + /// <summary> |
| 63 | + /// Creates a new instance of the <see cref="SubscriptionClientWrapper"/> class using specified token credential. |
| 64 | + /// </summary> |
| 65 | + /// <param name="endpointUrl">Service bus endpoint URL (e.g. "sb://nugetdev.servicebus.windows.net/")</param> |
| 66 | + /// <param name="topicPath">Path of the topic name</param> |
| 67 | + /// <param name="name">Subscription name</param> |
| 68 | + /// <param name="tokenCredential">Credential to use.</param> |
| 69 | + /// <param name="logger"><see cref="ILogger"/> instance</param> |
| 70 | + public SubscriptionClientWrapper(Uri endpointUrl, string topicPath, string name, TokenCredential tokenCredential, ILogger<SubscriptionClientWrapper> logger) |
| 71 | + { |
| 72 | + _serviceBusClient = new ServiceBusClient(endpointUrl.Host, tokenCredential); |
| 73 | + _topicPath = topicPath ?? throw new ArgumentNullException(nameof(topicPath)); |
| 74 | + _name = name ?? throw new ArgumentNullException(nameof(name)); |
| 75 | + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); |
| 76 | + } |
| 77 | + |
61 | 78 | public async Task StartProcessingAsync(Func<IReceivedBrokeredMessage, Task> onMessageAsync) |
62 | 79 | { |
63 | 80 | await StartProcessingAsync(onMessageAsync, new OnMessageOptionsWrapper()); |
|
0 commit comments