Search code examples
azureazure-blob-storagedotnet-aspire

Azure Blob Storage Error: Missing subscription configuration in .NET Aspire


I'm trying to run Azure blob storage by Aspire so I read this document

so I created Aspire AppHost and added this code to Program.cs file

var builder = DistributedApplication.CreateBuilder(args);

var blobs = builder.AddAzureStorage("storage")
    .AddBlobs("blobs");

builder.Build().Run();

this is my solution files

enter image description here

and I run the project

Expectation: The project creates an azurite container in the docker

Problem: no container running in the docker and I don't know why its two projects are running in the picture and it gives me Error: Missing subscription configuration

enter image description here

and this is the project log file

enter image description here


Solution

  • just run it as Emulator it will fix

    var builder = DistributedApplication.CreateBuilder(args);
    
    var blobs = builder.AddAzureStorage("storage")
        .RunAsEmulator()
        .AddBlobs("blobs");
    
    builder. Build().Run();
    

    and also if you want to have DataVolume use lambda expression for RunAsEmulator

    var blobs = builder.AddAzureStorage("storage")
            .RunAsEmulator(e=>e.WithDataVolume())
            .AddBlobs("blobs");