The handwriting is on the wallmost people building software and services today are rushing to embrace microservices and their benefits in terms of scale, fault tolerance, and time to market.
This isnt just because its a shiny new fad. The momentum behind microservices and the concepts driving them is far more important, and those looking for the pendulum to swing back away from the notion of smaller, independently deployed modules will be left behind.
Today, we need to be able to build resilient, elastically scalable applications, and we need to do it rapidly to satisfy the needs of our customers and to keep ahead of our competition.
What Youll Build
Unlike other more reference-style books that are all about showing you each and every API, library, and syntax pattern available to you in a given language, this book is written and meant to be consumed as a guide to building services, with ASP.NET Core simply being the framework in which all the code samples are built.
This book will not teach you every single nuance of low-level C# code; there are far thicker books written by other people if thats what youre looking for. My goal is that by the end of the book, creating, testing, compiling, and deploying microservices in ASP.NET Core will be muscle memory for you. Youll develop good, practical habits that will help you rapidly build stable, secure, reliable services.
The mentality Id like you to have is that after reading this book, youll have learned a lot about how to build services that are going to be deployed in elastically scalable, high-performance cloud environments. ASP.NET Core in C# is just one of many languages and frameworks you can use to build services, but the language does not make the serviceyou do. The care, discipline, and diligence you put into building your services is far more a predictor of their success in production than any one language or tool ever could be.
The paintbrushes and canvas do not make the painting, the painter does. You are a painter of services, and ASP.NET Core is just one brush among many.
In this book, youll start with the basic building blocks of any service, and then learn how to turn them into more powerful and robust services. Youll connect to databases and other backing services, and use lightweight distributed caches, secure services, and web apps, all while keeping an eye on the ability to continuously deliver immutable release artifacts in the form of Docker images.
Why Youre Building Services
Different teams work on different release cadences with different requirements, motivations, and measures of success. Gone are the days of building monoliths that require a custom, handcrafted, artisanal server in order to run properly. Hopefully, gone as well are the days of gathering a hundred people in conference rooms and on dial-in lines to hope and pray for the successful release of a product at 12:01 on a Sunday morning.
Microservices, if done properly, can give us the agility and drastically reduced time to market that our companies need in order to survive and thrive in this new world where nearly every vertical, regardless of its domain, seems to need software running in the cloud to make money.
As you progress through the book youll see the rationalizations for each decision made. From the individual lines of code to the high-level architectural napkin drawings, Ill discuss the pros and cons of each choice.
What Youll Need to Build Services
First and foremost, youll need the .NET Core command-line utilities and the appropriate software development kit (SDK) installed. In the first chapter Ill walk you through what youll need to get that set up.
Next, youre going to need Docker. Docker and the container technology that supports it are ubiquitous these days. Regardless of whether youre deploying to Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), or your own infrastructure, Docker provides the portable and immutable release artifacts that you crave (and Ill get more into the details of why this is the case throughout the book).
The development and build pipeline for the services in this book is the creation of Docker images running on Linux infrastructure in the cloud. As such, the path of least friction for readers of this book is likely a Mac or a Linux machine. Youll be able to work with Windows, but some things may be higher-friction or require extra workarounds. The new Linux subsystem for Windows 10 helps with this, but still isnt ideal.
Docker on Windows and the Mac will use virtual machines to host a Linux kernel (required for Dockers container tech), and as such you may find your machine struggling a bit if you dont have enough RAM.
If youre using Linux (I used Ubuntu to verify the code), then you dont need any virtual machines as Docker can run directly on top of a Linux kernel.
Online Resources
- Microsofts website
- This books GitHub repo
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.