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 @@ -2,8 +2,8 @@
using System.Text;
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Producer;
#if !SKIP_UNSTABLE_EMULATORS
using Azure.Messaging.ServiceBus;
#if !SKIP_UNSTABLE_EMULATORS
using Microsoft.Azure.Cosmos;
#endif
using Azure.Storage.Blobs;
Expand All @@ -17,8 +17,8 @@
builder.AddAzureQueueClient("queue");
builder.AddAzureBlobClient("blob");
builder.AddAzureEventHubProducerClient("eventhubs", static settings => settings.EventHubName = "myhub");
#if !SKIP_UNSTABLE_EMULATORS
builder.AddAzureServiceBusClient("messaging");
#if !SKIP_UNSTABLE_EMULATORS
builder.AddAzureCosmosClient("cosmosdb");
#endif

Expand Down Expand Up @@ -59,7 +59,6 @@ static string RandomString(int length)
return Results.Ok("Message sent to Azure EventHubs.");
});

#if !SKIP_UNSTABLE_EMULATORS
app.MapGet("/publish/asb", async (ServiceBusClient client, CancellationToken cancellationToken, int length = 20) =>
{
var sender = client.CreateSender("myqueue");
Expand All @@ -68,6 +67,7 @@ static string RandomString(int length)
return Results.Ok("Message sent to Azure Service Bus.");
});

#if !SKIP_UNSTABLE_EMULATORS
app.MapGet("/publish/cosmosdb", async (CosmosClient cosmosClient) =>
{
var db = cosmosClient.GetDatabase("mydatabase");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
var queue = storage.AddQueues("queue");
var blob = storage.AddBlobs("blob");
var eventHubs = builder.AddAzureEventHubs("eventhubs").RunAsEmulator().WithHub("myhub");
#if !SKIP_UNSTABLE_EMULATORS
var serviceBus = builder.AddAzureServiceBus("messaging").RunAsEmulator().WithQueue("myqueue");
#if !SKIP_UNSTABLE_EMULATORS
var cosmosDb = builder.AddAzureCosmosDB("cosmosdb")
.RunAsEmulator()
.WithDatabase("mydatabase", (database)
Expand All @@ -15,17 +15,17 @@
var funcApp = builder.AddAzureFunctionsProject<Projects.AzureFunctionsEndToEnd_Functions>("funcapp")
.WithExternalHttpEndpoints()
.WithReference(eventHubs).WaitFor(eventHubs)
#if !SKIP_UNSTABLE_EMULATORS
.WithReference(serviceBus).WaitFor(serviceBus)
#if !SKIP_UNSTABLE_EMULATORS
.WithReference(cosmosDb).WaitFor(cosmosDb)
#endif
.WithReference(blob)
.WithReference(queue);

builder.AddProject<Projects.AzureFunctionsEndToEnd_ApiService>("apiservice")
.WithReference(eventHubs).WaitFor(eventHubs)
#if !SKIP_UNSTABLE_EMULATORS
.WithReference(serviceBus).WaitFor(serviceBus)
#if !SKIP_UNSTABLE_EMULATORS
.WithReference(cosmosDb).WaitFor(cosmosDb)
#endif
.WithReference(queue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using System.Globalization;
using System.Text;
using Azure.Messaging.EventHubs.Producer;
#if !SKIP_UNSTABLE_EMULATORS
using Azure.Messaging.ServiceBus;
#endif
using Azure.Storage.Blobs;
using Azure.Storage.Queues;
using Microsoft.AspNetCore.Http;
Expand All @@ -17,9 +15,7 @@ namespace AzureFunctionsEndToEnd.Functions;

public class MyHttpTrigger(
ILogger<MyHttpTrigger> logger,
#if !SKIP_UNSTABLE_EMULATORS
ServiceBusClient serviceBusClient,
#endif
EventHubProducerClient eventHubProducerClient,
QueueServiceClient queueServiceClient,
BlobServiceClient blobServiceClient)
Expand All @@ -29,9 +25,7 @@ public IResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] Ht
{
logger.LogInformation("C# HTTP trigger function processed a request.");
var stringBuilder = new StringBuilder();
#if !SKIP_UNSTABLE_EMULATORS
stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"Aspire-injected ServiceBusClient namespace: {serviceBusClient.FullyQualifiedNamespace}");
#endif
stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"Aspire-injected EventHubProducerClient namespace: {eventHubProducerClient.FullyQualifiedNamespace}");
stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"Aspire-injected QueueServiceClient URI: {queueServiceClient.Uri}");
stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"Aspire-injected BlobServiceClient URI: {blobServiceClient.Uri}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if !SKIP_UNSTABLE_EMULATORS
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

Expand All @@ -18,4 +17,3 @@ public void Run([ServiceBusTrigger("myqueue", Connection = "messaging")] Service
logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
builder.AddAzureQueueClient("queue");
builder.AddAzureBlobClient("blob");
builder.AddAzureEventHubProducerClient("eventhubs", static settings => settings.EventHubName = "myhub");
#if !SKIP_UNSTABLE_EMULATORS
builder.AddAzureServiceBusClient("messaging");
#endif

builder.ConfigureFunctionsWebApplication();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ param principalId string
Assert.Equal(expectedBicep, manifest.BicepText);
}

[Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/dotnet/aspire/issues/7066")]
[Fact]
[RequiresDocker]
public async Task VerifyWaitForOnServiceBusEmulatorBlocksDependentResources()
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public async Task VerifyWaitForOnServiceBusEmulatorBlocksDependentResources()
await app.StopAsync();
}

[Fact(Skip = "Azure ServiceBus emulator is not reliable in CI - https://github.com/dotnet/aspire/issues/7066")]
[Fact]
[RequiresDocker]
public async Task VerifyAzureServiceBusEmulatorResource()
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Aspire.Playground.Tests/ProjectSpecificTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ await WaitForAllTextAsync(app,
resourceName: "funcapp",
timeoutSecs: 160);

#if !SKIP_UNSTABLE_EMULATORS // https://github.com/dotnet/aspire/issues/7066
// Assert that ServiceBus triggers work correctly
await apiServiceClient.GetAsync("/publish/asb");
await WaitForAllTextAsync(app,
Expand All @@ -123,7 +122,6 @@ await WaitForAllTextAsync(app,
],
resourceName: "funcapp",
timeoutSecs: 160);
#endif

// TODO: The following line is commented out because the test fails due to an erroneous log in the Functions App
// resource that happens after the Functions host has been built. The error log shows up after the Functions
Expand Down