Share via


EventHubClient.CreateFromConnectionString Method

Definition

Overloads

CreateFromConnectionString(String)

Creates a new instance of the Event Hubs client using the specified connection string. You can populate the EntityPath property with the name of the Event Hub.

CreateFromConnectionString(String, String)

Creates a new instance of the Event Hubs client using the specified connection string. Use this overload only when the connection string does not use the EntityPath property.

CreateFromConnectionString(String)

Creates a new instance of the Event Hubs client using the specified connection string. You can populate the EntityPath property with the name of the Event Hub.

public static Microsoft.ServiceBus.Messaging.EventHubClient CreateFromConnectionString (string connectionString);
static member CreateFromConnectionString : string -> Microsoft.ServiceBus.Messaging.EventHubClient
Public Shared Function CreateFromConnectionString (connectionString As String) As EventHubClient

Parameters

connectionString
String

The connection string to use.

Returns

The newly created EventHubClient object.

Exceptions

Thrown when the format of the parameter connectionString is incorrect.

Examples

Sample showing how to populate the EntityPath in connectionString

var connectionStringBuilder = new ServiceBusConnectionStringBuilder(connectionString);
connectionStringBuilder.EntityPath = eventHubDescription.Path;

var eventHubClient = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

Remarks

The connection can be obtained either from the Azure portal, or created from a ServiceBusConnectionStringBuilder instance.

Applies to

CreateFromConnectionString(String, String)

Creates a new instance of the Event Hubs client using the specified connection string. Use this overload only when the connection string does not use the EntityPath property.

public static Microsoft.ServiceBus.Messaging.EventHubClient CreateFromConnectionString (string connectionString, string path);
static member CreateFromConnectionString : string * string -> Microsoft.ServiceBus.Messaging.EventHubClient
Public Shared Function CreateFromConnectionString (connectionString As String, path As String) As EventHubClient

Parameters

connectionString
String

The connection string to be used.

path
String

The path to the Event Hub.

Returns

The newly created EventHubClient object.

Exceptions

Thrown when the format of the parameters is incorrect.

Remarks

The connection can be obtained either from the Azure portal, or created from a ServiceBusConnectionStringBuilder instance.

Applies to