Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
"principalId": ""
}
},
"eventhub": {
"type": "value.v0",
"connectionString": "Endpoint={eventhubns.outputs.eventHubsEndpoint};EntityPath=eventhub"
},
"consumer": {
"type": "project.v0",
"path": "../EventHubsConsumer/EventHubsConsumer.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ConnectionStrings__eventhubns": "{eventhubns.connectionString}",
"ConnectionStrings__eventhub": "{eventhub.connectionString}",
"ConnectionStrings__checkpoints": "{checkpoints.connectionString}"
}
},
Expand All @@ -42,7 +46,7 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{api.bindings.http.targetPort}",
"ConnectionStrings__eventhubns": "{eventhubns.connectionString}"
"ConnectionStrings__eventhub": "{eventhub.connectionString}"
},
"bindings": {
"http": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ resource eventhubns_AzureEventHubsDataOwner 'Microsoft.Authorization/roleAssignm
scope: eventhubns
}

resource hub 'Microsoft.EventHub/namespaces/eventhubs@2024-01-01' = {
name: 'hub'
resource eventhub 'Microsoft.EventHub/namespaces/eventhubs@2024-01-01' = {
name: 'eventhub'
parent: eventhubns
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
.RunAsEmulator()
.AddHub("myhub");
#if !SKIP_UNSTABLE_EMULATORS
var serviceBus = builder.AddAzureServiceBus("messaging").RunAsEmulator().WithQueue("myqueue");
var serviceBus = builder.AddAzureServiceBus("messaging")
.RunAsEmulator();
serviceBus.AddServiceBusQueue("myqueue");
var cosmosDb = builder.AddAzureCosmosDB("cosmosdb")
.RunAsEmulator();
var database = cosmosDb.AddCosmosDatabase("mydatabase");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"principalId": ""
}
},
"myhub": {
"type": "value.v0",
"connectionString": "Endpoint={eventhubs.outputs.eventHubsEndpoint};EntityPath=myhub"
},
"messaging": {
"type": "azure.bicep.v0",
"connectionString": "{messaging.outputs.serviceBusEndpoint}",
Expand All @@ -35,6 +39,10 @@
"principalId": ""
}
},
"myqueue": {
"type": "value.v0",
"connectionString": "{messaging.outputs.serviceBusEndpoint}"
},
"cosmosdb": {
"type": "azure.bicep.v0",
"connectionString": "{cosmosdb.outputs.connectionString}",
Expand Down Expand Up @@ -75,12 +83,17 @@
"AzureWebJobsStorage__queueServiceUri": "{funcstorage67c6c.outputs.queueEndpoint}",
"Aspire__Azure__Storage__Blobs__AzureWebJobsStorage__ServiceUri": "{funcstorage67c6c.outputs.blobEndpoint}",
"Aspire__Azure__Storage__Queues__AzureWebJobsStorage__ServiceUri": "{funcstorage67c6c.outputs.queueEndpoint}",
"eventhubs__fullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubProducerClient__eventhubs__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubConsumerClient__eventhubs__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventProcessorClient__eventhubs__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__PartitionReceiver__eventhubs__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubBufferedProducerClient__eventhubs__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"myhub__fullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubProducerClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubConsumerClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventProcessorClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__PartitionReceiver__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubBufferedProducerClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}",
"Aspire__Azure__Messaging__EventHubs__EventHubProducerClient__myhub__EventHubName": "myhub",
"Aspire__Azure__Messaging__EventHubs__EventHubConsumerClient__myhub__EventHubName": "myhub",
"Aspire__Azure__Messaging__EventHubs__EventProcessorClient__myhub__EventHubName": "myhub",
"Aspire__Azure__Messaging__EventHubs__PartitionReceiver__myhub__EventHubName": "myhub",
"Aspire__Azure__Messaging__EventHubs__EventHubBufferedProducerClient__myhub__EventHubName": "myhub",
"messaging__fullyQualifiedNamespace": "{messaging.outputs.serviceBusEndpoint}",
"Aspire__Azure__Messaging__ServiceBus__messaging__FullyQualifiedNamespace": "{messaging.outputs.serviceBusEndpoint}",
"cosmosdb__accountEndpoint": "{cosmosdb.outputs.connectionString}",
Expand Down Expand Up @@ -117,7 +130,7 @@
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{apiservice.bindings.http.targetPort}",
"ConnectionStrings__eventhubs": "{eventhubs.connectionString}",
"ConnectionStrings__myhub": "{myhub.connectionString}",
"ConnectionStrings__messaging": "{messaging.connectionString}",
"ConnectionStrings__cosmosdb": "{cosmosdb.connectionString}",
"ConnectionStrings__queue": "{queue.connectionString}",
Expand Down
25 changes: 10 additions & 15 deletions playground/AzureServiceBus/ServiceBus.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
using System.Text.Json.Nodes;
using Aspire.Hosting.Azure.ServiceBus;
using Aspire.Hosting.Azure;

var builder = DistributedApplication.CreateBuilder(args);

var serviceBus = builder.AddAzureServiceBus("sbemulator");

serviceBus
.WithQueue("queue1", queue =>
{
queue.DeadLetteringOnMessageExpiration = false;
})
.WithTopic("topic1", topic =>
serviceBus.AddServiceBusQueue("queue1")
.WithProperties(queue => queue.DeadLetteringOnMessageExpiration = false);

serviceBus.AddServiceBusTopic("topic1")
.AddServiceBusSubscription("sub1")
.WithProperties(subscription =>
{
var subscription = new ServiceBusSubscription("sub1")
{
MaxDeliveryCount = 10,
};
topic.Subscriptions.Add(subscription);
subscription.MaxDeliveryCount = 10;

var rule = new ServiceBusRule("app-prop-filter-1")
var rule = new AzureServiceBusRule("app-prop-filter-1")
{
CorrelationFilter = new()
{
Expand All @@ -33,8 +29,7 @@
}
};
subscription.Rules.Add(rule);
})
;
});

serviceBus.RunAsEmulator(configure => configure.WithConfiguration(document =>
{
Expand Down
12 changes: 12 additions & 0 deletions playground/AzureServiceBus/ServiceBus.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
"principalId": ""
}
},
"queue1": {
"type": "value.v0",
"connectionString": "{sbemulator.outputs.serviceBusEndpoint}"
},
"topic1": {
"type": "value.v0",
"connectionString": "{sbemulator.outputs.serviceBusEndpoint}"
},
"sub1": {
"type": "value.v0",
"connectionString": "{sbemulator.outputs.serviceBusEndpoint}"
},
"worker": {
"type": "project.v0",
"path": "../ServiceBusWorker/ServiceBusWorker.csproj",
Expand Down
14 changes: 10 additions & 4 deletions playground/bicep/BicepSample.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@
// Redis takes forever to spin up...
var redis = builder.AddAzureRedis("redis");

var serviceBus = builder.AddAzureServiceBus("sb")
.WithQueue("queue1")
.WithTopic("topic1", topic => topic.Subscriptions.AddRange([new("subscription1"), new("subscription2")]))
.WithTopic("topic2", topic => topic.Subscriptions.Add(new("subscription1")));
var serviceBus = builder.AddAzureServiceBus("sb");

serviceBus.AddServiceBusQueue("queue1");

var topic1 = serviceBus.AddServiceBusTopic("topic1");
topic1.AddServiceBusSubscription("subscription1");
topic1.AddServiceBusSubscription("subscription2");
serviceBus.AddServiceBusTopic("topic2")
.AddServiceBusSubscription("topic2sub", "subscription1");

var signalr = builder.AddAzureSignalR("signalr");
var webpubsub = builder.AddAzureWebPubSub("wps");
builder.AddProject<Projects.BicepSample_ApiService>("api")
Expand Down
24 changes: 24 additions & 0 deletions playground/bicep/BicepSample.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@
"principalId": ""
}
},
"queue1": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"topic1": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"subscription1": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"subscription2": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"topic2": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"topic2sub": {
"type": "value.v0",
"connectionString": "{sb.outputs.serviceBusEndpoint}"
},
"signalr": {
"type": "azure.bicep.v0",
"connectionString": "Endpoint=https://{signalr.outputs.hostName};AuthType=azure",
Expand Down
2 changes: 1 addition & 1 deletion playground/bicep/BicepSample.AppHost/sb.module.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resource topic2 'Microsoft.ServiceBus/namespaces/topics@2024-01-01' = {
parent: sb
}

resource subscription1 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2024-01-01' = {
resource topic2sub 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2024-01-01' = {
name: 'subscription1'
parent: topic2
}
Expand Down
53 changes: 30 additions & 23 deletions playground/cdk/CdkSample.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,36 @@
var pgsql2 = builder.AddAzurePostgresFlexibleServer("pgsql2")
.AddDatabase("pgsql2db");

var sb = builder.AddAzureServiceBus("servicebus")
.WithQueue("queue1")
.ConfigureInfrastructure(infrastructure =>
{
var queue = infrastructure.GetProvisionableResources().OfType<ServiceBusQueue>().Single(q => q.BicepIdentifier == "queue1");
queue.MaxDeliveryCount = 5;
queue.LockDuration = TimeSpan.FromMinutes(5);
})
.WithTopic("topic1")
.ConfigureInfrastructure(infrastructure =>
{
var topic = infrastructure.GetProvisionableResources().OfType<ServiceBusTopic>().Single(q => q.BicepIdentifier == "topic1");
topic.EnablePartitioning = true;
})
.WithTopic("topic2", topic2 => topic2.Subscriptions.Add(new("subscription1")))
.ConfigureInfrastructure(infrastructure =>
{
var subscription = infrastructure.GetProvisionableResources().OfType<ServiceBusSubscription>().Single(q => q.BicepIdentifier == "subscription1");
subscription.LockDuration = TimeSpan.FromMinutes(5);
subscription.RequiresSession = true;
})
.WithTopic("topic1", topic2 => topic2.Subscriptions.Add(new("subscription2")))
.WithTopic("topic3", topic3 => topic3.Subscriptions.AddRange([new("sub1"), new("sub2")]));
var sb = builder.AddAzureServiceBus("servicebus");

sb.AddServiceBusQueue("queue1");
sb.ConfigureInfrastructure(infrastructure =>
{
var queue = infrastructure.GetProvisionableResources().OfType<ServiceBusQueue>().Single(q => q.BicepIdentifier == "queue1");
queue.MaxDeliveryCount = 5;
queue.LockDuration = TimeSpan.FromMinutes(5);
});

sb.AddServiceBusTopic("topic1")
.AddServiceBusSubscription("subscription2");
sb.ConfigureInfrastructure(infrastructure =>
{
var topic = infrastructure.GetProvisionableResources().OfType<ServiceBusTopic>().Single(q => q.BicepIdentifier == "topic1");
topic.EnablePartitioning = true;
});

sb.AddServiceBusTopic("topic2")
.AddServiceBusSubscription("subscription1");
sb.ConfigureInfrastructure(infrastructure =>
{
var subscription = infrastructure.GetProvisionableResources().OfType<ServiceBusSubscription>().Single(q => q.BicepIdentifier == "subscription1");
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR, but we should consider combining this into a single method call:

var subscription = infrastructure.GetProvisionableResource<ServiceBusSubscription>("subscription1");

Perhaps with a sibling for other cases:

var subscription = infrastructure.GetProvisionableResource<ServiceBusSubscription>(q => q.BicepIdentifier == "subscription1");

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 think we want the Azure.Provisioning APIs to supply these kidns of helpers.

cc @tg-msft

subscription.LockDuration = TimeSpan.FromMinutes(5);
subscription.RequiresSession = true;
});

var topic3 = sb.AddServiceBusTopic("topic3");
topic3.AddServiceBusSubscription("sub1");
topic3.AddServiceBusSubscription("sub2");

var appConfig = builder.AddAzureAppConfiguration("appConfig");

Expand Down
32 changes: 32 additions & 0 deletions playground/cdk/CdkSample.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,38 @@
"principalId": ""
}
},
"queue1": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"topic1": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"subscription2": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"topic2": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"subscription1": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"topic3": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"sub1": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"sub2": {
"type": "value.v0",
"connectionString": "{servicebus.outputs.serviceBusEndpoint}"
},
"appConfig": {
"type": "azure.bicep.v0",
"connectionString": "{appConfig.outputs.appConfigEndpoint}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Aspire.Hosting.Azure.ServiceBus;
namespace Aspire.Hosting.Azure;

/// <summary>
/// Represents the correlation filter expression.
/// </summary>
public class ServiceBusCorrelationFilter
public class AzureServiceBusCorrelationFilter
{
/// <summary>
/// Represents the correlation filter expression.
/// </summary>
public ServiceBusCorrelationFilter()
public AzureServiceBusCorrelationFilter()
{
}

Expand Down
Loading