Simple Microservice and Azure Integration

This, and the following posts, are my interpretation of a simple guide to get a small microservice running on Azure, and mixing it with the security offered by AppConfiguration and KeyVault.

Part 1 : Setting everything up to code

So what do we need to start with?

  1. Visual Studio (community or code) –
    I’m a fan of Studio, but for this i’ve taken myself out of my comfort zone and decided to use VSCode
  2. Git and Github account
  3. Free Microsoft Azure account
  4. Azure Devops account (from the Azure account above)

Firstly create the project in devops, then create 2 branches

  1. Main (this is going to be the deployment branch)
  2. Development (this is going to be the main deployment trunk into which all tasks/branches will be pulled. Set this one as Default/Compare

Any branches created in the future will (and should be) based on development, so if something fails to build it doesn’t affect the Release(main) branch.

After this, create a new Epic and Task

In this instance I’ve created a new Epic “New Microservice” and from within that I created a simple task “Create the base structure”. This is to setup all the relevant configuration files and folder structures based on a DDD approach.

Within the task, create a branch (based on development) in which to do the work in.

Within Visual Studio Code Terminal window, run a git -clone command for the repository, followed by a git pull and git checkout 1-create-base-structure, this will checkout this branch within VSCode and allow files to be added/modified/removed from it.

(I like to prefix the branch with the work item number, as I find this helps me to remember which task I’m currently working on when I restart VS after a weekend, or some time away.)

Now create the following folder structure

As in my previous post about DDD, I like to have the above structure to my projects:

Application – Contains the Queries and Commands used in the Microservice

Common – Contains any code that can be shared across the layers, but is not reliant on any layer.

Components – Contains the consumers for the microservices

Domain – Contains any underlying entities and DTOs required by the microservice

Infrastructure – Contains any code relating to the communication with a 3rd party or external API

Persistence – Contains the code and context that allows connections to a persisted datastore.

Service – Contains the startup code for the Microservice, whether this is a scheduled or run-once service

Tests – Contains any tests for the Microservice

Part 2 – Creating some simple code locally to test it works.


Posted

in

by

Tags:

Comments

One response to “Simple Microservice and Azure Integration”

  1. […] as part of the Microservice project i’m creating myself, I thought I’d use Devops Pipelines for the build process. Having […]

Leave a Reply to Azure DevOps, Docker and Pipelines – An unexpected twist – robson://:software Cancel reply

Your email address will not be published. Required fields are marked *