Learn Microservices - ASP.NET Core and Docker
By Arnaud Weil
()
About this ebook
You're a developer who knows nothing to Microservices. Which is fine, except that you need to start coding your next Microservices-based application using ASP.NET Core and Docker.
Don't worry: I have you covered. I've been training hundreds of developers like you during 16 years, and converted my experience into this book. I know from experience teaching what takes more time to learn in Microservices, and will spend time only where appropriate.
Plus this book is packed with exercises which build up into a full project: you develop two interdependent Microservices, each exposing a CRUD JSON API. You publish them in a Docker repository and run them in Docker.
Read this book, and you can code your Microservices within a week.
Arnaud Weil
Arnaud Weil is a born developper: when he was a kid he was controlling his electric train using an Atari ST and some self-made electronics, then as a teenager created and distributed worldwide one of the first Web browsers for some of the first pocket computers, when the Web was just beginning. In fact, he loves coding. Then came .NET and from 2001 Arnaud has been coding using ASP.NET, WPF, WinForms, Silverlight, WCF, XAML for all kind of applications from factory tools to smarphone applications to house control solutions. When not coding, he teaches fellow developers and provides consulting for development teams to reach their targets in the most efficient way. His status as a freelancer allows him to help his clients with many different projects. As things move on, Arnaud also learned to love HTML5, JavaScript and all the great tools that allow building professional software with those technologies. He puts an emphasis on writing modular, clever programs using agile methods and a bunch of automated testing. But what Arnaud enjoys most is helping other developers: that's why he teaches, speaks, and began writing books.
Read more from Arnaud Weil
Learn WPF MVVM - XAML, C# and the MVVM pattern Rating: 4 out of 5 stars4/5Learn Kubernetes - Container orchestration using Docker: Learn Collection Rating: 4 out of 5 stars4/5Learn Kubernetes & Docker - .NET Core, Java, Node.JS, PHP or Python Rating: 0 out of 5 stars0 ratingsLearn Docker - .NET Core, Java, Node.JS, PHP or Python: Learn Collection Rating: 5 out of 5 stars5/5Learn ASP.NET MVC Rating: 4 out of 5 stars4/5Learn ASP.NET Core MVC - Be Ready Next Week Using Visual Studio 2017 Rating: 5 out of 5 stars5/5Learn Meteor - Node.js and MongoDB JavaScript platform Rating: 5 out of 5 stars5/5
Related to Learn Microservices - ASP.NET Core and Docker
Related ebooks
Bootstrap for ASP.NET MVC - Second Edition Rating: 5 out of 5 stars5/5Learn ASP.NET Core MVC - Be Ready Next Week Using Visual Studio 2017 Rating: 5 out of 5 stars5/5How To Build Microservices: Top 10 Hacks To Modeling, Integrating & Deploying Microservices Rating: 0 out of 5 stars0 ratingsAnsible For Containers and Kubernetes By Examples Rating: 0 out of 5 stars0 ratingsASP.NET Core for Jobseekers: Build Career in Designing Cross-Platform Web Applications Using Razor and Entity Framework Core Rating: 0 out of 5 stars0 ratingsBuilding a Web App with Blazor and ASP .Net Core: Create a Single Page App with Blazor Server and Entity Framework Core Rating: 0 out of 5 stars0 ratingsAWS Lambda in Action: Event-driven serverless applications Rating: 0 out of 5 stars0 ratingsHands-On Microservices with Kubernetes: Build, deploy, and manage scalable microservices on Kubernetes Rating: 5 out of 5 stars5/5WebSocket Essentials – Building Apps with HTML5 WebSockets Rating: 0 out of 5 stars0 ratingsStep by Step: Fault-tolerant, Scalable, Secure AWS Web Stack Rating: 0 out of 5 stars0 ratingsServerless Architectures on AWS, Second Edition Rating: 5 out of 5 stars5/5SignalR on .NET 6 - the Complete Guide Rating: 0 out of 5 stars0 ratings.NET Core in Action Rating: 0 out of 5 stars0 ratingsASP.NET Core 3 and React: Hands-On full stack web development using ASP.NET Core, React, and TypeScript 3 Rating: 0 out of 5 stars0 ratingsLearning .NET High-performance Programming Rating: 0 out of 5 stars0 ratingsMicroservices in .NET, Second Edition Rating: 0 out of 5 stars0 ratingsRx.NET in Action Rating: 0 out of 5 stars0 ratingsEntity Framework Core Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsEntity Framework Core in Action, Second Edition Rating: 0 out of 5 stars0 ratingsConcurrency in .NET: Modern patterns of concurrent and parallel programming Rating: 0 out of 5 stars0 ratingsWriting High-Performance .NET Code, 2nd Edition Rating: 5 out of 5 stars5/5Blazor in Action Rating: 0 out of 5 stars0 ratingsAzure Infrastructure as Code: With ARM templates and Bicep Rating: 0 out of 5 stars0 ratingsRe-Engineering Legacy Software Rating: 0 out of 5 stars0 ratingsKubernetes A Complete Guide Rating: 0 out of 5 stars0 ratingsDocker Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratings
Programming For You
Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5101 Amazing Nintendo NES Facts: Includes facts about the Famicom Rating: 4 out of 5 stars4/5Pokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Rating: 0 out of 5 stars0 ratingsPython Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratings
Reviews for Learn Microservices - ASP.NET Core and Docker
0 ratings0 reviews
Book preview
Learn Microservices - ASP.NET Core and Docker - Arnaud Weil
Learn Microservices - ASP.NET Core and Docker
Be ready for coding away next week
Arnaud Weil
This book is for sale at http://leanpub.com/micro
This version was published on 2018-08-21
publisher's logo* * * * *
This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do.
* * * * *
© 2017 - 2018 Arnaud Weil
To my parents, for teaching me freedom and making sure I can enjoy it.
To my wonderful family. Your love and support fueled this book.
To my readers who suggested improvements to this book, especially Doğan Kartaltepe and Louis-Guillaume Morand.
Table of Contents
Introduction
What this book is not
Prerequisites
How to read this book
Tools you need
Source code
1. Why microservices?
1.1 What are they?
1.2 Microservices induce complexity
2. Microservices as seen from the client
2.1 HTTP
2.2 Payloads
2.3 Do you speak JSON
2.4 Client types
2.5 Manual testing
2.6 Exercise - Invoke a microservice manually
2.7 Exercise solution
3. Microservices server-side
3.1 About coding the server
3.2 There comes .NET Core
3.3 Introduction to ASP.NET Core
3.4 ASP.NET Core Web API
3.5 Exercise - Create a train scheduling service
3.6 Exercise solution
4. Database access using Entity Framework Core
4.1 Introduction to Entity Framework Core
4.2 Scaffold your code and save time
4.3 Exercise - Extend the train scheduling service
4.4 Exercise solution
5. Adding UI server-side
5.1 To UI or not to UI
5.2 UI scaffolding with Visual Studio
5.3 Exercise - Add a UI to the train scheduling service
5.4 Exercise solution
6. Invoking a service from .NET and .NET Core
6.1 .NET Clients
6.2 Demo: consume the microservice from a WPF client
7. Invoking a service from another service
7.1 Same but different but same
7.2 Exercise - Create a ticketing service
7.3 Exercise solution
7.4 Exercise - Consume the scheduling service from the ticketing service
7.5 Exercise solution
7.6 Integration testing of the microservices created
8. Introduction to containers and Docker
8.1 Why do we need containers?
8.2 Virtualization could have been the panacea
8.3 Why containers perform better
8.4 Containers in practice
8.5 How containers solve problems
8.6 Containers as microservice hosts
8.7 Exercise - Run a Docker container
8.8 Exercise solution
9. Creating and running Docker images
9.1 How images are built
9.2 An ASP.NET Core Dockerfile
9.3 Multi-stage Dockerfiles
9.4 Exercise - Build and run your own Docker image
9.5 Exercise solution
10. Publishing images to Docker registries
10.1 Why bother with Registries?
10.2 Available Registries
10.3 Publishing an image
10.4 Exercise - Publish your services on Docker Hub
10.5 Exercise solution
11. Executing linked microservice containers in a Docker Swarm
11.1 The need for orchestrators
11.2 Orchestrators commonly used with Docker
11.3 Docker Swarm concepts
11.4 Creating a swarm
11.5 Configuring a stack
11.6 Deploying and managing a stack on a swarm
11.7 Exercise - Run the two services in a Docker Swarm
11.8 Exercise solution
11.9 Integration testing of the stack created
12. Microservice clusters using Docker Swarm
12.1 Demo: load-balancing the stack
A word from the author
The Learn collection
Notes
Introduction
What this book is not
I made my best to keep this book small, so that you can learn microservices quickly without getting lost in petty details. If you are looking for a reference book where you’ll find answers to all the questions you may have within the next 4 years of your microservices practice, you’ll find other heavy books for that.
My purpose is to swiftly provide you with the tools you need to code your first microservice application using Docker and ASP.NET Core, then be able to look for more by yourself when needed. While some authors seem to pride themselves in having the thickest book, in this series I’m glad I achieved the thinnest possible book for my purpose. Though I tried my best to keep all of what seems necessary, based on my 16 years experience of teaching .NET.
I assume that you know what microservices are and when to use them. In case you don’t, read the following Why microservices chapter.
Prerequisites
In order for this book to meet its goals, you must:
Have basic experience creating applications with C#
Know what a Web application is
How to read this book
This book’s aim is to make you productive as quickly as possible. For this we’ll use some theory, several demonstrations, plus exercises. Exercises appear like the following:
Do it yourself: Time to grab your keyboard and code away to meet the given objectives.
In code samples, a backslash is used in order to wrap long lines. Do not type theses backslashes when you copy code from the book.
Tools you need
The only tools you’ll need to work through this book are the following:
Windows 10
Visual Studio 2017 (Community, Professional or Enterprise)
Docker 17.09 or higher (Community)
When installing Visual Studio, make sure you select the ASP.NET and .NET Core components.
Source code
All of the source code for the demos and do-it-yourself