---
id: create_project_netcore
title: Create REST API with CQRS project
linkTitle: Create REST API with CQRS project
weight: 1
keywords:
  - .net core
  - rest api
  - cqrs
  - example
  - template
  - azure
  - application insights
  - cosmos db
  - build
  - run
  - application
  - configure
  - docker
  - tests
  - github
---

:imagesdir: ../../../../../../../static/img

== Create a project

.Installing/uninstalling the package
[%collapsible]
=====
[discrete]
=== Install the package

Access Ensono.Stacks.Template package page in Nuget https://www.nuget.org/packages/Amido.Stacks.Templates/[here]
Copy and execute the command displayed in the page (if you want to get the latest version).
For example

.Run the command to install the package
[source, bash]
----
dotnet new install Ensono.Stacks.Templates
----

Once installed, you obtain 7 templates that can be used

[discrete]
=== stacks-webapi

Simple web API which also includes the build infrastructure

Navigate to the folder where you wish to create a new project on.

.Run the command to create the project
[source, bash]
----
dotnet new stacks-webapi -n Company.Project -do YourDomain --cloudProvider CloudProvider
----

The above command will create a folder and a repository called `Company.Project`.

[discrete]
=== stacks-cqrs-app

The full template containing API, functions, background worker and build infrastructure

Navigate to the folder where you wish to create a new project on.

.Run the command to create the project
[source, bash]
----
dotnet new stacks-cqrs-app -n Company.Project -do YourDomain -e MessagingProvider -db DatabaseOption --cloudProvider CloudProvider
----

The above command will create a folder and a repository called `Company.Project`.

[discrete]
=== stacks-az-func-cosmosdb-worker

A template for a Azure Function containing a CosmosDb change feed trigger. Upon a CosmosDb event, the worker reads it and publishes a message to Service Bus.

Navigate to the folder where you wish to create a new project on.

.Run the command to create the function
[source, bash]
----
dotnet new stacks-az-func-cosmosdb-worker -n Company.Project
----

[discrete]
=== stacks-az-func-asb-listener

A template containing an Azure Function project with a single function that has a Service Bus subscription trigger. The function receives the message and deserializes it.

Navigate to the folder where you wish to create a new project on.

.Run the command to create the function
[source, bash]
----
dotnet new stacks-az-func-asb-listener -n Company.Project -do Menu
----

[discrete]
=== stacks-asb-worker

A template contains a background worker application that reads and handles messages from a ServiceBus subscription.

Navigate to the folder where you wish to create a new project on.

.Run the command to create the function
[source, bash]
----
dotnet new stacks-asb-worker -n Company.Project -do Menu
----

[NOTE]
.Template parameter details (some templates may offer only a subset of the arguments shown)
====
- **-n|--name**
- Sets the project name
- Omitting it will result in the project name being the same as the folder where the command has been ran from
- **-do|--domain**
- Sets the name of the aggregate root object. It is also the name of the collection within CosmosDB instance.
- **-db|--database**
- Configures which database provider to be used
- **-e|--eventPublisher**
- Configures the messaging service. Available services are:
- ServiceBus
- EventHub
- AwsSns
- None
- **-e:fw|--enableFunctionWorker**
- Configures the messaging service
- **-e:fl|--enableFunctionListener**
- Configures the messaging service
- **-e:bw|--enableBackgroundWorker**
- Configures the messaging service
- **-o|--output**
- Sets the path to where the project is added
- Omitting the parameter will result in the creation of a new folder
- **--cloudProvider**
- Configures which cloud provider to be used
====

Once installed you can either, create a new project or add CQRS to an existing project.

[discrete]
=== Uninstalling the templates

If you want to remove the templates from your system you'll have to uninstall the Nuget package.

.To uninstall package execute the following command
[source, bash]
----
dotnet new uninstall Ensono.Stacks.Templates
----
=====

.Creating a new project
[%collapsible]
=====
[discrete]
=== Create a new project

Navigate to the folder where you wish to create a new project in. Then run the following command.

.Run the command to create the project
[source, bash]
----
dotnet new stacks-cqrs-app -n Company.Project -do YourDomain --cloudProvider Azure
----

The above command will create a folder and a repository called `Company.Project` with DevOps build pipelines ready for Azure DevOps.

[discrete]
=== Setting the database option

To create a project with CosmosDb as the database you can use the following command

.Run the command to create the project with database
[source, bash]
----
dotnet new stacks-cqrs-app -n Company.Project -do YourDomain -db CosmosDb
----

[NOTE]
.Template parameter details
====
- **-n|--name**
- Sets the project name
- Omitting it will result in the project name being the same as the folder where the command has been ran from
- **-do|--domain**
- Sets the name of the aggregate root object. It is also the name of the collection within CosmosDB instance.
- **-db|--database**
- Configures which database provider to be used.
- **-o|--output**
- Sets the path to where the project is added
- Omitting the parameter will result in the creation of a new folder
- **--cloudProvider**
- Configures which cloud provider to be used
- **-cicd|--cicdProvider**
- Configures which cicd provider templates to be used
====