- ABP Framework version: v5.3.0
- UI type: Blazor-server
- DB provider: EF Core / MongoDB
- Tiered (MVC) or Identity Server Separated (Angular): yes
I have built up a microservice solution and would like to add an other project based on the standard template pro as service to it. At the end my solution will look similiar to you eshoponabp project, where you use postgres and mongo as db.
i did follow the doc from here: https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice to generate a service with the same name. It seems that the parameter for the database provider is ignored (-d mongo) . It always creates a service based on EF. Is this a bug ?
I did also compare the generated files from the new service with the files from the standard template pro and found differences in the module files and structure. I would like to know howto modify the files from the standard template to be able to use it as service in the microservice solution.
As far as i can see, i need to edit all csproj files and *module.cs files to remove unneeded things and add at least something like "typeof(AbpDddDomainModule)," etc., remove Identity Project, move some files to other projects and so on.
I would like to have a detailed step by step guide for a demo project like eventhub /boookstore to see howto integrate it in a microservice solution, Any help would be great
12 Answer(s)
-
0
i did follow the doc from here: https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice to generate a service with the same name. It seems that the parameter for the database provider is ignored (-d mongo) . It always creates a service based on EF. Is this a bug ?
We have MongoDB support for services in our to-do list, but it is not supported yet. You need to configure it manually.
Adding a pro template to the microservice template will not make it a microservice. The only supported way is documented in Add new Microservices to the Solution. If you want to use the MongoDB for your newly created microservice, you can also follow Change Microservice project to use MongoDB Provider guide.
-
0
I know that a pro template is not a microservice. But i want to move the relevant parts from pro template solution to a new microservice .. Thats why asked for a guide.. I think its a valid option for moving towards a microservice solution
-
0
I know that a pro template is not a microservice. But i want to move the relevant parts from pro template solution to a new microservice .. Thats why asked for a guide.. I think its a valid option for moving towards a microservice solution
What do you mean by relevant parts? You can move the domain layer to the domain, the application layer to the application layer. It shouldn't be any problem.
The only exception with the microservice is the UI. Because there are 2 ways to build the UI;
Can you provide some samples of the issue you are having?
-
0
Yes here is one issue. I did follow your document "Add a new microservice to solution". I can reach my added new Service per Swagger on localhost port 44472. Thats site works.
But i get an error on both gateways if i try to select my new service, that it failed to fetch due Cors Origin:
Fetch error Failed to fetch https://localhost:44472/swagger/v1/swagger.json
Fetch error Possible cross-origin (CORS) issue? The URL origin (https://localhost:44472) does not match the page (https://localhost:44325). Check the server returns the correct 'Access-Control-Allow-*' headers.
I did double check the product service and compared with my new services. But i didn't find any differences so far.
Your document doesn't seem to be updated to 5.3.. There is no internal gateway, and the other gateways do not rely anymore on a project reference for the HttpApi Projects. I did update ocelot.json, the specific Module.cs, but still get the error.
Your document "Change Microservice project to use MongoDB Provider" changes everything to mongo. But i would only add one additional service with mongo. There is a difference , that both Migrations and Checker must work at same time.. and the document doesn't describe that clearly. I did look at eshoponabp and it a looks a bit different.
What can i do for the gateways to acceppt my new service `??
Maybe you could share a complete microservice-template-pro example based on mongdb with me.?
-
0
Possible cross-origin (CORS) issue? The URL origin (https://localhost:44472) does not match the page (https://localhost:44325). Check the server returns the correct 'Access-Control-Allow-*' headers.
What is running on port 44325? Your new microservice? You need to add https://localhost:44472 to your new microservice appsettings Cors configuration.
Your document doesn't seem to be updated to 5.3.. There is no internal gateway, and the other gateways do not rely anymore on a project reference for the HttpApi Projects. I did update ocelot.json, the specific Module.cs, but still get the error.
We have updated the documentation but maybe we forgot some of it. Can you point which documentation have internal gateway reference?
Your document "Change Microservice project to use MongoDB Provider" changes everything to mongo. But i would only add one additional service with mongo. There is a difference , that both Migrations and Checker must work at same time.. and the document doesn't describe that clearly. I did look at eshoponabp and it a looks a bit different.
It has actually commented code to activate MongoDB for a single microservice. You can also check the eShopOnAbp sample that CatalogService is using MongoDB.
-
0
your document "https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice" contain infos about the internal gateway and project reference which doesn't exist anymore, this one needs an update
if i try to follow you document how to change to mongodb. i receive a lot of errors in vs
The Port 44325 is port of the WebGateway, The Port 44472 is the port of my new microservice. I also receive this error on the PublicWebGateway which runs at Port 44353. Both Gateways are added to the new microservice appsettings Cors configuration per default. Also if i open the new microservice page in tye directly (https://localhost:44472) . it works fine but not if try to access it over an gateway. I did follow also the section about the gateways in your microservcice document any didn't find any difference.
I did reproduce it with these steps:
- generate microservice: abp new AppMicro -t microservice-pro -u blazor-server -csf
- abp new AppZero -t microservice-service-pro
- follow gatway document to add it.
- Start tye and test the new microservice appzero directly .. it will work. try to access it over one gateway. i do get the same error.
-
0
My environment
ABP Framework version: v5.3.0 UI type: angular DB provider: EF Core Identity Server Separated (Angular): yes
same problem on my end, please let me know if you get this working please. S I have this configuration over Ports:
WebGateway: https: 44325 AuthServer: https: 44322 IdentityService: https: 44388 ProductService: https: 44361 NewService: https: 44752
AngularClient: http: 4200 ReactClient: http: 5200
CORS: WebGateway: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" AuthServer: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361", IdentityService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" ProductService: "https://localhost:44325,https://localhost:44353" NewService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361"
Result:
NewService: Swagger is working, and openApi definition is working ProductService: Swagger is working, and openApi definition is working
WebGateway: works over all old services, but when I try to switch to NewService Api definition from WebGateway it gives me a CORS error, if I pick ProductService it works, that not makes sense to me, it has be something else in between
-
0
Hi,
till now i dont got any solution for this. Cors gives the error for the new service but i didn't any differerence to product service. The cors setting is exactly the same in appsettings.
I hope the support team will solve this for us. I need this fixed.
-
0
I found on AuthService logs this line,
2022-06-29 14:48:42.714 -05:00 [DBG] CORS request made for path: /swagger/v1/swagger.json from origin: https://localhost:44325 but was ignored because path was not for an allowed IdentityServer CORS endpoint 2022-06-29 14:48:42.714 -05:00 [INF] No CORS policy found for the specified request. 2022-06-29 14:48:42.977 -05:00 [INF] Request finished HTTP/2 GET https://localhost:44322/swagger/v1/swagger.json - - - 200 - application/json;charset=utf-8 2675.0220ms
-
0
Can you check if your new microservice registers the Cors configuration using the cors middleware?
In NewServiceHttpApiHostModuleat
ConfigureServices
method should contain below:context.Services.AddCors(options => { options.AddDefaultPolicy(builder => { builder .WithOrigins( configuration["App:CorsOrigins"] .Split(",", StringSplitOptions.RemoveEmptyEntries) .Select(o => o.Trim().RemovePostFix("/")) .ToArray() ) .WithAbpExposedHeaders() .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); });
In NewServiceHttpApiHostModule at
OnApplicationInitialization
method should contain:... app.UseRouting(); app.UseCors(); // Check for this app.UseAuthentication(); ...
Now you can add api-gateway url to appsettings so that NewMicroservice can allow for any header with any method to the origins specified at appsettings.
-
0
Hi @gterdem,
yes indeed "app.UseCors();" was missing in the NewServiceHttpApiHostModule in OnApplicationInitialization. Seems to be an error in generation through abp-cli. but this did resolve it..
I thank you. I needed that fix. When will that be fixed in cli ?
-
0
We have added it to the patch and merged it. In the first release it will be fixed.
I have refunded your question, thank you for reporting.