Class EventHubsConnectionStringBuilder
EventHubsConnectionStringBuilder can be used to construct a connection string which can establish communication with Event Hubs entities. It can also be used to perform basic validation on an existing connection string.
A connection string is basically a string consisted of key-value pair separated by ";". Basic format is "<key>=<value>[;<key>=<value>]" where supported key name are as follow:
Endpoint - the URL that contains the Event Hubs namespace
EntityPath - the path to the Event Hub entity
SharedAccessKeyName - the key name to the corresponding shared access policy rule for the namespace, or entity.
SharedAccessKey - the key for the corresponding shared access policy rule of the namespace or entity.
Inheritance
Namespace: System.Dynamic.ExpandoObject
Assembly: Microsoft.Azure.EventHubs.dll
Syntax
public class EventHubsConnectionStringBuilder
Examples
Sample code:
var connectionStringBuiler = new EventHubsConnectionStringBuilder(
"amqps://EventHubsNamespaceName.servicebus.windows.net",
"EventHubsEntityName", // Event Hub Name
"SharedAccessSignatureKeyName",
"SharedAccessSignatureKey");
string connectionString = connectionStringBuiler.ToString();
Constructors
EventHubsConnectionStringBuilder(String)
ConnectionString format: Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessKeyName=SHARED_ACCESS_KEY_NAME;SharedAccessKey=SHARED_ACCESS_KEY
Declaration
public EventHubsConnectionStringBuilder (string connectionString);
Parameters
|
System.String
connectionString
Event Hubs ConnectionString |
EventHubsConnectionStringBuilder(Uri, String, String, String)
Build a connection string consumable by CreateFromConnectionString(String)
Declaration
public EventHubsConnectionStringBuilder (Uri endpointAddress, string entityPath, string sharedAccessKeyName, string sharedAccessKey);
Parameters
|
System.Uri
endpointAddress
Fully qualified domain name for Event Hubs. Most likely, {yournamespace}.servicebus.windows.net |
|
System.String
entityPath
Entity path or Event Hub name. |
|
System.String
sharedAccessKeyName
Shared Access Key name |
|
System.String
sharedAccessKey
Shared Access Key |
EventHubsConnectionStringBuilder(Uri, String, String, TimeSpan)
Build a connection string consumable by CreateFromConnectionString(String)
Declaration
public EventHubsConnectionStringBuilder (Uri endpointAddress, string entityPath, string sharedAccessSignature, TimeSpan operationTimeout);
Parameters
|
System.Uri
endpointAddress
Fully qualified domain name for Event Hubs. Most likely, {yournamespace}.servicebus.windows.net |
|
System.String
entityPath
Entity path or Event Hub name. |
|
System.String
sharedAccessSignature
Shared Access Signature |
|
System.TimeSpan
operationTimeout
Operation timeout for Event Hubs operations |
EventHubsConnectionStringBuilder(Uri, String, String, String, TimeSpan)
Build a connection string consumable by CreateFromConnectionString(String)
Declaration
public EventHubsConnectionStringBuilder (Uri endpointAddress, string entityPath, string sharedAccessKeyName, string sharedAccessKey, TimeSpan operationTimeout);
Parameters
|
System.Uri
endpointAddress
Fully qualified domain name for Event Hubs. Most likely, {yournamespace}.servicebus.windows.net |
|
System.String
entityPath
Entity path or Event Hub name. |
|
System.String
sharedAccessKeyName
Shared Access Key name |
|
System.String
sharedAccessKey
Shared Access Key |
|
System.TimeSpan
operationTimeout
Operation timeout for Event Hubs operations |
Properties
Authentication
Enables Azure Active Directory Managed Identity authentication when set to 'Managed Identity'
Declaration
public string Authentication { get; set; }
Property Value
|
System.String
|
Endpoint
Gets or sets the Event Hubs endpoint.
Declaration
public Uri Endpoint { get; set; }
Property Value
|
System.Uri
|
EntityPath
Get the entity path value from the connection string
Declaration
public string EntityPath { get; set; }
Property Value
|
System.String
|
OperationTimeout
OperationTimeout is applied in erroneous situations to notify the caller about the relevant EventHubsException
Declaration
public TimeSpan OperationTimeout { get; set; }
Property Value
|
System.TimeSpan
|
SasKey
Get the shared access policy key value from the connection string
Declaration
public string SasKey { get; set; }
Property Value
|
System.String
Shared Access Signature key |
SasKeyName
Get the shared access policy owner name from the connection string
Declaration
public string SasKeyName { get; set; }
Property Value
|
System.String
|
SharedAccessSignature
TransportType
Transport type for the client connection. Avaiable options are Amqp and AmqpWebSockets. Defaults to Amqp if not specified.
Declaration
public Microsoft.Azure.EventHubs.TransportType TransportType { get; set; }
Property Value
|
TransportType
|
Methods
Clone()
Creates a cloned object of the current EventHubsConnectionStringBuilder.
Declaration
public Microsoft.Azure.EventHubs.EventHubsConnectionStringBuilder Clone ();
Returns
| EventHubsConnectionStringBuilder |
ToString()
Returns an interoperable connection string that can be used to connect to Event Hubs Namespace
Declaration
public override string ToString ();
Returns
|
System.String
the connection string |