Azure Queue Storage is a queue service within an Azure Storage account. It enables asynchronous communication between applications and services, offering straightforward message handling for basic task management. section 7.2
In an online shop, the order-placement endpoint publishes an order-created message; a location-tracking background service consumes it and updates delivery information. This lets the update run in the background rather than delaying the user-facing request. section 7.2 section 7.2.3
A typical Aspire setup connects the applications to a queue through these steps:
- Add an emulated Azure Storage component and its queue in the Aspire host, then reference the queue from the API and frontend projects. section 7.2.1
- Register the queue client in the API, create the `orders-created` queue if needed, and send a serialized order message. section 7.2.2
- Use a background service to receive up to ten messages per iteration and process each order. section 7.2.3
var storage = builder.AddAzureStorage("storage")
.RunAsEmulator();
var queues = storage.AddQueues("queues");
builder
.AddProject<Projects.OnlineShop_ApiService>(
"apiservice")
.WaitFor(queues)
.WithReference(queues)...
Aspire host configuration for running Azure Storage with an emulator and adding a queue. section 7.2.1
var queueClient = queueServiceClient
.GetQueueClient("orders-created");
await queueClient.CreateIfNotExistsAsync();
while (!stoppingToken.IsCancellationRequested)
{
QueueMessage[] messages = queueClient
.ReceiveMessages(maxMessages: 10);
foreach (var message in messages)
{
var body =
JsonSerializer.Deserialize<OrderCreatedMessage>(message.MessageText);
await SetInitialDeliveryLocation(
body.OrderId,
stoppingToken);
}
}
A background-service example that creates the queue, receives message batches, and processes order IDs. section 7.2.3

