Skip to content

Commit 09e8242

Browse files
authored
[Event Hubs] Assorted Minor Updates (Azure#23655)
# Summary The focus of these changes is to: - Update change logs - Refine documentation around event handlers in the buffered producer - Adapt to changes in the `TestEnvironment` that altered behavior - Fix a corner case in the `AmqpConnectionScope` that could lead to timers not being properly disposed in some error scenarios.
1 parent 4e3a33b commit 09e8242

File tree

8 files changed

+143
-87
lines changed

8 files changed

+143
-87
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@
22

33
## 5.7.0-beta.1 (Unreleased)
44

5-
### Features Added
5+
### Acknowledgments
66

7-
### Breaking Changes
7+
Thank you to our developer community members who helped to make the Event Hubs client libraries better with their contributions to this release:
88

9-
### Bugs Fixed
9+
- Andrey Shihov _([GitHub](https://github.com/andreyshihov))_
10+
11+
### Changes
12+
13+
#### Features Added
14+
15+
#### Breaking Changes
16+
17+
#### Bugs Fixed
1018

1119
- Fixed an issue with refreshing authorization where redundant requests were made to acquire AAD tokens that were due to expire. Refreshes will now coordinate to ensure a single AAD token acquisition.
1220

13-
### Other Changes
21+
- Fixed an issue with authorization refresh where attempts may have been made to authorize a faulted link. Links that fail to open are no longer be considered valid for authorization.
22+
23+
#### Other Changes
24+
25+
- Documentation has been enhanced to provide additional context for client library types, notably detailing non-obvious validations applied to parameters and options members.
1426

1527
## 5.6.0 (2021-08-10)
1628

sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Testing/EventHubsTestEnvironment.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ public sealed class EventHubsTestEnvironment : TestEnvironment
113113
///
114114
public string SharedAccessKey => ParsedConnectionString.Value.SharedAccessKey;
115115

116-
/// <summary>
117-
/// The Azure Authority host to be used for authentication with the active cloud environment.
118-
/// </summary>
119-
///
120-
public new string AuthorityHostUrl => base.AuthorityHostUrl ?? "https://login.microsoftonline.com/";
121-
122116
/// <summary>
123117
/// The Azure Service Management endpoint to be used for management plane authentication with the active cloud environment.
124118
/// </summary>

sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,30 @@
22

33
## 5.7.0-beta.1 (Unreleased)
44

5-
### Features Added
5+
### Acknowledgments
6+
7+
Thank you to our developer community members who helped to make the Event Hubs client libraries better with their contributions to this release:
8+
9+
- Andrey Shihov _([GitHub](https://github.com/andreyshihov))_
10+
11+
### Changes
12+
13+
#### Features Added
614

7-
### Breaking Changes
15+
#### Breaking Changes
816

9-
### Bugs Fixed
17+
#### Bugs Fixed
1018

1119
- Fixed an issue with refreshing authorization where redundant requests were made to acquire AAD tokens that were due to expire. Refreshes will now coordinate to ensure a single AAD token acquisition.
1220

21+
- Fixed an issue with authorization refresh where attempts may have been made to authorize a faulted link. Links that fail to open are no longer be considered valid for authorization.
22+
1323
### Other Changes
1424

25+
- A sample demonstrating the use of the `AzureEventSourceListener` from `Azure.Core` for common scenarios with the Event Hubs client library has been created. _(A community contribution, courtesy of [andreyshihov](https://github.com/andreyshihov))_
26+
27+
- Documentation has been enhanced to provide additional context for client library types, notably detailing non-obvious validations applied to parameters and options members.
28+
1529
## 5.6.0 (2021-08-10)
1630

1731
### Features Added

sdk/eventhub/Azure.Messaging.EventHubs/CONTRIBUTING.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,39 @@ Tests in the Event Hubs client library are split into two categories:
3232
The Live tests read information from the following environment variables:
3333

3434
- `EVENTHUB_RESOURCE_GROUP`
35-
The name of the Azure resource group that contains the Event Hubs namespace
35+
The name of the Azure resource group that contains the Event Hubs namespace
3636

3737
- `EVENTHUB_SUBSCRIPTION_ID`
38-
The identifier (GUID) of the Azure subscription to which the service principal belongs
38+
The identifier (GUID) of the Azure subscription to which the service principal belongs
3939

4040
- `EVENTHUB_TENANT_ID`
41-
The identifier (GUID) of the Azure Active Directory tenant that contains the service principal
41+
The identifier (GUID) of the Azure Active Directory tenant that contains the service principal
4242

4343
- `EVENTHUB_CLIENT_ID`
44-
The identifier (GUID) of the Azure Active Directory application that is associated with the service principal
44+
The identifier (GUID) of the Azure Active Directory application that is associated with the service principal
4545

4646
- `EVENTHUB_CLIENT_SECRET`
47-
The client secret (password) of the Azure Active Directory application that is associated with the service principal
47+
The client secret (password) of the Azure Active Directory application that is associated with the service principal
4848

49-
- `EVENTHUB_PER_TEST_LIMIT_MINUTES`
50-
The maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung. If not provided, a default suitable for most local development environment runs is assumed.
49+
- `EVENTHUB_PER_TEST_LIMIT_MINUTES`
50+
The maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung. If not provided, a default suitable for most local development environment runs is assumed.
51+
52+
- `AZURE_AUTHORITY_HOST`
53+
The URL of the Azure Authority to use for authenticating resource management operations. For the Azure public cloud, this should be: https://login.microsoftonline.com/.
54+
55+
When testing in other cloud instances, the appropriate host will be needed. See [National Clouds](https://docs.microsoft.com/azure/active-directory/develop/authentication-national-cloud) for more information.
5156

5257
- `EVENTHUB_NAMESPACE_CONNECTION_STRING` _**(optional)**_
5358
The connection string to an existing Event Hubs namespace to use for testing. If specified, this namespace will be used as the basis for the test run, with Event Hub instances dynamically managed by the tests. When the run is complete, the namespace will be left in the state that it was in before the test run took place. If not specified, a new namespace will be dynamically created for the test run and removed at the end of the run.
5459

5560
- `EVENTHUB_PROCESSOR_STORAGE_CONNECTION_STRING` _**(optional)**_
5661
The connection string to an existing Blob Storage account to use for `EventProcessorClient` testing. If specified, this account will be used as the basis for the test run, with container instances dynamically managed by the tests. When the run is complete, the account will be left in the state that it was in before the test run took place. If not specified, a new storage account will be dynamically created for the test run and removed at the end of the run.
57-
58-
- `AZURE_AUTHORITY_HOST` _**(optional)**_
59-
The name of the Azure Authority to use for authenticating resource management operations. The default for this is appropriate for use with the Azure public cloud; when testing in other cloud instances, this may be needed.
60-
62+
6163
- `SERVICE_MANAGEMENT_URL` _**(optional)**_
62-
The URL of the endpoint responsible for service management operations in Azure. The default for this is appropriate for use with the Azure public cloud; when testing in other cloud instances, this may be needed.
64+
The URL of the endpoint responsible for service management operations in Azure. The default for this is appropriate for use with the Azure public cloud; when testing in other cloud instances, specifying this value may be needed.
6365

6466
- `RESOURCE_MANAGER_URL` _**(optional)**_
65-
The URL of the endpoint responsible for resource management operations in Azure. The default for this is appropriate for use with the Azure public cloud; when testing in other cloud instances, this may be needed.
67+
The URL of the endpoint responsible for resource management operations in Azure. The default for this is appropriate for use with the Azure public cloud; when testing in other cloud instances, specifying this value may be needed.
6668

6769
To make setting up your environment easier, a [PowerShell script](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/assets/live-tests-azure-setup.ps1) is included in the repository and will create and/or configure the needed Azure resources. To use this script, open a PowerShell instance and login to your Azure account using `Login-AzAccount`, then execute the script. You will need to provide some information, after which the script will configure the Azure resources and then output the set of environment variables with the correct values for running tests.
6870

sdk/eventhub/Azure.Messaging.EventHubs/samples/Sample10_AzureEventSourceListener.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ This example captures all Azure SDK logs from any client library in use, writing
1313
```C# Snippet:EventHubs_Sample10_ConsoleListener
1414
var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
1515
var eventHubName = "<< NAME OF THE EVENT HUB >>";
16+
var producer = new EventHubProducerClient(connectionString, eventHubName);
1617

1718
using AzureEventSourceListener consoleListener = AzureEventSourceListener.CreateConsoleLogger(EventLevel.LogAlways);
1819

19-
EventHubProducerClient producer = new EventHubProducerClient(connectionString, eventHubName);
20-
2120
try
2221
{
2322
using var eventBatch = await producer.CreateBatchAsync();
24-
2523
var eventData = new EventData("This is an event body");
2624

2725
if (!eventBatch.TryAdd(eventData))
@@ -42,15 +40,13 @@ Similar to the previous example, this snippet captures all logs, but writes them
4240
```C# Snippet:EventHubs_Sample10_TraceListener
4341
var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
4442
var eventHubName = "<< NAME OF THE EVENT HUB >>";
43+
var producer = new EventHubProducerClient(connectionString, eventHubName);
4544

4645
using AzureEventSourceListener traceListener = AzureEventSourceListener.CreateTraceLogger(EventLevel.LogAlways);
4746

48-
EventHubProducerClient producer = new EventHubProducerClient(connectionString, eventHubName);
49-
5047
try
5148
{
5249
using var eventBatch = await producer.CreateBatchAsync();
53-
5450
var eventData = new EventData("This is an event body");
5551

5652
if (!eventBatch.TryAdd(eventData))
@@ -75,6 +71,7 @@ More information about the `args` parameter for the callback can be found in the
7571
```C# Snippet:EventHubs_Sample10_CustomListenerWithFilter
7672
var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
7773
var eventHubName = "<< NAME OF THE EVENT HUB >>";
74+
var producer = new EventHubProducerClient(connectionString, eventHubName);
7875

7976
using AzureEventSourceListener customListener = new AzureEventSourceListener((args, message) =>
8077
{
@@ -95,19 +92,9 @@ using AzureEventSourceListener customListener = new AzureEventSourceListener((ar
9592
}
9693
}, EventLevel.LogAlways);
9794

98-
EventHubsConnectionStringProperties connectionStringProperties = EventHubsConnectionStringProperties.Parse(connectionString);
99-
100-
TokenCredential credential = new DefaultAzureCredential();
101-
102-
var producer = new EventHubProducerClient(
103-
connectionStringProperties.FullyQualifiedNamespace,
104-
connectionStringProperties.EventHubName ?? eventHubName,
105-
credential);
106-
10795
try
10896
{
10997
using var eventBatch = await producer.CreateBatchAsync();
110-
11198
var eventData = new EventData("This is an event body");
11299

113100
if (!eventBatch.TryAdd(eventData))
@@ -128,8 +115,9 @@ For scenarios where capturing logs to `Trace` or `Console` outputs isn't ideal,
128115
```C# Snippet:EventHubs_Sample10_CustomListenerWithFile
129116
var connectionString = "<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>";
130117
var eventHubName = "<< NAME OF THE EVENT HUB >>";
118+
var producer = new EventHubProducerClient(connectionString, eventHubName);
131119

132-
using Stream stream = new FileStream("<< PATH TO THE FILE >>", FileMode.OpenOrCreate, FileAccess.Write);
120+
using Stream stream = new FileStream("<< PATH TO THE FILE >>", FileMode.OpenOrCreate, FileAccess.Write);
133121

134122
using StreamWriter streamWriter = new StreamWriter(stream)
135123
{
@@ -152,12 +140,9 @@ using AzureEventSourceListener customListener = new AzureEventSourceListener((ar
152140
}
153141
}, EventLevel.LogAlways);
154142

155-
EventHubProducerClient producer = new EventHubProducerClient(connectionString, eventHubName);
156-
157143
try
158144
{
159145
using var eventBatch = await producer.CreateBatchAsync();
160-
161146
var eventData = new EventData("This is an event body");
162147

163148
if (!eventBatch.TryAdd(eventData))

0 commit comments

Comments
 (0)