You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The focus of these changes is to enhance connection string validation for
all clients to ensure that issues are detected where reasonable messages
can be displayed. Previously, validation was delegated to the EventHubConnection
which left a gap when the connection was not eagerly initialized, such as with
the event processor types.
Expand all lines: sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Core/ConnectionStringProperties.cs
+35
Original file line number
Diff line number
Diff line change
@@ -59,5 +59,40 @@ public ConnectionStringProperties(Uri endpoint,
59
59
SharedAccessKeyName=sharedAccessKeyName;
60
60
SharedAccessKey=sharedAccessKey;
61
61
}
62
+
63
+
/// <summary>
64
+
/// Performs the actions needed to validate the set of connection string properties for connecting to the
65
+
/// Event Hubs service.
66
+
/// </summary>
67
+
///
68
+
/// <param name="explicitEventHubName">The name of the Event Hub that was explicitly passed independent of the connection string, allowing easier use of a namespace-level connection string.</param>
69
+
/// <param name="connectionStringArgumentName">The name of the argument associated with the connection string; to be used when raising <see cref="ArgumentException" /> variants.</param>
70
+
///
71
+
/// <exception cref="ArgumentException">In the case that the properties violate an invariant or otherwise represent a combination that is not permissible, an appropriate exception will be thrown.</exception>
72
+
///
73
+
publicvoidValidate(stringexplicitEventHubName,
74
+
stringconnectionStringArgumentName)
75
+
{
76
+
// The Event Hub name may only be specified in one of the possible forms, either as part of the
77
+
// connection string or as a stand-alone parameter, but not both. If specified in both to the same
<value>The connection string used for an Event Hub client must specify the Event Hubs namespace host, and a Shared Access Signature (both the name and value) to be valid. The path to an Event Hub must be included in the connection string or specified separately.</value>
154
+
<value>The connection string used for an Event Hub client must specify the Event Hubs namespace host, and a Shared Access Key (both the name and value) to be valid. The path to an Event Hub must be included in the connection string or specified separately.</value>
<value>The path to an Event Hub may be specified as part of the connection string or as a separate value, but not both.</value>
157
+
<value>The path to an Event Hub may be specified as part of the connection string or as a separate value, but not both. Please verify that your connection string does not have the `EntityPath` token if you are passing an explicit Event Hub name.</value>
/// Performs the actions needed to validate the set of properties for connecting to the
475
-
/// Event Hubs service, as passed to this client during creation.
476
-
/// </summary>
477
-
///
478
-
/// <param name="properties">The set of properties parsed from the connection string associated this client.</param>
479
-
/// <param name="eventHubName">The name of the Event Hub passed independent of the connection string, allowing easier use of a namespace-level connection string.</param>
480
-
/// <param name="connectionStringArgumentName">The name of the argument associated with the connection string; to be used when raising <see cref="ArgumentException" /> variants.</param>
481
-
///
482
-
/// <remarks>
483
-
/// In the case that the properties violate an invariant or otherwise represent a combination that
484
-
/// is not permissible, an appropriate exception will be thrown.
Assert.That(()=>newEventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName,connectionString),Throws.InstanceOf<ArgumentException>(),"The constructor without options should ensure a connection string.");
80
80
Assert.That(()=>newEventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName,connectionString,"dummy",newEventHubConsumerClientOptions()),Throws.InstanceOf<ArgumentException>(),"The constructor with options should ensure a connection string.");
81
81
}
82
82
83
+
/// <summary>
84
+
/// Verifies functionality of the <see cref="EventHubConnection" />
Assert.That(()=>newMinimalProcessorMock(1,EventHubConsumerClient.DefaultConsumerGroupName,connectionString),Throws.InstanceOf<ArgumentException>(),"The constructor without options should ensure a connection string.");
82
82
Assert.That(()=>newMinimalProcessorMock(1,EventHubConsumerClient.DefaultConsumerGroupName,connectionString,"dummy",newEventProcessorOptions()),Throws.InstanceOf<ArgumentException>(),"The constructor with options should ensure a connection string.");
83
83
}
84
84
85
+
/// <summary>
86
+
/// Verifies functionality of the <see cref="EventHubConnection" />
0 commit comments