Open Closed

Split the Abp Saas Module as a Microservice #505


User avatar
0
Mohammad created

Hello

We are working on a project based on microservice architecture.

How can we divide the Pro Saas Module as a Microservice architecture. Could you provide samples for each module.

  1. Microservice
  2. Gateway
  3. Application

Also could you explains how the httpapi, Application, Efcore httpApi.Client Project seperation works in case of Microservices project structure.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: vX.X.X
  • UI type: Angular / MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

19 Answer(s)
  • User Avatar
    0
    lanpin created

    I used the Chat module in my project. Before version 3.0.2, the ChatFeatureDefinitionProvider of the Chat module set ChatFeatures.Enable to true by default, and the default is false after the upgrade. It caused me to have to enable the feature-management module and the Saas module, but these two modules are not for microservices. Very friendly. I cannot integrate them easily. I wanted to learn something from Permission-Management, but it didn't work. I need help.

  • User Avatar
    0
    alper created
    Support Team Director

    @Mohammad this document explains your question in details https://docs.abp.io/en/abp/latest/Best-Practices/Module-Architecture

  • User Avatar
    0
    Mohammad created

    Hello @alper

    I understand that the document explains the Module Architecture. But my question involves the below three layers.

    How to Segregate the module architecture for the below microservice architecture example provided by your company

    Take for example the Volo.Saas Package. Which projects would go under each folder.

    Microservice Which Saas Packages to include in the service Gateway Which Saas Packages to include in the Gateway Application Application Which Saas Packages to include in the Application

    Awaiting your quick response as its urgent to our developement roadmap

    Thank you

  • User Avatar
    0
    alper created
    Support Team Director

    This is the solution structure of the SaaS package

    This module package is not a final application. You need to include this package in your final app. You can create a final app for each module (to be able to publish as individually) or you can put them all in a monolith app. In your case I think you want your SaaS package as a separate app.

    You can create a new HttpApi.Host project using HttpApi project and you can put this app behind the Gateway (so that you can rate limit or load balance your API)

    Host.Web and Blazor projects are the applications. These project has UI pages.

  • User Avatar
    0
    hikalkan created
    Support Team Co-Founder

    Hi,

    Microservice: Which Saas Packages to include in the service

    • *.HttpApi
    • *.Application
    • *.EntityFrameworkCore (or MongoDB, based on your domain)

    This is explained in the document as the following:

    Gateway: Which Saas Packages to include in the Gateway Application

    • *.HttpApi
    • *.HttpApi.Client

    This is explained in the document as the following:

    UI Application: Which Saas Packages to include in the UI Application

    • *.Web
    • *.HttpApi.Client

    This is explained in the document as the following:

    If your UI is angular, then you only need to add the related NPM package (@volo/saas)

    This is the package distributon. But, every microservice solution is unique. Adding packages is only the beginning. You need then configure the authentication, gateway and other parts of your solution. You need to understand all the aspects and build your own solution. This is why https://docs.abp.io/en/abp/latest/Best-Practices/Module-Architecture document is essential.

    I hope this helps at the beginning :)

  • User Avatar
    0
    Mohammad created

    Thank you. This was very Informative.

  • User Avatar
    0
    Mohammad created

    When I run the sample microservice

    Identityservice

    Route: /api/identity/roles/all

    I get this error. Could you help resolve this error. I have added JWT token in the bearer token authentication

    { "error": { "code": null, "message": "Authorization failed! Given policy has not granted.", "details": null, "data": null, "validationErrors": null } }

    Thank you

  • User Avatar
    0
    Mohammad created

    Also can you explain which modules to use in the dependson.

    From the guide above. It mentions to use Application Project. But in the Auth Server (Microservices Demo). AbpTenantManagementApplicationContractsModule Contracts module is used in the depends on.

    How to decide on the usage?

    Thank You

  • User Avatar
    0
    hikalkan created
    Support Team Co-Founder

    Auth Server is not a microservice (that servers the tenant management API). It is the authentication server. We add AppContract to it since TenantManagementAppContracts package contains the permission definitions related to the tenant management. Auth Server needs to know all the permissions.

  • User Avatar
    0
    Mohammad created

    Hi

    I am getting this error on the identityservice api

    { "error": { "code": null, "message": "Authorization failed! Given policy has not granted.", "details": null, "data": null, "validationErrors": null } }

    I am logged in with the admin.

    2020-10-26 08:47:42.934 +03:00 [INF] Request finished in 71496.9471ms 500 2020-10-26 08:53:54.560 +03:00 [INF] Request starting HTTP/2.0 GET https://localhost:44311/
    2020-10-26 08:53:54.569 +03:00 [WRN] Could not find IdentityClientConfiguration for . Either define a configuration for or set a default configuration. 2020-10-26 08:53:54.569 +03:00 [INF] Start processing HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:53:54.569 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:53:54.583 +03:00 [INF] Received HTTP response after 14.5985ms - "InternalServerError" 2020-10-26 08:53:56.592 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:53:56.604 +03:00 [INF] Received HTTP response after 11.2953ms - "InternalServerError" 2020-10-26 08:54:00.616 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:00.626 +03:00 [INF] Received HTTP response after 10.3383ms - "InternalServerError" 2020-10-26 08:54:08.638 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:08.649 +03:00 [INF] Received HTTP response after 10.664ms - "InternalServerError" 2020-10-26 08:54:10.654 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:10.665 +03:00 [INF] Received HTTP response after 10.7143ms - "InternalServerError" 2020-10-26 08:54:12.670 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:12.701 +03:00 [INF] Received HTTP response after 31.5501ms - "InternalServerError" 2020-10-26 08:54:16.713 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:16.728 +03:00 [INF] Received HTTP response after 14.9425ms - "InternalServerError" 2020-10-26 08:54:24.736 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:24.748 +03:00 [INF] Received HTTP response after 11.8249ms - "InternalServerError" 2020-10-26 08:54:28.749 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:28.760 +03:00 [INF] Received HTTP response after 10.6523ms - "InternalServerError" 2020-10-26 08:54:30.771 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:30.783 +03:00 [INF] Received HTTP response after 12.145ms - "InternalServerError" 2020-10-26 08:54:34.795 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:34.806 +03:00 [INF] Received HTTP response after 11.4928ms - "InternalServerError" 2020-10-26 08:54:42.810 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:42.820 +03:00 [INF] Received HTTP response after 10.3106ms - "InternalServerError" 2020-10-26 08:54:50.828 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:50.838 +03:00 [INF] Received HTTP response after 10.3042ms - "InternalServerError" 2020-10-26 08:54:52.846 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:52.857 +03:00 [INF] Received HTTP response after 10.8905ms - "InternalServerError" 2020-10-26 08:54:56.857 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:54:56.866 +03:00 [INF] Received HTTP response after 9.5353ms - "InternalServerError" 2020-10-26 08:55:04.873 +03:00 [INF] Sending HTTP request GET "https://localhost:44372/api/abp/application-configuration?api-version=1.0" 2020-10-26 08:55:04.881 +03:00 [INF] Received HTTP response after 8.7098ms - "InternalServerError" 2020-10-26 08:55:04.881 +03:00 [INF] End processing HTTP request after 70312.866ms - "InternalServerError" 2020-10-26 08:55:04.883 +03:00 [ERR] Connection ID "18374686524231909440", Request ID "80000041-000a-ff00-b63f-84710c7967bb": An unhandled exception was thrown by the application. Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request! at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.MakeRequestAsync(IAbpMethodInvocation invocation) at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.MakeRequestAndGetResultAsync[T](IAbpMethodInvocation invocation) at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.GetResultAsync(Task task, Type resultType) at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor1.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient.<GetAsync>b__14_0() at Volo.Abp.Caching.DistributedCache2.GetOrAddAsync(TCacheKey key, Func1 factory, Func1 optionsFactory, Nullable1 hideErrors, Boolean considerUow, CancellationToken token) at Volo.Abp.AspNetCore.Mvc.Client.MvcCachedApplicationConfigurationClient.GetAsync() at Volo.Abp.AspNetCore.Mvc.Client.RemoteLanguageProvider.GetLanguagesAsync() at Microsoft.AspNetCore.RequestLocalization.DefaultAbpRequestLocalizationOptionsProvider.GetLocalizationOptionsAsync() at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync() 2020-10-26 08:55:04.885 +03:00 [INF] Request finished in 70325.2576ms 500

  • User Avatar
    0
    Mohammad created

    How to Configure SAAS Menu Links to the Module Navigation?

  • User Avatar
    0
    alper created
    Support Team Director

    It looks like a IDS4 configuration issue.

    did you run the DbMigrator project? If you are using the same database as your previous projects you may get this exception. Be sure that you create a new database with the DbMigrator project.

  • User Avatar
    0
    Mohammad created

    Thanks. It was a problem with referencing different versions of packages.

    Could you help me with

    How to Configure SAAS Menu Links to the Module Navigation?

    The saas menu is not appearing.

    Also the Identity Service Shows Authorization Failed for Admin User. at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() 2020-10-26 14:58:29.143 +03:00 [ERR] IDX20803: Unable to obtain configuration from: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. System.InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. ---> System.IO.IOException: IDX20804: Unable to retrieve document from: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request.. ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request. --- End of inner exception stack trace ---

  • User Avatar
    0
    Mohammad created

    Is this code valid to display the saas management module menu?

    Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new BackendAdminAppMenuContributor(configuration)); options.MenuContributors.Add(new SaasHostMenuContributor()); options.MenuContributors.Add(new SaasTenantMenuContributor()); });

  • User Avatar
    0
    alper created
    Support Team Director

    yes but you need to add the dependencies with DependsOn attribute https://github.com/abpframework/abp/blob/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs

  • User Avatar
    0
    Mohammad created

    HI @alper

    I have added the dependencies but still the saas menu is not visible.

    [DependsOn( typeof(AbpAutofacModule), typeof(AbpAspNetCoreMvcClientModule), typeof(AbpAspNetCoreAuthenticationOAuthModule), typeof(AbpHttpClientIdentityModelWebModule), typeof(AbpIdentityHttpApiClientModule), typeof(AbpIdentityWebModule), typeof(AbpTenantManagementHttpApiClientModule), typeof(AbpTenantManagementWebModule), typeof(AbpPermissionManagementHttpApiClientModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpFeatureManagementHttpApiClientModule), typeof(SaasHostWebModule), typeof(SaasTenantWebModule), typeof(SaasHostHttpApiClientModule), typeof(SaasTenantHttpApiClientModule) )]

    these are the DependsOn

  • User Avatar
    1
    alper created
    Support Team Director

    see this class as an example:

    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Volo.Saas.EntityFrameworkCore;
    using Microsoft.OpenApi.Models;
    using Swashbuckle.AspNetCore.Swagger;
    using System.IO;
    using System.Linq;
    using Microsoft.Extensions.Hosting;
    using Volo.Abp;
    using Volo.Abp.Account;
    using Volo.Abp.Account.Web;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
    using Volo.Abp.Authorization.Permissions;
    using Volo.Abp.Autofac;
    using Volo.Abp.Data;
    using Volo.Abp.EntityFrameworkCore;
    using Volo.Abp.EntityFrameworkCore.SqlServer;
    using Volo.Abp.Identity;
    using Volo.Abp.Identity.EntityFrameworkCore;
    using Volo.Abp.Identity.Web;
    using Volo.Abp.Localization;
    using Volo.Abp.Modularity;
    using Volo.Abp.PermissionManagement;
    using Volo.Abp.PermissionManagement.EntityFrameworkCore;
    using Volo.Abp.PermissionManagement.Identity;
    using Volo.Abp.SettingManagement.EntityFrameworkCore;
    using Volo.Abp.Threading;
    using Volo.Abp.VirtualFileSystem;
    using Volo.Saas.Host;
    
    namespace Volo.Saas.DemoApp
    {
        [DependsOn(
            typeof(SaasHostWebModule),
            typeof(SaasHostApplicationModule),
            typeof(SaasEntityFrameworkCoreModule),
    
            typeof(AbpPermissionManagementEntityFrameworkCoreModule),
            typeof(AbpSettingManagementEntityFrameworkCoreModule),
            typeof(AbpIdentityEntityFrameworkCoreModule),
            typeof(AbpEntityFrameworkCoreSqlServerModule),
    
            typeof(AbpAccountWebModule),
            typeof(AbpIdentityWebModule),
            typeof(AbpIdentityApplicationModule),
            typeof(AbpPermissionManagementApplicationModule),
            typeof(AbpPermissionManagementDomainIdentityModule),
            typeof(AbpAutofacModule),
            typeof(AbpAspNetCoreMvcUiBasicThemeModule),
            typeof(AbpAccountApplicationModule)
            )]
        public class DemoAppModule : AbpModule
        {
            public override void ConfigureServices(ServiceConfigurationContext context)
            {
                var hostingEnvironment = context.Services.GetHostingEnvironment();
                var configuration = context.Services.GetConfiguration();
    
                Configure<AbpDbConnectionOptions>(options =>
                {
                    options.ConnectionStrings.Default = configuration.GetConnectionString("Default");
                });
    
                Configure<AbpDbContextOptions>(options =>
                {
                    options.UseSqlServer();
                }); 
                
                context.Services.AddSwaggerGen(
                    options =>
                    {
                        options.SwaggerDoc("v1", new OpenApiInfo { Title = "Saas API", Version = "v1" });
                        options.DocInclusionPredicate((docName, description) => true);
                        options.CustomSchemaIds(type => type.FullName);
                    });
    
                Configure<AbpLocalizationOptions>(options =>
                {
                    options.Languages.Add(new LanguageInfo("en", "en", "English"));
                    //...add other languages
                });
            }
    
            public override void OnApplicationInitialization(ApplicationInitializationContext context)
            {
                var app = context.GetApplicationBuilder();
    
                if (context.GetEnvironment().IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
                else
                {
                    app.UseErrorPage();
                }
    
                app.UseVirtualFiles();
                
                app.UseRouting();
    
                app.UseSwagger();
                app.UseSwaggerUI(options =>
                {
                    options.SwaggerEndpoint("/swagger/v1/swagger.json", "Test APP API");
                });
    
                app.UseAuthentication();
                app.UseAbpRequestLocalization();
                app.UseAuditing();
    
                app.UseConfiguredEndpoints();
    
                using (var scope = context.ServiceProvider.CreateScope())
                {
                    AsyncHelper.RunSync(async () =>
                    {
                        await scope.ServiceProvider
                            .GetRequiredService<IDataSeeder>()
                            .SeedAsync();
                    });
                }
            }
        }
    }
    
    
  • User Avatar
    0
    Qusai created

    Hi @alper i hope you are fine

    It seems like there is a problem with volo.abpcommercial packages.

    first of all most of the new version (4.0.0) packages are not compatible with netcoreapp 3.1

    and another thing is that ABP Commercial NuGet Source is not working probably , most of the packages disappeard , and sometimes there is this error [ABP Commercial NuGet Source] The source does not have a Search service!

    and it has been like this for 2 days, so any ideas on what to do here ?

    Regards

  • User Avatar
    0
    alper created
    Support Team Director

    we have upgraded to .NET5 in v4.0 https://blog.abp.io/abp/ABP.IO-Platform-v4.0-RC-Has-Been-Released-based-on-.NET-5.0

    for the NuGet issue, can you clear your NuGet cache and then restore your project

    dotnet nuget locals -c all
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09