# AzureEventHubsExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Azure.EventHubs](/reference/api/csharp/aspire.hosting.azure.eventhubs.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsExtensions.cs)

Provides extension methods for adding the Azure Event Hubs resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class AzureEventHubsExtensions
{
    // ...
}
```

## Methods

- [AddAzureEventHubs(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#addazureeventhubs-idistributedapplicationbuilder-string) : `IResourceBuilder<AzureEventHubsResource>` `extension` `ats export` -- Adds an Azure Event Hubs Namespace resource to the application model. This resource can be used to create Event Hub resources.
- [AddConsumerGroup(IResourceBuilder<AzureEventHubResource>, string, string?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#addconsumergroup-iresourcebuilder-azureeventhubresource-string-string) : `IResourceBuilder<AzureEventHubConsumerGroupResource>` `extension` `ats export` -- Adds an Azure Event Hub Consumer Group resource to the application model.
- [AddEventHub(IResourceBuilder<AzureEventHubsResource>, string)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#addeventhub-iresourcebuilder-azureeventhubsresource-string) : `IResourceBuilder<AzureEventHubsResource>` `extension` `obsolete` -- Adds an Azure Event Hubs hub resource to the application model. This resource requires an [AzureEventHubsResource](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsresource.md) to be added to the application model.
- [AddHub(IResourceBuilder<AzureEventHubsResource>, string, string?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#addhub-iresourcebuilder-azureeventhubsresource-string-string) : `IResourceBuilder<AzureEventHubResource>` `extension` `ats export` -- Adds an Azure Event Hubs hub resource to the application model.
- [RunAsEmulator(IResourceBuilder<AzureEventHubsResource>, Action<IResourceBuilder<AzureEventHubsEmulatorResource>>)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#runasemulator-iresourcebuilder-azureeventhubsresource-action-iresourcebuilder-azureeventhubsemulatorresource) : `IResourceBuilder<AzureEventHubsResource>` `extension` `ats export` -- Configures an Azure Event Hubs resource to be emulated. This resource requires an [AzureEventHubsResource](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsresource.md) to be added to the application model.
- [WithConfiguration(IResourceBuilder<AzureEventHubsEmulatorResource>, Action<JsonNode>)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withconfiguration-iresourcebuilder-azureeventhubsemulatorresource-action-jsonnode) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `ats ignored` -- Alters the JSON configuration document used by the emulator.
- [WithConfigurationFile(IResourceBuilder<AzureEventHubsEmulatorResource>, string)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withconfigurationfile-iresourcebuilder-azureeventhubsemulatorresource-string) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `ats export` -- Adds a bind mount for the configuration file of an Azure Event Hubs emulator resource.
- [WithDataBindMount(IResourceBuilder<AzureEventHubsEmulatorResource>, string?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withdatabindmount-iresourcebuilder-azureeventhubsemulatorresource-string) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `obsolete` -- Adds a bind mount for the data folder to an Azure Event Hubs emulator resource.
- [WithDataVolume(IResourceBuilder<AzureEventHubsEmulatorResource>, string?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withdatavolume-iresourcebuilder-azureeventhubsemulatorresource-string) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `obsolete` -- Adds a named volume for the data folder to an Azure Event Hubs emulator resource.
- [WithGatewayPort(IResourceBuilder<AzureEventHubsEmulatorResource>, int?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withgatewayport-iresourcebuilder-azureeventhubsemulatorresource-int) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `obsolete` -- Configures the host port for the Azure Event Hubs emulator is exposed on instead of using randomly assigned port.
- [WithHostPort(IResourceBuilder<AzureEventHubsEmulatorResource>, int?)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withhostport-iresourcebuilder-azureeventhubsemulatorresource-int) : `IResourceBuilder<AzureEventHubsEmulatorResource>` `extension` `ats export` -- Configures the host port for the Azure Event Hubs emulator is exposed on instead of using randomly assigned port.
- [WithProperties(IResourceBuilder<AzureEventHubResource>, Action<AzureEventHubResource>)](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withproperties-iresourcebuilder-azureeventhubresource-action-azureeventhubresource) : `IResourceBuilder<AzureEventHubResource>` `extension` `ats export` -- Allows setting the properties of an Azure Event Hub resource.
- [WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureEventHubsResource>, EventHubsBuiltInRole[])](/reference/api/csharp/aspire.hosting.azure.eventhubs/azureeventhubsextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-azureeventhubsresource-eventhubsbuiltinrole) : `IResourceBuilder<T>` `extension` `ats ignored` -- Assigns the specified roles to the given resource, granting it the necessary permissions on the target Azure Event Hubs Namespace resource. This replaces the default role assignments for the resource.
