Table of contents
- Install the dotnet new template
- Create a new microservice application
- Run the application
In this post I will show you how to create ABP microservice using a dotnet new template.
Right now it is not easy to create a new microservice application with ABP. I have made a 12 part video series on how to create a microservice application with ABP. It is a lot of work and it is not easy to follow. I have created a dotnet new template to make it easier to create a new microservice application with ABP. You can find the template on GitHub. You can also find the video series on YouTube. If you are new to ABP then start here and then come back to this post.
The template is still in the early stages. I have created the template using the sample application from the video series. I have not tested the template with all the features. This is really usefull if you already know how to create a microservice application with ABP. But if you are new to ABP then I would recommend to watch the video series. It will give you a good understanding of how to create a microservice application with ABP.
To use the template you need to have the following installed on your machine.
- .Net 7.0 SDK
- ABP CLI
- Tye (Optional)
I mostly use the Visual Studio Code as my IDE. But you can use any IDE you want. I have tested the template with Visual Studio Code and Visual Studio 2022.
For my development environment I use Docker to run the database, RabbitMQ and Redis. you find my docker stack files in the GitHub repository.
Install the dotnet new template
To install the dotnet new template you need to run the following command.
dotnet new install Anto.Abp.Microservice.Template::1.1.2
This will install the template to your local machine. You can check the installed templates by running the following command.
dotnet new -l
Note: Right now the template is using PostgreSQL as the database provider. you can change the database provider to whatever you want. For more information on how to change the database provider please check the documentation.
Create a new microservice application
To create a new microservice application you need to run the following command.
dotnet new abp-ms -n MyMicroservice
This will create a new microservice application with the name
MyMicroservice. You can change the name to whatever you want. This will create a new folder with the name
MyMicroservice. You can open the folder in your favorite IDE.
Run the application
Before you run the application make sure you have built the solution at least once. You can build the solution by running the following command.
Once the solution is built run the following to command to install the npm packages.
Note: You need to have
abpinstalled on your machine. You can install
abpby running the following command.
dotnet tool install -g Volo.Abp.Cli
This will install the npm packages for all the projects.
Once the packages are installed then we have to update the connection string in the
appsettings.json file. You can find the
appsettings.json file in the
*.HttpApi.Host projects and
The first project you need to run is the
MyMicroservice.DbMigrator project. You can run the project by running the following command.
dotnet run --project MyMicroservice/shared/MyMicroservice.DbMigrator/MyMicroservice.DbMigrator.csproj
This will create the database and seed the data. Once the database is created you can run the
tye file is located in the
MyMicroservice folder. You can run the
tye by running the following command.
Note: You need to have
tyeinstalled on your machine. You can install
tyeby running the following command.
dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"
tye is running you can open the
http://localhost:8000 in your browser. you should see all the services running.
I think this is a good start for creating a new microservice application with ABP. I will be adding more features to the template in the future. If you have any suggestions or feedback please let me know in the comments. I would love to hear from you.