Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure Event Hub emulator support #4209

Merged
merged 23 commits into from
May 24, 2024
Merged

Add Azure Event Hub emulator support #4209

merged 23 commits into from
May 24, 2024

Conversation

sebastienros
Copy link
Member

@sebastienros sebastienros commented May 16, 2024

Fixes #3412

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-components Issues pertaining to Aspire Component packages label May 16, 2024
writer.WriteStartArray("NamespaceConfig"); // "NamespaceConfig": [
writer.WriteStartObject(); // {
writer.WriteString("Type", "EventHub"); // "Type": "EventHub",
writer.WriteString("Name", "emulatorNs1"); // "Name": "emulatorNs1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be hardcoded like this or can this namespace be derived by the event hub resource name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be multiple hubs in this file.

@krishankumar_microsoft how should this resource be named? Or can we remove the name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah what I'm getting at is that for each evenhub namespace in the config file ... it corresponds to a call to AddAzureEventHubs in the app host - that resource has a name so we should use that name here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it now, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to revert this change,

Expected string to be "emulatorns1" with a length of 11 because NamespaceName is non-modifiable.Only supported emulatorns1, but "eventhubns" has a length of 10, differs near "ven" (index 1).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, the team says this is hardcoded for now. So proceed as you have it.

src/Aspire.Hosting.MySql/PhpMyAdminConfigWriterHook.cs Outdated Show resolved Hide resolved
src/Aspire.Hosting.Redis/RedisCommanderConfigWriterHook.cs Outdated Show resolved Hide resolved
public const string Registry = "messagingemulators.azurecr.io";
public const string Image = "microsoft/azure/eventhubs/emulator";
public const string Registry = "mcr.microsoft.com";
public const string Image = "azure-messaging/eventhubs-emulator";
public const string Tag = "latest";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there isn't a stable version number for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet https://mcr.microsoft.com/en-us/product/azure-messaging/eventhubs-emulator/tags

latest
1.2.3-preview-arm64 
1.2.3-preview-amd64 

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Co-authored-by: David Pine <david.pine@microsoft.com>
@davidfowl
Copy link
Member

Make sure this still works after that connection string change.

@sebastienros
Copy link
Member Author

@davidfowl E2E test is passing and tried the playground app locally too after your change which spits out the expected Endpoint=sb://localhost:54297;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;

It is mergeable now IMO.

@davidfowl davidfowl merged commit 40a1675 into main May 24, 2024
8 checks passed
@davidfowl davidfowl deleted the sebros/ehemulator branch May 24, 2024 06:06
/// <param name="path">Relative path to the AppHost where emulator storage is persisted between runs. Defaults to the path '.eventhubs/{builder.Resource.Name}'</param>
/// <param name="isReadOnly">A flag that indicates if this is a read-only mount.</param>
/// <returns>A builder for the <see cref="AzureEventHubsEmulatorResource"/>.</returns>
public static IResourceBuilder<AzureEventHubsEmulatorResource> WithDataBindMount(this IResourceBuilder<AzureEventHubsEmulatorResource> builder, string? path = null, bool isReadOnly = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we have a WithDataVolume?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - what does a data folder do for Azure EventHubs? Doesn't it store all its necessary data in the Storage blobs we gave it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - what does a data folder do for Azure EventHubs? Doesn't it store all its necessary data in the Storage blobs we gave it?

The EH uses the storage blobs for managing partition leases only, not for general data (messages.) The EH client uses a storage account to hold checkpointing info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-components Issues pertaining to Aspire Component packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Azure EventHub emulator support
8 participants