Open csharpfritz opened 4 months ago
That sounds great, how would it work? Is there a container that runs the storage explorer that exposes an http endpoint?
The team has a slimmed down version that runs in the Azure Portal. I don't think its available as a container though.
I'm exploring the image at https://github.com/sebagomez/azurestorageexplorer to attach and work with my Aspire hosted Azure Storage instances
I am having a hard time getting that StorageExplorer container connected with a proper connectionstring to a host Azurite emulator.
Any ideas how to pull the connectionstring in AppHost and pass it as an environment variable?
Show me what you have currently?
I've added the following into AppHost, but I can't seem to get the connectionstring passed along. I've tried to grab fragments with no luck
AppHost/Program.cs:
var storage = builder.AddAzureStorage("storage");
if (builder.Environment.IsDevelopment())
{
storage.RunAsEmulator(config =>
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
config.WithDataBindMount("C:\\Temp\\AzureStorage");
else
config.WithDataBindMount("/tmp/AzureStorage");
});
}
builder.AddContainer("storage-explorer", "sebagomez/azurestorageexplorer")
.WithHttpEndpoint(targetPort: 8080);
// .WithEnvironment("AZURE_STORAGE_CONNECTIONSTRING", $"""
// Use the Azurite AccountName and Key:
// DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
// AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
// BlobEndpoint={blobs.Resource.ConnectionStringExpression}/devstoreaccount1;
// """);
var builder = DistributedApplication.CreateBuilder(args);
var storage = builder.AddAzureStorage("storage")
.RunAsEmulator(config => config.WithDataVolume())
.AddBlobs("blobs");
builder.AddContainer("storage-explorer", "sebagomez/azurestorageexplorer")
.WithHttpEndpoint(targetPort: 8080)
.WithEnvironment(e =>
{
e.EnvironmentVariables["AZURE_STORAGE_CONNECTIONSTRING"] = new ConnectionStringReference(storage.Resource, optional: false);
})
.ExcludeFromManifest();
builder.Build().Run();
RunAsEmulator will be used in run mode and not publish mode, so no need to guard it behind the IsDevelopment method. I also swapped from using a bind mount (which needs a host volume) to using a volume (https://docs.docker.com/storage/bind-mounts/). Our azure storage resource only exposes connection strings for specific resources like blob, queue or table. We don't expose the uber connection string since with all 3.
I also added ExcludeFromManifest
to remove this container from being deployed assuming that's what you want to do.
When you call WithReference, this is what happens under the covers (we make a ConnectionStringReference
). There's an API coming post GA that will make this a bit easier:
Very cool! That appears to have that container running and connecting to the storage service. I really need to access the tables browser, so I changed the connectionstring over to the tables instance and it doesn't appear to be connecting like the blobs connectionstring does.
There appears to be a few issues with the Storage Explorer container. I'll connect with that package owner and see if we can get that in a better working order
Huge thanks for the help with this solution!
Hi please is this solution for the azure storage explorer going to eventually be officially integrated to .NET aspire as a container like pgAdmin? That would be so helpful if possible. I am having issues connecting the Microsoft azure monitor to the azurite instance created by aspire.
Configuring the storage explorer like shown above doesn't seem to work as expected for me. The explorer fails to log me in using the supplied connection string. Did someone get this to work for a local Azurite blob storage?
On the first glance, it looks like an issue on the side of storage explorer, not Aspire, so I opened sebagomez/azurestorageexplorer#173 with more details.
Similar to pgAdmin and RedisCommander, it would be convenient to expose an Azure Storage Explorer webpage (similar to the one in the Azure Portal) that allows us to browse our Azurite emulator managed instances