Activities of "O_SAG"

Thank you. You have been very helpful.

I don't understand; you can use the same DB container instead of create a new DB container.

Those are unfortunately our requirements: We have to be able to host every tenant db on a separate server, which means every tenant db needs to be a separate container.

you don't need to do it; ABP will publish a tenant-created event, and the handler will create a database.

Ok. So we could modify HandleEventAsync() of this handler to call a script on the server to create the docker container and only then apply the migration?

Thank you for your answers. We have more questions:

We want to automate the tenant creation process. Since we want our tenant dbs in docker containers, before the tenant db is created and seeded we need to create the docker container (with a script executed on the server), and only then we know what the connection string for the tenant will look like.

As a second step, we plan to execute the DbMigrator to apply migrations and seeding data to this newly created tenant db container.

Is there a way to pass seeding data to the DbMigrator when executing it with dotnet run? Asked another way: How does the DbMigrator get the admin credentials of a newly created tenant if it is executed separately with dotnet run?

Or does it make more sense to inject the DbMigrator Service in the backend and execute it that way instead?

Sorry, but this does not answer my questions at all.

I was first of all asking for a general guide, a summary or something else concerning a multi-tenant architecure with separate tenant dbs (for example in docker containers on another server than the host db). I believe we would not be the only ones working with abp who would profit from having such a guide, since the documentation is lacking in this topic.


Secondly, it seems you are talking about a out-of-the box abp commercial solution with the saas module. We are aware of this. This was not the question, however.

We need to know how to get to this point with our architecture. There needs to happen some setup for what you said to work with separate tenant dbs.

Questions:

  • Do we need a 2. DbContext for all TenantDBs (with MultiTenancySide=Tenant)?
  • Does the DbMigrator support migrations and data seeding without extra modification for a multi-tenant architecure with separate tenant dbs? (assuming everything else is correctly set up)
  • How do we customize the seeding data for every tenant (like, a admin user with a certain password)?
  • If running the DbMigrator separately (with dotnet run), how does the DbMigrator find out which tenants are new and need to be setup and data seeded?

Thank you, it works now. I must have confused the packages.

You were right. I solved it. AbpLicenceCode in appsettings.secrets.json was not read in, because we added custom code to read in appsettings from different environments, which did not read in the secrets file since we did not need it before.

Now that the DbMigrator has the Licence Code, it does not crash anymore.

Maybe a suggestion: There should be an error message thrown, its really confusing and inconvenient if the program silently crashes.

Thank you for your help @liangshiwei

Further investigations:

  • dotnet build works without issues
  • The error occures in await application.InitializeAsync(); in StartAsync() in DbMigratorHostedService.cs:
public async Task StartAsync(CancellationToken cancellationToken)
    {
        Console.WriteLine("Starting DbMigrator...");
        using var application = await AbpApplicationFactory.CreateAsync<CapDbMigratorModule>(options =>
        {
            options.Services.ReplaceConfiguration(_configuration);
            options.Services.ReplaceConfiguration(BuildConfiguration());
            options.UseAutofac();
            options.Services.AddLogging(c => c.AddSerilog());
            options.AddDataMigrationEnvironment();
        });
        
        Console.WriteLine("0");
        
        await application.InitializeAsync();
        
        Console.WriteLine("1");

        await application
            .ServiceProvider
            .GetRequiredService<CapDbMigrationService>()
            .MigrateAsync();
        
        Console.WriteLine("2");

        await application.ShutdownAsync();
        
        Console.WriteLine("3");

        _hostApplicationLifetime.StopApplication();
        Console.WriteLine("DbMigrator finished.");
    }

It does not reach Console.WriteLine("1");. Now it comes to abp internals of which I have no idea. Maybe this helps?

You can try configure the appsettings.secrets.json

Thanks, but this is already implemented like you suggested. I'm not sure appsettings.secrets.json is even the problem :(

I figured it out - I had to remove these two Packages from the .csproj File:

<PackageReference Include="Volo.Abp.Account.Application" Version="8.0.3" />
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="8.0.3" />

Thank you.

Showing 1 to 9 of 9 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07