Partager via


AzureEventHubsExtensions.RunAsEmulator Method

Definition

Configures an Azure Event Hubs resource to be emulated. This resource requires an AzureEventHubsResource to be added to the application model.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsResource> RunAsEmulator (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsResource> builder, Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsEmulatorResource>>? configureContainer = default);
static member RunAsEmulator : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsResource> * Action<Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsEmulatorResource>> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureEventHubsResource>
<Extension()>
Public Function RunAsEmulator (builder As IResourceBuilder(Of AzureEventHubsResource), Optional configureContainer As Action(Of IResourceBuilder(Of AzureEventHubsEmulatorResource)) = Nothing) As IResourceBuilder(Of AzureEventHubsResource)

Parameters

builder
IResourceBuilder<AzureEventHubsResource>

The Azure Event Hubs resource builder.

configureContainer
Action<IResourceBuilder<AzureEventHubsEmulatorResource>>

Callback that exposes underlying container used for emulation to allow for customization.

Returns

A reference to the IResourceBuilder<T>.

Examples

The following example creates an Azure Event Hubs resource that runs locally is an emulator and referencing that resource in a .NET project.

var builder = DistributedApplication.CreateBuilder(args);

var eventHub = builder.AddAzureEventHubs("eventhubns")
   .RunAsEmulator()
   .AddEventHub("hub");

builder.AddProject<Projects.InventoryService>()
       .WithReference(eventHub);

builder.Build().Run();

Applies to