Skip to content

Commit

Permalink
docs: azure eventhubs documentation page
Browse files Browse the repository at this point in the history
  • Loading branch information
rafek1241 committed Jan 25, 2025
1 parent 7eabf4e commit 21637c5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 48 deletions.
35 changes: 35 additions & 0 deletions docs/modules/azureeventhubs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Azure EventHubs

[Azure EventHubs](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-about) is a native data-streaming service in the cloud that can stream millions of events per second, with low latency, from any source to any destination. Event Hubs is compatible with Apache Kafka. It enables you to run existing Kafka workloads without any code changes.
In this module, you will learn how to use Testcontainers to start an [Azure EventHubs emulator](https://learn.microsoft.com/en-us/azure/event-hubs/overview-emulator) container for testing. To be able to use the Azure EventHubs emulator, you need to accept the [Microsoft Event Hubs Emulator License](https://github.com/Azure/azure-event-hubs-emulator-installer/blob/main/EMULATOR_EULA.md).

!!!Known Limitations

In the official documentation, there are limitations to the Azure EventHubs emulator. You can find the limitations [here](https://learn.microsoft.com/en-us/azure/event-hubs/overview-emulator#known-limitations).

Add the following dependency to your project file:

```shell title="NuGet"
dotnet add package Testcontainers.EventHubs
```

You can start a Azure EventHubs emulator instance from any .NET application. Here, we create different container instances and pass them to the base test class. This allows us to test different configurations.

To create a container instance with minimal configuration, use the following code:

=== "Create initial configuration JSON"
```csharp
--8<-- "tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs:MinimalConfigurationJson"
```

=== "Create Container Instance"
```csharp
--8<-- "tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs:MinimalConfigurationEventHubs"
```

This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method.

=== "Usage Example"
```csharp
--8<-- "tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs:EventHubsUsage"
```
Loading

0 comments on commit 21637c5

Please sign in to comment.