![]() |
VOOZH | about |
Requires NuGet 5.10.0 or higher.
dotnet new install Genocs.Microservice.Template@1.0.4
👁 License
👁 Build
👁 Packages
👁 Downloads
👁 Contributors
👁 Forks
👁 Stargazers
👁 Issues
👁 Discord
👁 Gitter
👁 Twitter
👁 Twitterx
👁 LinkedIn
Genocs .NET Web API Microservice Template is a starting point for your next .NET7 Clean Architecture Project that incorporates the most essential packages and features your projects will ever need including out of the box Multi-Tenancy support.
As the name suggests, this is an API / Server Template. You can find other Client Template that consume this API under
@genocshandle.
- Find
Blazor WebAssembly Templatehere - Blazor WebAssembly Template
The template can be used with the genocs cli or dotnet new command or with the Visual Studio 2022 or Visual Studio Code IDEs.
Watch the Getting started video here: youtube intro
The goal of this repository is to provide a complete and feature-rich starting point for any .NET Developer / Team to kick-start their next major project using .NET7 Microservices architecture. This also serves the purpose of learning advanced concepts and implementations such as Multitenancy, CQRS, Onion Architecture, Clean Coding standards, Docker Concepts, Cloud Deployments with Terraform to AWS, CI/CD Pipelines & Workflows and so on.
Read Documentation related to this template here - Template Documentation
Feel free to contribute to the Documentation Repository - Contribute Documentation
To get started with this Template, here are the available options:
genocs cli tool. Use this for latest release versions of the Template only.dotnet new install tool. Use this for any versions of the Template.Make sure that your DEV enviroment is setup, Read the Development Environment Guide
Before creating your first solution, you should ensure that your local machine has:
After you have installed .NET, you will need to install the cli console tool.
dotnet tool install -g genocs.cli
genocs install
This install the CLI tools and the associated Templates. You are now ready to create your first project!
Here's how you would create a Solution using the Genocs .NET WebAPI Template.
Simply navigate to a new directory (wherever you want to place your new solution), and open up bash prompt at the opened directory.
Run the following command. Note that, in this demonstration, I am naming my new solution as CompanyName.ProjectName.ServiceName.
genocs api new CompanyName.ProjectName.ServiceName
OR
genocs api n CompanyName.ProjectName.ServiceName
This will create a new .NET7 Web API solution for you using the template. For further steps and details, Read the Getting Started Guide
To update the tool & templates, run the following commands
dotnet tool update genocs.cli --global
genocs update
You would probably need to take this approach if you want to keep your source code up to date with the latest changes. To get started based on this repository, you need to get a copy locally. You have three options: fork, clone, or download.
dotnet-microservice-template personal project by cloning the forked repository on your personal GitHub.git remote add upstream https://github.com/{githubuseraccount}/dotnet-microservice-template and git remote set-url --push upstream DISABLEFor step by step instructions, follow: this and this.
So, for a better developer experience, I have added Makefile into the solution. Now that our solution is generated, let's navigate to the root folder of the solution and open up a command terminal.
To build the solution:
make build
By default, the solution is configured to work with postgresql database (mainly because of the OS licensing). So, you will have to make sure that postgresql database instance is up and running on your machine. You can modify the connection string to include your username and password. Connections strings can be found at src/WebApi/Configurations/database.json and src/WebApi/Configurations/hangfire.json. Once that's done, let's start up the API server.
make start
That's it, the application would connect to the defined postgresql database and start creating tables, and seed required data.
For testing this API, we have 3 options.
localhost:5001/swagger./postmanThe default credentials to this API is:
{
"email":"admin@root.com",
"password":"123Pa$$word!"
}
Open up Postman, Thunderclient or Swagger.
identity → get-token
This is a POST Request. Here the body of the request will be the JSON (credentials) I specified earlier. And also, remember to pass the tenant id in the header of the request. The default tenant id is root.
Here is a sample CURL command for getting the tokens.
curl -X POST \
'https://localhost:5001/api/tokens' \
--header 'Accept: */*' \
--header 'tenant: root' \
--header 'Accept-Language: en-US' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "admin@root.com",
"password": "123Pa$$word!"
}'
And here is the response.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjM0YTY4ZjQyLWE0ZDgtNDNlMy1hNzE3LTI1OTczZjZmZTJjNyIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6ImFkbWluQHJvb3QuY29tIiwiZnVsbE5hbWUiOiJyb290IEFkbWluIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZSI6InJvb3QiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zdXJuYW1lIjoiQWRtaW4iLCJpcEFkZHJlc3MiOiIxMjcuMC4wLjEiLCJ0ZW5hbnQiOiJyb290IiwiaW1hZ2VfdXJsIjoiIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIiLCJleHAiOjE2ODA5NDE3MzN9.VYNaNvk2T4YDvQ3wriXgk2W_Vy9zyEEhjveNauNAeJY",
"refreshToken": "pyxO30zJK8KelpEXF0vPfbSbjntdlbbnxrZAlUFXfyE=",
"refreshTokenExpiryTime": "2023-04-15T07:15:33.5187598Z"
}
You will need to pass the token in the request headers to authenticate calls to the Genocs API!
For further steps and details, Read the Getting Started Guide
The project, being .NET7, it is configured to have built-in support for containerization. That means, you really don't need a dockerfile to containerize the webapi.
To build a docker image, all you have to do is, ensure that docker-desktop or docker instance is running. And run the following command at the root of the solution.
make publish
You can also push the docker image directly to dockerhub or any supported registry by using the following command.
make publish-to-hub
You will have to update your docker registry/repo url in the Makefile though!
This project also comes with examples of docker compose files, where you can spin up the webapi and database instance in your local containers with the following commands.
#docker compose up - Boots up the webapi & postgresql container
make dcu
#docker compose down - Shuts down the webapi & postgresql containers
make dcd
There are also examples for mysql & mssql variations. You can find the other docker-compose files under the ./docker-compose folder. Read more about docker-compose instructions & files here .
We do support cloud deployment to AWS using terraform. The terraform files are available at the ./terraform folder.
In brief, the terraform folder has 2 sub-folders:
The Backend folder is internally used by Terraform for state management and locking. There is a one-time setup you have to do against this folder. Navigate to the backend folder and run the command.
terraform init
terraform apply -auto-approve
This would create the required S3 Buckets and DDB table for you.
Next is the environments/staging folder. Here too, run the following command.
terraform init
Once done, you can go the terraform.tfvars file to change the variables like:
After that, simply go back to the root of the solution and run the following command.
make ta
This will evaluate your terraform files and create a provision plan for you. Once you are ok, type in yes and the tool will start to deploy your .NET Microservice project as containers along with a RDS PostgreSQL instance. You will be receiving the hosted api url once the provisioning is completed!
To destroy the deployed resources, run the following
make td
Check nuget is installed on your machine. To download nuget, visit nuget.org
nuget pack ./src/Package.Template.nuspec -NoDefaultExcludes -OutputDirectory ./out -Version {{semver}}
dotnet new install ./out/Genocs.Microservice.Template.{{semver}}.nupkg
dotnet new gnx-microservice --help
dotnet new gnx-microservice --name {{CompanyName.ProjectName.ServiceName}}
Participate in QNA & General Discussions
View Complete Changelogs.
This project is licensed with the .
Has this Project helped you learn something New? or Helped you at work? Here are a few ways by which you can support.
Become a financial contributor and help me sustain the project.
Support the Project on Opencollective
This package has no dependencies.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.1 | 7,766 | 10/31/2025 |
| 3.1.0 | 435 | 10/31/2025 |
| 3.0.0 | 466 | 10/26/2025 |
| 2.3.3 | 7,881 | 2/15/2025 |
| 2.3.2 | 831 | 1/1/2025 |
| 2.3.1 | 837 | 1/1/2025 |
| 2.3.0 | 2,974 | 11/30/2024 |
| 2.2.0 | 2,752 | 10/31/2024 |
| 2.1.0 | 14,075 | 7/2/2024 |
| 2.0.0 | 3,370 | 5/12/2024 |
| 1.0.5 | 19,620 | 11/17/2023 |
| 1.0.4 | 5,938 | 11/4/2023 |
| 1.0.3 | 11,990 | 10/22/2023 |
| 1.0.2 | 4,761 | 10/21/2023 |
| 1.0.1 | 3,589 | 10/21/2023 |
| 1.0.0 | 8,381 | 9/23/2023 |