This is part of a five-part series in my exploration of Azure microservices facilities.
- Kick-start containerized microservice CI/CD with Azure DevOps
- Build containerized microservices with Docker and .NET Core 2.1
- Build containerized web dashboard with ASP.NET Core
- Email service health report with Azure serverless
- Scale out services with Managed Kubernetes
I have always been fascinated with container technology and over years I have watched the technology mature. As cloud adaption grows, the community interests on microservices and distributed computing is also unwavering. Undoubtedly, there has never been a better time to be a developer and there just so many exciting things to learn!
But if we want to explore a new technology, it would be nice to build something that is far more than a
HelloWorld. Something that would make a difference to what we normally do. So I thought of building a simple service health dashboard that our team could checkout in the morning on their way to work thru notebook or mobile.
The Achitecture Vision
My goal is simple. To build a scalable service that can receive heartbeats from on-premise systems and create near-real time dashboard accessible anywhere and anytime. If should fast to develop and cheap to operate.
The Technology Stack
- Azure Container Services (AKS)
- Azure DevOps
- Azure SQL Database
- Application Insights
- .NET Core 2.1
- Docker for Windows
Jumpstart CI/CD with Azure DevOps
Azure DevOps is a magic wand. It boils and cooks everything for you so you can immedially deliver value. When you choose to create a .NET Core project, Azure DevOps will:
Setup your Azure infrastructure
- Resource Group. For cost management.
- Container Registry. For hosting your docker images
- Linux-based Hosting Plan. For exposing the service to public
- Application Insights. For your application logs and diagnostics
- AppService. Dor running your container instance and expose via public URL.
Setup your CI/CD pipeline in VSTS
- Creates a Git-based project in your VSTS account
- Creates CI builds
Creates CD to your Azure AppService
Build with VSCode
To start developing container-based services, you’re gonna need Windows 10 Pro. Yeah, ditch those Windows 8 machines or create a new Windows 10 VM in Azure. That’s what I did, fast, simple.
Create VM in Azure
- Standard D4s v3 (4 vcpus, 16 GB memory)
- Windows 10 Pro
/ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Install Docker for Windows
/ choco install docker..and don’t forget to enable Hyper-V.
Install VS Code with these plugins
/ choco install vscode
Install Git For Windows
/ choco install git
Install .NET Core 2.1 SDK
/ choco install dotnetcore-sdk
Run your .NET Core App
Copy your git repo link from your VSTS project page.
/ git clone https://rdagumampanvsts.visualstudio.com/ServiceHealthWebApp/_git/ServiceHealthWebApp / dotnet restore / dotnet build / dotnet run
Build and run your first container
Dockerize it. Open
FROM microsoft/aspnetcore-build:1.1 AS build-env WORKDIR /app # Copy csproj and restore as distinct layers COPY *.csproj ./ RUN dotnet restore # Copy everything else and build COPY . ./ RUN dotnet publish -c Release -o out # Build runtime image FROM microsoft/aspnetcore:1.1 WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "aspnet-core-dotnet-core.dll"]
/ dotnet publish --configuration=Release -o pub / docker build . -t servicehealthweb / docker images
/ docker run -d -p 8080:80 --name servicehealthweb servicehealthweb
/ docker ps
/ docker ps / docker stop <containerid>
Cleanup your ship, remove all containers and images.
Containers and images takes enormouse amount of space especially your picking a large distribution. These commands cleanup all your running containers and existing images. WARNING: THIS DELETES ALL CONTAINERS AND IMAGES IN YOUR MACHINE!
/ docker ps / docker stop $(docker ps -a -q) / docker rm $(docker ps -a -q)
/ docker images / docker rmi $(docker images -a -q)
Azue DevOps is great way to get started and greatly reduced the challenges of making entire CI/CD work. Docker made it so easy to create portable aplications that can be deployed across environments and cloud platforms;
Its important to note that I just made this for fun and learning. The solution altenatives are.
Use enterprise APM solutions. APM solutions like HP’s Microfocus APM and Cisco’s AppDynamics delivers comprehensive service monitoring tools. No doubt its the best tool money can buy but tools like these would have to go through official budget commitment and an enterprise agreement.
Use open source ELK stack. We can leverage on existing ElasticSearch logs to derive service states. This is promising alternative though our ELK server is not exposed to the internet.