Skip to content
Draft
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
26 changes: 18 additions & 8 deletions docs/docs/rules/sw103-avoid-microsoft-extensions-azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ builder.Services.AddAzureClients(clients =>
// Program.cs / Startup.cs
// No Microsoft.Extensions.Azure import required

builder.Services.AddKeyedSingleton<BlobServiceClient>("blob-storage", (sp, _) =>
new BlobServiceClient(
builder.Configuration.GetConnectionString("BlobStorage")));
builder.Services.AddAzureBlobClient("blob-storage");
builder.Services.AddAzureQueueClient("order-queue");
builder.Services.AddAzureTableClient("order-table");
```

These Aspire wrappers keep the same resource key naming story and register keyed clients that can be resolved with `[FromKeyedServices("...")]`.

builder.Services.AddKeyedSingleton<QueueServiceClient>("order-queue", (sp, _) =>
new QueueServiceClient(
builder.Configuration.GetConnectionString("OrderQueue")));
```csharp
public class QueueWorker(
[FromKeyedServices("order-queue")] QueueServiceClient queueClient,
[FromKeyedServices("order-table")] TableServiceClient tableClient)
{
}
```

#### DI callsite — before (`IAzureClientFactory<T>`)
Expand Down Expand Up @@ -112,8 +118,12 @@ public class BlobUploadService

## Related Documentation

- Aspire Azure Storage Blobs integration (keyed/resource-oriented approach):
https://aspire.dev/integrations/cloud/azure/azure-storage-blobs/azure-storage-blobs-connect/#blob-storage-resource
- Aspire Azure Storage Blobs client:
https://aspire.dev/integrations/cloud/azure/azure-storage-blobs/azure-storage-blobs-client/
- Aspire Azure Storage Queues client:
https://aspire.dev/integrations/cloud/azure/azure-storage-queues/azure-storage-queues-client/
- Aspire Azure Data Tables client:
https://aspire.dev/integrations/cloud/azure/azure-data-tables/azure-data-tables-client/
- Azure SDK discussion:
https://github.com/Azure/azure-sdk-for-net/issues/40408#issuecomment-3599496883
- Azure SDK follow-up issue:
Expand Down