Skip to content

The Azure Storage APIs are a bit confusing and misleading #6875

@IEvangelist

Description

@IEvangelist

Background and Motivation

The current Azure Storage API is a bit confusing and misleading. Today, when you call AddAzureStorage it adds provisioning and infrastructure details, including roles, to the Azure storage resource for blobs, queues, and tables. This happens regardless of whether or not you call AddBlobs, AddQueues, or AddTables. It might make more sense to instead change these specific APIs to be GetBlobs, GetQueues, and GetTables instead without the name parameter.

Proposed API

namespace Aspire.Hosting;

public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageResource> AddAzureStorage(
        this IDistributedApplicationBuilder builder, [ResourceName] string name)
    {
        // ...
    }

   // Omitted for brevity...

    public static IResourceBuilder<AzureBlobStorageResource> GetBlobs(
        this IResourceBuilder<AzureStorageResource> builder);

    public static IResourceBuilder<AzureTableStorageResource> GetTables(
        this IResourceBuilder<AzureStorageResource> builder);

    public static IResourceBuilder<AzureQueueStorageResource> GetQueues(
        this IResourceBuilder<AzureStorageResource> builder);
}

Usage Examples

var builder = DistributedApplication.CreateBuilder(args);

var storage = builder.AddAzureStorage("storage").RunAsEmulator(static container =>
{
    container.WithDataBindMount();
});

var blobs = storage.GetBlobs();
var queues = storage.GetQueues();
var table = storage.GetTables();

// Use storage bits...

builder.Build().Run();

Alternative Designs

Risks

This is a breaking change, and will require obsoleting existing AddBlobs, AddQueues, and AddTables APIs.

Metadata

Metadata

Assignees

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesazureIssues associated specifically with scenarios tied to using Azureazure-storageIssues related to azure storage integration

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions