Equivalent of ServiceBusConnectionStringBuilder in Azure.Messaging.ServiceBus

Viewed 460

I have some code that I would like to migrate from Microsoft.Azure.ServiceBus to Azure.Messaging.ServiceBus, considering the former package is considered deprecated.

One of the things I cannot figure out how to do with this new package, is to build/manipulate connection strings. Specifically, I was using ServiceBusConnectionStringBuilder to parse the connection strings from my configuration and get the EntityPath, as well as a few other things provided by this class.

Am I overlooking something, or was this functionality completely removed?

2 Answers

You can also parse easily yourself:

        IDictionary<string, string> ParseConnectionString(string connectionString)
        {
            var result = connectionString.Split(';').Select(x =>
            {
                var items = x.Split('=');
                return new { Key = items[0], Value = items[1] };
            }).ToDictionary(x => x.Key, x => x.Value);

            return result;
        }

It appears that microsoft re-fukctored the ServiceBusConnectionStringBuilder into a poorly named and inferior ServiceBusConnectionStringProperties

Which does expose a static method ServiceBusConnectionStringProperties Parse(string).

This will, however, not provide all the connectionstring metadata as the builder was.

Related