Create the project

There are several ways to get your Stacks project, or to get parts of it as well as a couple of configuration options.


Create a new project using the template or add code to an existing project

Install the package

Access Amido.Stacks.CQRS.Events.Template package page in Nuget 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
dotnet new --install Amido.Stacks.CQRS.Events.Templates::0.0.92

Once installed, you obtain 6 templates that can be used

stacks-cqrs-events-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
dotnet new stacks-cqrs-events-app -n Company.Project -do YourDomain -e MessagingProvider -d DatabaseOption

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

stacks-cqrs-events-webapi

A template for the api project. If you need a CQRS WebAPI that can publish messages, this is the template to use.

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

Run the command to create the project
dotnet new stacks-cqrs-events-webapi -n Company.Project -do YourDomain -e MessagingProvider

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

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
dotnet new stacks-az-func-cosmosdb-worker -n Company.Project

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
dotnet new stacks-az-func-asb-listener -n Company.Project

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
dotnet new stacks-asb-worker -n Company.Project
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.
  • -d, --database
    • Configures which database provider to be used
  • -d, --database
    • Configures which database provider to be used
  • -e, --eventPublisher
    • Configures the messaging service
  • -en, --enableFunctionWorker
    • Configures the messaging service
  • -p:e, --enableFunctionListener
    • Configures the messaging service
  • -p:en, --enableBackgroundWorker
    • Configures the messaging service
  • -o
    • Sets the path to where the project is added
    • Omitting the parameter will result in the creation of a new folder

Create the project by cloning GitHub repository

Clone the .NET project to your local machine from here: stacks-dotnet-cqrs-events repository

Run git clone repository command
git clone git@github.com:amido/stacks-dotnet-cqrs-events.git

Create the project using the Scaffolding CLI (in redevelopment)

The scaffolding CLI is being redeveloped to offer you more guided choices of Amido Stacks project flavour. Based on the answers, the ready-to-build project template will be produced.



Pros and cons of each option

PROS

  • Has no dependencies.
  • Enables creation of .NET Core projects in Amido Stacks Suite.
  • Can pick some parts of the whole suite (just a function, just a worker, etc).
  • Enables versioning and access to older versions of Stacks templates
  • Removes out the content not needed from the GitHub repository.

CONS

  • Too many commands to run.