dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.61k stars 403 forks source link

Unable to use Azure table-storage with Orleans reminders #4010

Open vyliniem opened 4 months ago

vyliniem commented 4 months ago

Not sure if this is Aspire, Orleans or user issue, but I am unable to use Azure table-storage with reminders. This happens when running locally (preview 5 & 6) using either Aspire provisioned storage-account or storage-emulator. Orleans setup with development-clustering and memory-storages works fine.

// AppHost:
var tables = builder.AddAzureStorage("storage").AddTables("tables");
-- OR --
var tables = builder.AddAzureStorage("storage-emulator").RunAsEmulator().AddTables("tables");

var orleans = builder.AddOrleans("myapp-cluster")
  .WithClustering(tables)
  .WithGrainStorage("myapp-grains", tables)
  .WithReminders(tables);

// Orleans-resource:
builder.AddKeyedAzureTableClient("tables");
builder.UseOrleans();

Above setup causes orleans-resources to exit with error: System.InvalidOperationException: Could not find Reminders provider named 'AzureTableStorage'. This can indicate that either the 'Microsoft.Orleans.Sdk' or the provider's package are not referenced by your application.

If I switch reminders to use Redis then everything works as expected.

Trying to use table-storage resource with connection-string (builder.AddConnectionString(...)) causes an error with clustering: System.InvalidOperationException: Could not find Clustering provider named 'ResourceWithConnectionStringSurrogate'. This can indicate that either the 'Microsoft.Orleans.Sdk' or the provider's package are not referenced by your application.

Adding Orleans.SDK makes no difference and since Orleans.Server package is present it shouldn't be needed anyways:

<PackageReference Include="Aspire.Azure.Data.Tables" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Microsoft.Orleans.Server" Version="8.1.0" />
<PackageReference Include="Microsoft.Orleans.Clustering.AzureStorage" Version="8.1.0" />
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="8.1.0" />
<PackageReference Include="Microsoft.Orleans.Reminders.AzureStorage" Version="8.1.0" />

Am I missing some packages or Aspire-setup here?

abbottdev commented 1 month ago

I'm also having the same issue! I'm using the latest packages and I'm getting this exception:

Exception thrown: 'System.InvalidOperationException' in Orleans.Runtime.dll: 'Could not find Clustering provider named 'AzureTableStorage'. This can indicate that either the 'Microsoft.Orleans.Sdk' or the provider's package are not referenced by your application.'
   at Orleans.Hosting.DefaultSiloServices.<ApplyConfiguration>g__GetRequiredProvider|2_3(Dictionary`2 knownProviderTypes, String kind, String name)
   at Orleans.Hosting.DefaultSiloServices.<ApplyConfiguration>g__ConfigureProvider|2_2(ISiloBuilder builder, Dictionary`2 knownProviderTypes, String kind, String name, IConfigurationSection configurationSection)
   at Orleans.Hosting.DefaultSiloServices.<ApplyConfiguration>g__ApplySubsection|2_5(ISiloBuilder builder, IConfigurationSection cfg, Dictionary`2 knownProviderTypes, String sectionName)
   at Orleans.Hosting.DefaultSiloServices.ApplyConfiguration(ISiloBuilder builder)
   at Orleans.Hosting.DefaultSiloServices.AddDefaultServices(ISiloBuilder builder)
   at Orleans.Hosting.SiloBuilder..ctor(IServiceCollection services, IConfiguration configuration)
   at Microsoft.Extensions.Hosting.OrleansSiloGenericHostExtensions.AddOrleansCore(IServiceCollection services, IConfiguration configuration)
   at Microsoft.Extensions.Hosting.OrleansSiloGenericHostExtensions.UseOrleans(IHostApplicationBuilder hostAppBuilder, Action`1 configureDelegate)
   at Program.<<Main>$>d__0.MoveNext() in c:\Repos\Gymotion\Gymotion.Service\Program.cs:line 8

It looks like DefaultSiloServices: ApplySubsection(builder, cfg, knownProviderTypes, "Clustering"); https://github.com/dotnet/orleans/blob/92e0bf37048cd8e6c728fba008fd4cfbbd647435/src/Orleans.Runtime/Hosting/DefaultSiloServices.cs#L436

Is failing, which suggests the above change needs to remain named "Clustering"?

This would suggest the code in the linked PR above may have altered service registration @Costo ? (cc @ReubenBond )

ReubenBond commented 1 month ago

Which packages do you have installed on the silo project, @abbottdev ?

abbottdev commented 1 month ago

Hey @ReubenBond

Silo project:

    <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
    <PackageReference Include="Aspire.Azure.Data.Tables" Version="8.0.1" />
    <PackageReference Include="Aspire.Azure.Storage.Blobs" Version="8.0.1" />
    <PackageReference Include="Aspire.Azure.Storage.Queues" Version="8.0.1" />
    <PackageReference Include="Microsoft.Orleans.Server" Version="8.2.0" />
    <PackageReference Include="Microsoft.Orleans.Sdk" Version="8.2.0" />
    <PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="8.2.0" />
    <PackageReference Include="Microsoft.Orleans.Clustering.AzureStorage" Version="8.2.0" />
    <PackageReference Include="Microsoft.Orleans.Reminders.AzureStorage" Version="8.2.0" />
    <PackageReference Include="Microsoft.Orleans.Streaming.AzureStorage" Version="8.2.0" />

AppHost:

    <PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.1" />
    <PackageReference Include="Aspire.Hosting.Azure.Storage" Version="8.0.1" />
    <PackageReference Include="Aspire.Hosting.Orleans" Version="8.0.1" />

EDIT: Realise the version numbers were slightly outdated but is still an issue with the 8.0.2 aspire packages.

abbottdev commented 1 month ago

@ReubenBond I can't repro this issue using the latest packages for table backed storage. I can however reproduce an issue with streaming which I've raised in the Orleans repo and linked above.

t13ka commented 3 weeks ago

in my case a have got this error: "Could not find Clustering provider named MongoDBDatabase"

yoDon commented 4 days ago

This issue happens in the official Microsoft Use Orleans with .NET Aspire docs.

The docs say to call builder.AddAzureStorage("storage"), but the method is undefined and there is no indication what NuGet package might contain that method.

davidfowl commented 1 day ago

cc @ReubenBond