It seems it stucks while trying acuiring lock for IdentitySessionCleanupBackgroundWorker. The log says it already acquired the lock but this process takes a lot of time or it cannot perform the action: https://github.com/abpframework/abp/blob/d5087c6b940320a3e932be348812d32fe06255a8/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Tokens/TokenCleanupBackgroundWorker.cs#L38-L41
Since it has "Start cleanup."
logs at the beginning of the method:
https://github.com/abpframework/abp/blob/d5087c6b940320a3e932be348812d32fe06255a8/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/TokenCleanupService.cs#L36
Probably one of its dependencies cannot be resolved or causes a problem.
Can you try disabling background workers and deploy it again to make sure if it's the reason or not? https://abp.io/docs/latest/framework/infrastructure/background-workers#options
And also, you can set LogLevel as Debug
to see more details about what happens before freezing
Hi
How can we specify which service tenant database a microservice should work with (e.g., Microservice_Tenant1_Products, Microservice_Tenant2_Products, etc.)?
Do you use micro-serivce template currently or you'll separate your services later? By default we don't suggest using different databases for tenants in the micro-service template currently, if you wish you can rea the discussion from here: https://abp.io/support/questions/8692/Problems-configuring-a-separate-database-for-each-tenant-in-a-microservices-application
If your template is not micro-service, you can customize MultiTenantConnectionStringResolver
in your application
https://github.com/abpframework/abp/blob/74d516829be7f05cfae7d4a67f18591b41e5446a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs#L76-L79
using System;
using Microsoft.Extensions.Options;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
namespace AbpSolution1.AuthServer;
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IConnectionStringResolver), typeof(DefaultConnectionStringResolver))]
public class MicroServiceConnectionStringResolver : MultiTenantConnectionStringResolver
{
private readonly ICurrentTenant _currentTenant;
private readonly IServiceProvider _serviceProvider;
public MicroServiceConnectionStringResolver(IOptionsMonitor<AbpDbConnectionOptions> options, ICurrentTenant currentTenant, IServiceProvider serviceProvider) : base(options, currentTenant, serviceProvider)
{
_currentTenant = currentTenant;
_serviceProvider = serviceProvider;
}
public override async Task<string> ResolveAsync(string? connectionStringName = null)
{
// ⚠️ Implement Your own logic, this is for demonstration
var prefix = "Microservice";
var postfix="Products";
var tenant = _currentTenant.Name;
// ...
return $"Server=myServerAddress;Database={prefix}_{tenant}_{postfix};Trusted_Connection=True;"
}
}
When we add new database migrations at the service, how should we handle them considering that each tenant has its own separate service database? how this migration will be applied to all service tenant dbs?
DbMigrator project applies migrations for all the tenants
Where should I put** "Resolving Entity Tracking Issue"** code from your above suggestion ?
Sorry, IdentityUser has AddLoginAsync
not UpdateLoginAsync
method. You can create your own IdentityUserManager and handle the external login in there. That can be a good point to start tracking what is going on
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IdentityUserManager))]
public class MyIdentityManager : IdentityUserManager
{
public MyIdentityManager(
IdentityUserStore store,
IIdentityRoleRepository roleRepository,
IIdentityUserRepository userRepository,
IOptions<IdentityOptions> optionsAccessor,
IPasswordHasher<Volo.Abp.Identity.IdentityUser> passwordHasher,
IEnumerable<IUserValidator<Volo.Abp.Identity.IdentityUser>> userValidators,
IEnumerable<IPasswordValidator<Volo.Abp.Identity.IdentityUser>> passwordValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
IServiceProvider services,
ILogger<IdentityUserManager> logger,
ICancellationTokenProvider cancellationTokenProvider,
IOrganizationUnitRepository organizationUnitRepository,
ISettingProvider settingProvider,
IDistributedEventBus distributedEventBus,
IIdentityLinkUserRepository identityLinkUserRepository,
IDistributedCache<AbpDynamicClaimCacheItem> dynamicClaimCache) : base(store, roleRepository, userRepository, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger, cancellationTokenProvider, organizationUnitRepository, settingProvider, distributedEventBus, identityLinkUserRepository, dynamicClaimCache)
{
}
public override async Task<IdentityResult> AddLoginAsync(Volo.Abp.Identity.IdentityUser user, UserLoginInfo login)
{
if(login.ProviderKey == "PingOne")
{
// Handle PingOne login
}
return await base.AddLoginAsync(user, login);
}
}```
Hi,
While you developing a Module, you shouldn't create migrations inside module since it's re-usable project that can be consumed by multiple applications. You should create migrations in your end application that consumes your module.
You can call builder.ConfigureModule1();
extension method in your application's DbContext to configure entities from your module and then create migrations in application. If you created DDD Module while creating it, there should already be Module1DbContextModelCreatingExtensions.cs
and you can configure your entities there, you can configure entities from module in that extension method nad use it wherever you use use that module like any other ABP modules.
Hi,
Do you deploy database in the cluster at the same time, too? Since there is no error log it's pretty hard to understand the problem but there can be some connection problems such as trying to connect redis or database or other services if it's a microservice application
Hi,
It's possible but also it seems not stable.
ABP supports using database separation across tenants. Whenever you separate database for a tenant you'll not be able to combine all the data between tennats
In the scenario you'll use always same database;
You don't have to implement your own repositories. You can use CurrentTenant.Change()
method inside a using scope to change the tenant you want to access its data.
using (CurrentTenant.Change(tenantId))
{
return await _productRepository.GetCountAsync();
}
Check here: https://abp.io/docs/latest/framework/architecture/multi-tenancy#change-the-current-tenant
You can iterate all the tenants inside a foreach loop in this way:
var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
foreach (var tenant in tenants)
{
using (_currentTenant.Change(tenant.Id))
{
var users = _userRepository.GetList(/*...*/);
Logger.LogInformation($"Tenant {tenant.Name} has {users.Count} users.");
}
}
Hi,
It seems it's not an expected situation. I'll deliver this problem to the ABP Suite team and inform you about if it's bug or not.
Thanks
I think docs module uses a different layout which is EmptyLayout
:
https://github.com/abpframework/abp/blob/0b6ae95866a884f054f1684cea0eba62082b3e46/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml#L32
You can override this cdhtml
file in your project and copy all the content from the link I gave you above, and just replace
Layout = ThemeManager.CurrentTheme.GetEmptyLayout();
line with
Layout = ThemeManager.CurrentTheme.GetApplicationLayout();
and documents will start using your application layout.
Still I cannot guarantee it looks good or not
You can override cshtml files by placing them the exact same folders in your application:
https://abp.io/docs/latest/framework/ui/mvc-razor-pages/customization-user-interface#overriding-a-razor-page-cshtml
Hi,
Can you check this post? https://abp.io/support/questions/5480/Does-ABP-support-Active-Directory-LDAP--and-Azure-AD#answer-3a0ca8b8-f0a4-e087-6489-84a6d88ad04c
It doesn't matter if your application MVC, Blazor or angular. Still your authentication is done by ASP.NET Core and all the options are same.
If you use separated authserver solutioın, you'll configure it in your AuthServer application.
So this will work on your Blazor project: https://abp.io/community/articles/how-to-use-the-azure-active-directory-authentication-for-mvc-razor-page-applications-4603b9cf
Hi,
Can you check browser console if there is an error? You may need to click again after opening the browser console to get output, if there is problem in the console, please share with us to determine the problem.
By the way, can you try updating bundles by executing abp bundle
command inside your blazor wasm (Blazor.Client
) project?