Table storage configuration documentation and examples #3701
iamandymcinnes
started this conversation in
General
Replies: 1 comment 2 replies
-
If you don't want Aspire to create a storage account for you, you can use the So for example you would have the following in your AppHost: var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache");
var tables = builder.AddConnectionString("tables");
var apiService = builder.AddProject<Projects.MyApp_ApiService>("apiservice")
.WithReference(tables);
builder.AddProject<Projects.MyApp_Web>("webfrontend")
.WithReference(cache)
.WithReference(apiService);
builder.Build().Run(); Then in the user secrets for your apphost you would have this: {
"Parameters": {
"tables": "<connectionstring to table endpoint configured for token auth>"
}
} That said it can be quite convienient for Aspire to manage the creation of a storage account for you. It will automatically create and configure the storage account for local development. You can also use the Azurite storage emulator simply by doing this: var tables = builder.AddAzureStorage("storage").UseEmulator().AddTables("tables"); So you've got a few different approaches there! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
I'm on preview4 but trying to follow the documentation / tutorials about connecting to azure storage but not having much luck.
I've been trying to use my microsoft user account that I'm signed in to VS with to authenticate and then use the aspire configuration providers as per: https://learn.microsoft.com/en-us/dotnet/aspire/storage/azure-storage-tables-component?tabs=dotnet-cli#use-configuration-providers
In my ApiService program.cs I have
And my AppHost program.cs I have
I have already created the storage account in azure, but when I debug my apphost it then creates a new storage account in the resource group of the one I manually created called "storageq66avpocuvt3s". And then when I try to perform any actions against that table store in my ApiService code i.e. CreateIfNotExists on the table store, it errors saying I don't have permission. I checked that IAM details and my user is both Owner and Storage Table Data Contributor.
So the real question I have is, how do I connect to an existing storage account, i.e. don't create a new one and the tutorials for example, just use the storage emulator, which doesn't really help either.
Finally, I really like the storage provider structure for your appsettings.json for things like connecting to a storage account and then using DefaultAzureCredential provider or whatever to cycle through credential options like environment variables etc, but all the examples and documentation talk about the aspire settings providers, but then all go on to only use the example of using the connectionstring instead. One question I have and perhaps it's just me misunderstanding, but I thought the point of the AppHost structure was to deliver the required config to each of the services from the AppHost, but it's not clear in the documentation (or examples as they all use the storage emulator) which appsettings.json should have what config. Should I just be able to just put all the config in the AppHosts appsettings and it deliver the required config out to the services or do you just do it in the traditional way of just adding the required config the appsettings for the service that needs those settings and not in the AppHosts appsettings.json?
Beta Was this translation helpful? Give feedback.
All reactions