Table of Contents

Class ServiceBusConnectionStringBuilder

Namespace
Microsoft.Azure.ServiceBus
Assembly
Microsoft.Azure.ServiceBus.dll

Used to generate Service Bus connection strings.

public class ServiceBusConnectionStringBuilder
Inheritance
ServiceBusConnectionStringBuilder
Inherited Members

Constructors

ServiceBusConnectionStringBuilder()

public ServiceBusConnectionStringBuilder()

ServiceBusConnectionStringBuilder(string)

public ServiceBusConnectionStringBuilder(string connectionString)

Parameters

connectionString string

Connection string for namespace or the entity.

ServiceBusConnectionStringBuilder(string, string, string)

public ServiceBusConnectionStringBuilder(string endpoint, string entityPath, string sharedAccessSignature)

Parameters

endpoint string

Fully qualified endpoint.

entityPath string
sharedAccessSignature string

Examples

var connectionStringBuilder = new ServiceBusConnectionStringBuilder(
    "contoso.servicebus.windows.net",
    "myQueue",
    "{ ... SAS token ... }"
);

ServiceBusConnectionStringBuilder(string, string, string, TransportType)

public ServiceBusConnectionStringBuilder(string endpoint, string entityPath, string sharedAccessSignature, TransportType transportType)

Parameters

endpoint string

Fully qualified endpoint.

entityPath string
sharedAccessSignature string
transportType TransportType

Examples

var connectionStringBuilder = new ServiceBusConnectionStringBuilder(
    "contoso.servicebus.windows.net",
    "myQueue",
    "{ ... SAS token ... }",
    TransportType.Amqp
);

ServiceBusConnectionStringBuilder(string, string, string, string)

public ServiceBusConnectionStringBuilder(string endpoint, string entityPath, string sharedAccessKeyName, string sharedAccessKey)

Parameters

endpoint string

Fully qualified endpoint.

entityPath string
sharedAccessKeyName string
sharedAccessKey string

Examples

var connectionStringBuilder = new ServiceBusConnectionStringBuilder(
    "contoso.servicebus.windows.net",
    "myQueue",
    "RootManageSharedAccessKey",
    "<sharedAccessKey>
);

ServiceBusConnectionStringBuilder(string, string, string, string, TransportType)

public ServiceBusConnectionStringBuilder(string endpoint, string entityPath, string sharedAccessKeyName, string sharedAccessKey, TransportType transportType)

Parameters

endpoint string

Fully qualified endpoint.

entityPath string
sharedAccessKeyName string
sharedAccessKey string
transportType TransportType

Examples

var connectionStringBuilder = new ServiceBusConnectionStringBuilder(
    "contoso.servicebus.windows.net",
    "myQueue",
    "RootManageSharedAccessKey",
    "<sharedAccessKey>,
    TransportType.Amqp
);

Properties

Endpoint

Fully qualified domain name of the endpoint.

public string Endpoint { get; set; }

Property Value

string

Examples

this.Endpoint = contoso.servicebus.windows.net

Exceptions

ArgumentException

Throws when endpoint is not fully qualified endpoint.

UriFormatException

Throws when the hostname cannot be parsed

EntityPath

Get the entity path value from the connection string

public string EntityPath { get; set; }

Property Value

string

SasKey

Get the shared access policy key value from the connection string

public string SasKey { get; set; }

Property Value

string

Shared Access Signature key

SasKeyName

Get the shared access policy owner name from the connection string

public string SasKeyName { get; set; }

Property Value

string

SasToken

Get the shared access signature token from the connection string

public string SasToken { get; set; }

Property Value

string

Shared Access Signature token

TransportType

Get the transport type from the connection string

public TransportType TransportType { get; set; }

Property Value

TransportType

Methods

GetEntityConnectionString()

Returns an interoperable connection string that can be used to connect to the given ServiceBus Entity

public string GetEntityConnectionString()

Returns

string

Entity connection string

GetNamespaceConnectionString()

Returns an interoperable connection string that can be used to connect to ServiceBus Namespace

public string GetNamespaceConnectionString()

Returns

string

Namespace connection string

ToString()

Returns an interoperable connection string that can be used to connect to ServiceBus Namespace

public override string ToString()

Returns

string

The connection string