From 530b2277b3edacc3b09cb75f44c64cd65e578049 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Tue, 11 Feb 2025 06:53:27 +0100 Subject: [PATCH 1/4] chore(deps): deprecate arcus.security references in service-bus projects --- .../AzureServiceBusClient.cs | 1 + .../AzureServiceBusMessagePumpSettings.cs | 46 +++++++++++++++++++ ...AzureServiceBusManagementAuthentication.cs | 1 + .../IServiceCollectionExtensions.cs | 14 ++++++ ...AzureServiceBusManagementAuthentication.cs | 4 +- .../AzureClientFactoryBuilderExtensions.cs | 2 + 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusClient.cs b/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusClient.cs index 00e6cdb0..c3a07b30 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusClient.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusClient.cs @@ -9,6 +9,7 @@ namespace Arcus.Messaging.Pumps.ServiceBus /// /// Represents a client to interact with a Azure Service Bus. /// + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to construct " + nameof(ServiceBusManagementClient) + " instances which can rotate Azure Service bus keys")] public class AzureServiceBusClient { private readonly IAzureServiceBusManagementAuthentication _authentication; diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/Configuration/AzureServiceBusMessagePumpSettings.cs b/src/Arcus.Messaging.Pumps.ServiceBus/Configuration/AzureServiceBusMessagePumpSettings.cs index 5a948e82..33a3b03f 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/Configuration/AzureServiceBusMessagePumpSettings.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/Configuration/AzureServiceBusMessagePumpSettings.cs @@ -24,6 +24,51 @@ public class AzureServiceBusMessagePumpSettings private readonly TokenCredential _tokenCredential; private readonly IServiceProvider _serviceProvider; + /// + /// Initializes a new instance of the class. + /// + /// The name of the entity to process. + /// The name of the subscription to process. + /// The entity type of the Azure Service Bus. + /// The function to look up the connection string from the configuration. + /// The options that influence the behavior of the . + /// The collection of services to use during the lifetime of the . + /// + /// Thrown when the , or is null. + /// + public AzureServiceBusMessagePumpSettings( + string entityName, + string subscriptionName, + ServiceBusEntityType serviceBusEntity, + Func getConnectionStringFromConfigurationFunc, + AzureServiceBusMessagePumpOptions options, + IServiceProvider serviceProvider) + { + if (serviceBusEntity is ServiceBusEntityType.Topic && string.IsNullOrWhiteSpace(subscriptionName)) + { + throw new ArgumentException("Requires a non-blank Azure Service bus topic subscription name", nameof(subscriptionName)); + } + + if (getConnectionStringFromConfigurationFunc is null) + { + throw new ArgumentNullException(nameof(getConnectionStringFromConfigurationFunc)); + } + + if (!Enum.IsDefined(typeof(ServiceBusEntityType), serviceBusEntity) || serviceBusEntity is ServiceBusEntityType.Unknown) + { + throw new ArgumentException( + $"Azure Service Bus entity type should either be '{ServiceBusEntityType.Queue}' or '{ServiceBusEntityType.Topic}'", nameof(serviceBusEntity)); + } + + _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); + _getConnectionStringFromConfigurationFunc = getConnectionStringFromConfigurationFunc; + + EntityName = entityName; + SubscriptionName = subscriptionName; + ServiceBusEntity = serviceBusEntity; + Options = options ?? throw new ArgumentNullException(nameof(options)); + } + /// /// Initializes a new instance of the class. /// @@ -38,6 +83,7 @@ public class AzureServiceBusMessagePumpSettings /// /// Thrown when the nor the is available. /// + [Obsolete("Will be removed in v3.0, please use the other constructor without the " + nameof(ISecretProvider))] public AzureServiceBusMessagePumpSettings( string entityName, string subscriptionName, diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/DefaultAzureServiceBusManagementAuthentication.cs b/src/Arcus.Messaging.Pumps.ServiceBus/DefaultAzureServiceBusManagementAuthentication.cs index b6f45928..1b47c19e 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/DefaultAzureServiceBusManagementAuthentication.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/DefaultAzureServiceBusManagementAuthentication.cs @@ -11,6 +11,7 @@ namespace Arcus.Messaging.Pumps.ServiceBus /// /// Represents the authentication with the Azure Service Bus. /// + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to construct " + nameof(ServiceBusManagementClient) + " instances")] public class DefaultAzureServiceBusManagementAuthentication : IAzureServiceBusManagementAuthentication { private readonly string _clientId, _clientSecretKey, _subscriptionId, _tenantId; diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/Extensions/IServiceCollectionExtensions.cs b/src/Arcus.Messaging.Pumps.ServiceBus/Extensions/IServiceCollectionExtensions.cs index 22b482e8..62c2a063 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/Extensions/IServiceCollectionExtensions.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/Extensions/IServiceCollectionExtensions.cs @@ -30,6 +30,7 @@ public static class IServiceCollectionExtensions /// The function to look up the connection string scoped to the Azure Service Bus Queue from the secret store. /// The capability to configure additional options on how the message pump should behave. /// Thrown when the or is null. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( this IServiceCollection services, Func> getConnectionStringFromSecretFunc, @@ -85,6 +86,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( /// The capability to configure additional options on how the message pump should behave. /// Thrown when the is null. /// Thrown when the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( this IServiceCollection services, string secretName, @@ -119,6 +121,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( /// The capability to configure additional options on how the message pump should behave. /// Thrown when the is null. /// Thrown when the or is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( this IServiceCollection services, string queueName, @@ -159,6 +162,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( /// Thrown when the or is null. /// /// Thrown when the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( this IServiceCollection services, string queueName, @@ -284,6 +288,7 @@ private static ServiceBusMessageHandlerCollection AddServiceBusQueueMessagePump( /// The capability to configure additional options on how the message pump should behave. /// Thrown when the is null. /// Thrown when the or is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( this IServiceCollection services, string subscriptionName, @@ -322,6 +327,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( /// Thrown when the or the is null. /// /// Thrown when the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( this IServiceCollection services, string subscriptionName, @@ -387,6 +393,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( /// /// Thrown when the , the , or the is blank. /// + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( this IServiceCollection services, string topicName, @@ -423,6 +430,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( /// The capability to configure additional options on how the message pump should behave. /// Thrown when the or is null. /// Thrown when the or the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePump( this IServiceCollection services, string topicName, @@ -537,6 +545,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpUs /// The capability to configure additional options on how the message pump should behave. /// Thrown when the is null. /// Thrown when the or the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWithPrefix( this IServiceCollection services, string subscriptionPrefix, @@ -574,6 +583,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWi /// The capability to configure additional options on how the message pump should behave. /// Thrown when the or the is null. /// Thrown when the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWithPrefix( this IServiceCollection services, string subscriptionPrefix, @@ -643,6 +653,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWi /// /// Thrown when the , the , or the is blank. /// + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWithPrefix( this IServiceCollection services, string topicName, @@ -686,6 +697,7 @@ public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWi /// The capability to configure additional options on how the message pump should behave. /// Thrown when the or the is null. /// Thrown when the or the is blank. + [Obsolete("Will be removed in v3.0, please use other overload without " + nameof(ISecretProvider) + " requirement")] public static ServiceBusMessageHandlerCollection AddServiceBusTopicMessagePumpWithPrefix( this IServiceCollection services, string topicName, @@ -885,8 +897,10 @@ private static ServiceBusMessageHandlerCollection AddServiceBusMessagePump( AzureServiceBusMessagePumpSettings settings; if (tokenCredential is null) { +#pragma warning disable CS0618 // Type or member is obsolete: will use other overload in v3.0. settings = new AzureServiceBusMessagePumpSettings( entityName, subscriptionName, serviceBusEntity, getConnectionStringFromConfigurationFunc, getConnectionStringFromSecretFunc, options, serviceProvider); +#pragma warning restore CS0618 // Type or member is obsolete } else { diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/IAzureServiceBusManagementAuthentication.cs b/src/Arcus.Messaging.Pumps.ServiceBus/IAzureServiceBusManagementAuthentication.cs index bca25c94..ab7e4b10 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/IAzureServiceBusManagementAuthentication.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/IAzureServiceBusManagementAuthentication.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Microsoft.Azure.Management.ServiceBus; namespace Arcus.Messaging.Pumps.ServiceBus @@ -6,6 +7,7 @@ namespace Arcus.Messaging.Pumps.ServiceBus /// /// Represents the contract on how to authenticate with the Azure Service Bus. /// + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to construct " + nameof(ServiceBusManagementClient) + " instances")] public interface IAzureServiceBusManagementAuthentication { /// diff --git a/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs b/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs index bd51fb9f..7b0616fe 100644 --- a/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs +++ b/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs @@ -29,6 +29,7 @@ public static class AzureClientFactoryBuilderExtensions /// Thrown when the is blank. /// Thrown when the Arcus secret store is not registered. /// Thrown when no Azure EventHubs connection string secret was found in the Arcus secret store. + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to register a " + nameof(ServiceBusClient) + " to remove the " + nameof(ISecretProvider) + " requirement")] public static IAzureClientBuilder AddServiceBusClient( this AzureClientFactoryBuilder builder, string connectionStringSecretName) @@ -51,6 +52,7 @@ public static IAzureClientBuilder Add /// Thrown when the is blank. /// Thrown when the Arcus secret store is not registered. /// Thrown when no Azure EventHubs connection string secret was found in the Arcus secret store. + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to register a " + nameof(ServiceBusClient) + " to remove the " + nameof(ISecretProvider) + " requirement")] public static IAzureClientBuilder AddServiceBusClient( this AzureClientFactoryBuilder builder, string connectionStringSecretName, From 41f650e768773265bdb4dd531032bf8260da324c Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Tue, 11 Feb 2025 08:40:42 +0100 Subject: [PATCH 2/4] docs(sb): remove secret store mentioning + promote managed identity --- .../02-message-handling/01-service-bus.md | 73 +++++-------------- .../02-Features/04-service-bus-extensions.md | 26 ------- .../02-Features/06-general-messaging.md | 6 +- 3 files changed, 21 insertions(+), 84 deletions(-) diff --git a/docs/preview/02-Features/02-message-handling/01-service-bus.md b/docs/preview/02-Features/02-message-handling/01-service-bus.md index a49c19b0..d34939fd 100644 --- a/docs/preview/02-Features/02-message-handling/01-service-bus.md +++ b/docs/preview/02-Features/02-message-handling/01-service-bus.md @@ -65,14 +65,14 @@ public class Startup public void ConfigureServices(IServiceCollection services) { // Add Service Bus Queue message pump and use OrdersMessageHandler to process the messages - // - ISecretProvider will be used to lookup the connection string scoped to the queue for secret ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING - services.AddServiceBusQueueMessagePump("ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING") + services.AddServiceBusQueueMessagePumpUsingManagedIdentity( + "", "",) .WithServiceBusMessageHandler(); // Add Service Bus Topic message pump and use OrdersMessageHandler to process the messages on the 'My-Subscription-Name' subscription // - Topic subscriptions over 50 characters will be truncated - // - ISecretProvider will be used to lookup the connection string scoped to the queue for secret ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING - services.AddServiceBusTopicMessagePump("My-Subscription-Name", "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING") + services.AddServiceBusTopicMessagePumpUsingManagedIdentity( + "", "", "") .WithServiceBusMessageHandler(); // Note, that only a single call to the `.WithServiceBusMessageHandler` has to be made when the handler should be used across message pumps. @@ -80,9 +80,7 @@ public class Startup } ``` -In this example, we are using the Azure Service Bus message pump to process a queue and a topic and use the connection string stored in the `ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING` connection string. - -> 💡 We support **connection strings that are scoped on the Service Bus namespace and entity** allowing you to choose the required security model for your applications. If you are using namespace-scoped connection strings you'll have to pass your queue/topic name as well. +> 💡 We also support **connection strings that are scoped on the Service Bus namespace and entity** allowing you to choose the required security model for your applications. If you are using namespace-scoped connection strings you'll have to pass your queue/topic name as well. > ⚠ The order in which the message handlers are registered matters when a message is processed. If the first one can't handle the message, the second will be checked, and so forth. @@ -117,7 +115,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusTopicMessagePump(...) + services.AddServiceBusTopicMessagePumpUsingManagedIdentity(...) .WithServiceBusMessageHandler(context => context.Properties["MessageType"].ToString() == "Order"); } } @@ -161,11 +159,11 @@ public class Startup public void ConfigureServices(IServiceCollection services) { // Register the message body serializer in the dependency container where the dependent services will be injected. - services.AddServiceBusTopicMessagePump(...) + services.AddServiceBusTopicMessagePumpUsingManagedIdentity(...) .WitServiceBusMessageHandler(..., messageBodySerializer: new OrderBatchMessageBodySerializer()); // Register the message body serializer in the dependency container where the dependent services are manually injected. - services.AddServiceBusTopicMessagePump(...) + services.AddServiceBusTopicMessagePumpUsingManagedIdentity(...) .WithServiceBusMessageHandler(..., messageBodySerializerImplementationFactory: serviceProvider => { var logger = serviceProvider.GetService>(); @@ -213,7 +211,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusTopicMessagePump(...) + services.AddServiceBusTopicMessagePumpUsingManagedIdentity(...) .WithServiceMessageHandler((Order order) => order.Type == Department.Sales); } } @@ -261,7 +259,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusQueueMessagePump(...) + services.AddServiceBusQueueMessagePumpUsingManagedIdentity(...) .WithServiceBusFallbackMessageHandler(); } } @@ -317,7 +315,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusQueueMessagePump(...) + services.AddServiceBusQueueMessagePumpUsingManagedIdentity(...) .WithServiceBusMessageHandler(); } } @@ -364,7 +362,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusQueueMessagePump(...) + services.AddServiceBusQueueMessagePumpUsingManagedIdentity(...) .WithServiceBusFallbackMessageHandler(); } } @@ -380,38 +378,12 @@ Next to that, we provide a **variety of overloads** to allow you to: ```csharp using Microsoft.Extensions.DependencyInjection; -public class Startup +public class Program { public void ConfigureServices(IServiceCollection services) { - // Specify the name of the Service Bus Queue: - services.AddServiceBusQueueMessagePump( - "My-Service-Bus-Queue-Name", - "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING"); - - // Specify the name of the Service Bus Topic, and provide a name for the Topic subscription: - services.AddServiceBusMessageTopicMessagePump( - "My-Service-Bus-Topic-Name", - "My-Service-Bus-Topic-Subscription-Name", - "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING"); - - // Specify a topic subscription prefix instead of a name to separate topic message pumps. - services.AddServiceBusTopicMessagePumpWithPrefix( - "My-Service-Bus-Topic-Name" - "My-Service-Bus-Subscription-Prefix", - "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING"); - - // Uses managed identity to authenticate with the Service Bus Topic: - services.AddServiceBusTopicMessagePumpUsingManagedIdentity( - topicName: properties.EntityPath, - subscriptionName: "Receive-All", - fullyQualifiedNamespace: ".servicebus.windows.net" - // The optional client id to authenticate for a user assigned managed identity. More information on user assigned managed identities cam be found here: - // https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview#how-a-user-assigned-managed-identity-works-with-an-azure-vm - clientId: ""); - - services.AddServiceBusTopicMessagePump( - "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING", + + services.AddServiceBusTopicMessagePumpUsingManagedIdentity(..., options => { // Indicate whether or not messages should be automatically marked as completed @@ -466,8 +438,7 @@ public class Startup options.TopicSubscription = TopicSubscription.Automatic; }); - services.AddServiceBusQueueMessagePump( - "ARCUS_SERVICEBUS_ORDERS_CONNECTIONSTRING", + services.AddServiceBusQueueMessagePumpUsingManagedIdentity(... options => { // Indicate whether or not messages should be automatically marked as completed @@ -518,17 +489,9 @@ public class Startup options.Routing.Deserialization.AdditionalMembers = AdditionalMembersHandling.Ignore; }); - // Uses managed identity to authenticate with the Service Bus Topic: - services.AddServiceBusQueueMessagePumpUsingManagedIdentity( - queueName: "orders", - serviceBusNamespace: "" - // The optional client id to authenticate for a user assigned managed identity. More information on user assigned managed identities cam be found here: - // https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview#how-a-user-assigned-managed-identity-works-with-an-azure-vm - clientId: ""); - // Multiple message handlers can be added to the services, based on the message type (ex. 'Order', 'Customer'...), // the correct message handler will be selected. - services.AddServiceBusQueueMessagePump(...) + services.AddServiceBusQueueMessagePumpUsingManagedIdentity(...) .WithServiceBusMessageHandler() .WithMessageHandler(); } @@ -576,7 +539,7 @@ public void ConfigureServices(IServiceCollection services) return new TrackedAzureServiceBusMessageRouter(serviceProvider, logger); }); - services.AddServiceBusQueueMessagePump(...); + services.AddServiceBusQueueMessagePumpUsingMangedIdentity(...); } ``` diff --git a/docs/preview/02-Features/04-service-bus-extensions.md b/docs/preview/02-Features/04-service-bus-extensions.md index eadd1ee6..9dfa0438 100644 --- a/docs/preview/02-Features/04-service-bus-extensions.md +++ b/docs/preview/02-Features/04-service-bus-extensions.md @@ -15,32 +15,6 @@ This features requires to install our NuGet package: PM > Install-Package Arcus.Messaging.ServiceBus.Core ``` -## Using Arcus secret store when registering the Service Bus client - -When registering a `ServiceBusClient` via [Azure's client registration process](https://learn.microsoft.com/en-us/dotnet/api/overview/azure/messaging.servicebus-readme), the library provides an extension to pass-in a secret name instead of directly passing the Azure Service Bus connection string. -This secret name will correspond with a registered secret in the [Arcus secret store](https://security.arcus-azure.net/features/secret-store) that holds the Azure Service Bus connection string. - -Following example shows how the secret name is passed to this extension overload: - -```csharp -using Microsoft.Extensions.Azure; -using Microsoft.Extensions.DependencyInjection; - -public class Program -{ - public void ConfigureServices(IServiceCollection services) - { - // Adding Arcus secret store, more info: https://security.arcus-azure.net/features/secret-store - services.AddSecretStore(stores => stores.AddAzureKeyVaultWithManagedIdentity("https://my.vault.azure.net"); - - // Adding Service Bus client with secret in Arcus secret store. - services.AddAzureClients(clients => clients.AddServiceBusClient(connectionStringSecretName: "")); - } -} -``` - -🥇 Adding your Azure Service Bus client this way helps separating application configuration from sensitive secrets. For more information on the added-values of the Arcus secret store, see [our dedicated documentation page](https://security.arcus-azure.net/features/secret-store). - ## Automatic tracking and Hierarchical correlating of Service Bus messages The Arcus message pump/router automatically makes sure that received Azure Service Bus messages are tracked as request telemetry in Application Insights. diff --git a/docs/preview/02-Features/06-general-messaging.md b/docs/preview/02-Features/06-general-messaging.md index 014a3e9b..98fadd0e 100644 --- a/docs/preview/02-Features/06-general-messaging.md +++ b/docs/preview/02-Features/06-general-messaging.md @@ -86,7 +86,7 @@ After the message pump and/or message handlers are registered, you can add one o ```csharp using Arcus.Messaging.Pumps.Abstractions; -services.AddServiceBusMessagePump(...) +services.AddServiceBusMessagePumpUsingManagedIdentity(...) .WithCircuitBreakerStateChangedEventHandler() .WithCircuitBreakerStateChangedEventHandler(); ``` @@ -127,10 +127,10 @@ public class Program { public void ConfigureServices(IServiceCollection services) { - services.AddServiceBusMessagePump(..., options => options.JobId = "abc-123") + services.AddServiceBusMessagePumpUsingManagedIdentity(..., options => options.JobId = "abc-123") .WithServiceBusMessageHandler<..., ...>(); - services.AddEventHubsMessagePump(..., options => options.JobId = "def-456") + services.AddEventHubsMessagePumpUsingManagedIdentity(..., options => options.JobId = "def-456") .WithEventHubsMessageHandler<..., ...>(); } } From 021c7f3f4023f6adf2ee5d0d7c80d1681b45114d Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Thu, 13 Feb 2025 07:53:25 +0100 Subject: [PATCH 3/4] chore(deprecate): az namespace data model --- .../AzureServiceBusNamespace.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusNamespace.cs b/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusNamespace.cs index fa2dbb30..abfc11b1 100644 --- a/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusNamespace.cs +++ b/src/Arcus.Messaging.Pumps.ServiceBus/AzureServiceBusNamespace.cs @@ -1,4 +1,5 @@ using System; +using Microsoft.Azure.Management.ServiceBus; using Microsoft.Extensions.Logging; namespace Arcus.Messaging.Pumps.ServiceBus @@ -6,6 +7,7 @@ namespace Arcus.Messaging.Pumps.ServiceBus /// /// Represents the namespace of a Azure Service Bus resource; where the Azure Service Bus is located. /// + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to construct " + nameof(ServiceBusManagementClient) + " instances which can rotate Azure Service bus keys")] public class AzureServiceBusNamespace { /// From 9539465bd59c0d17348296390442175f00884e4e Mon Sep 17 00:00:00 2001 From: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Date: Tue, 25 Feb 2025 08:35:39 +0100 Subject: [PATCH 4/4] Update AzureClientFactoryBuilderExtensions.cs --- .../Extensions/AzureClientFactoryBuilderExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs b/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs index 7b0616fe..ef494625 100644 --- a/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs +++ b/src/Arcus.Messaging.ServiceBus.Core/Extensions/AzureClientFactoryBuilderExtensions.cs @@ -13,6 +13,7 @@ namespace Microsoft.Extensions.Azure /// Extensions on the to add more easily Azure Service Bus clients with Arcus components. /// // ReSharper disable once InconsistentNaming + [Obsolete("Will be removed in v3.0, please use Microsoft's built-in Azure SDK clients to register a " + nameof(ServiceBusClient) + " to remove the " + nameof(ISecretProvider) + " requirement")] public static class AzureClientFactoryBuilderExtensions { ///