-
Notifications
You must be signed in to change notification settings - Fork 482
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 Service Bus emulator support #6737
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # Aspire.sln # src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusExtensions.cs
src/Aspire.Hosting.Azure.ServiceBus/ApplicationModel/OptionalValue.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.ServiceBus/ApplicationModel/ServiceBusClientAffineProperties.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.ServiceBus/ApplicationModel/ServiceBusClientAffineProperties.cs
Outdated
Show resolved
Hide resolved
…alue.cs Co-authored-by: David Pine <[email protected]>
src/Aspire.Hosting.Azure.ServiceBus/ApplicationModel/OptionalValue.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.EventHubs/EventHubsEmulatorContainerImageTags.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.ServiceBus/Aspire.Hosting.Azure.ServiceBus.csproj
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusEmulatorResource.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Azure.ServiceBus/ApplicationModel/ServiceBusClientAffineProperties.cs
Outdated
Show resolved
Hide resolved
/// Converts the current instance to a provisioning entity. | ||
/// </summary> | ||
/// <returns>A <see cref="global::Azure.Provisioning.ServiceBus.ServiceBusTopic"/> instance.</returns> | ||
public global::Azure.Provisioning.ServiceBus.ServiceBusTopic ToProvisioningEntity() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate that we have conflicting type names with Azure.Provisioning. I imagine we will have a lot of users who will reference both and need to disambiguate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add a suffix to these types. However looking at the app host we shouldn't need to add usings at all, unless we call ConfigureInfrastructure to get the CDK types.
playground/AzureServiceBus/ServiceBusWorker/ServiceBusWorker.csproj
Outdated
Show resolved
Hide resolved
; | ||
|
||
serviceBus | ||
.AddQueue("myQueue", queue => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use a callback API pattern here? Why doesn't .AddQueue
return the Queue, and then you can modify it as you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eerhardt In this case we would need to return an object that combines behavior of IResourceBuilder<AzureServiceBusResource>
with what you are describing so that we could either modify the specified queue or start to specify a different queue or topic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(full disclosure, I'm not a super fan of fluent APIs)
If you want to start to specify a different queue, you would start a new code line.
var serviceBus = builder.AddAzureServiceBus("sbemulator");
var queue1 = serviceBus.AddQueue("queue1");
// set properties on queue1
var queue2 = serviceBus.AddQueue("queue2");
// set properties on queue2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't .AddQueue return the Queue, and then you can modify it as you want?
This would be a breaking change. Is that something we'd want? But we could then reference the resources when building the model, or do topic.AddSubscription("sub.1")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a breaking change. Is that something we'd want?
Any way we could make it without a breaking change? A new method name? AddServiceBusQueue
?
cc @mitchdenny @davidfowl - thoughts on using callbacks in the API this way?
public class AzureServiceBusEmulatorResource(AzureServiceBusResource innerResource) : ContainerResource(innerResource.Name), IResource | ||
{ | ||
// The path to the emulator configuration file in the container. | ||
internal const string EmulatorConfigJsonPath = "/ServiceBus_Emulator/ConfigFiles/Config.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assume this is still WIP as would need a way to supply config.json based ont he docs as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the internal path for the emulator, this won't change. We do bind your own files to this internal path. Use the WithConfigJson(yourpath)
for that. And internally it will bind to this path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add another method to configure a JsonObject
representing the document in case we want to alter either the generated one of the bound one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the internal path for the emulator, this won't change. We do bind your own files to this internal path. Use the
WithConfigJson(yourpath)
for that. And internally it will bind to this path.
Oh, that would be nice to get in for Event Hubs emulator to unblock a few things while the API evolves to match this app model idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, added ConfigureJson
in the RunEmulator
's lambda.
Description
Add support for the Service Bus emulator https://techcommunity.microsoft.com/blog/messagingonazureblog/introducing-local-emulator-for-azure-service-bus/4304457
This PR introduces a custom model to configure the emulator and the cloud service. There is another branch that was based on the CDK directly (and use it for the emulator JSON too) but some discussions led to create a custom, simplified one (not really simplified here for the sake of understanding limits), that is then converted to JSON for the emulator, and to CDK resources for provisioning. If the model is not sufficient (can be on purpose to limit it to what users use in most cases) then the emulator configuration can be defined in JSON directly via
WithConfigJson(path)
, customized withRunAsEmulator(c => c.ConfigJson(JsonNode))
, and the CDK resources can be enhanced with the existingConfigureInfrastructure()
.Fixes #6605
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):Microsoft Reviewers: Open in CodeFlow