About the Book
Book + Content Update Program
“Beyond just describing the basics, this book dives into best practices every aspiring microservices developer or architect should know.”
—Foreword by Corey Sanders, Partner Director of Program Management, Azure
Microservice-based applications enable unprecedented agility and ease of management, and Docker containers are ideal for building them. Microsoft Azure offers all the foundational technology and higher-level services you need to develop and run any microservices application. Microservices with Docker on Microsoft Azure brings together essential knowledge for creating these applications from the ground up, or incrementally deconstructing monolithic applications over time.
The authors draw on their pioneering experience helping to develop Azure’s microservices features and collaborating with Microsoft product teams who’ve relied on microservices architectures for years. They illuminate the benefits and challenges of microservices development and share best practices all developers and architects should know.
You’ll gain hands-on expertise through a detailed sample application, downloadable at github.com/flakio/flakio.github.io. Step by step, you’ll walk through working with services written in Node.js, Go, and ASP.NET 5, using diverse data stores (mysql, elasticsearch, block storage). The authors guide you through using Docker Hub as a service registry, and Microsoft Azure Container service for cluster management and service orchestration.
Coverage includes:
Recognizing how microservices architectures are different, and when they make sense
Understanding Docker containers in the context of microservices architectures
Building, pulling, and layering Docker images
Working with Docker volumes, containers, images, tags, and logs
Using Docker Swarm, Docker Compose, and Docker Networks
Creating Docker hosts using the Azure portal, Azure Resource Manager, the command line, docker-machine, or locally via Docker toolbox
Establishing development and DevOps environments to support microservices applications
Making the most of Docker’s continuous delivery options
Using Azure’s cluster and container orchestration capabilities to operate and scale containerized microservices applications with maximum resilience
Monitoring microservices applications with Azure Diagnostics, Visual Studio Application Insights, and Microsoft Operations Management Suite
Developing microservices applications faster and more effectively with Azure Service Fabric
An extensive sample application demonstrating the microservices concepts discussed throughout the book is available online
In addition, this book is part of InformIT’s exciting new Content Update Program, which provides content updates for major technology improvements! As significant updates are made to Docker and Azure, sections of this book will be updated or new sections will be added to match the updates to the technologies. As updates become available, they will be delivered to you via a free Web Edition of this book, which can be accessed with any Internet connection. To learn more, visit informit.com/cup.
How to access the Web Edition: Follow the instructions inside to learn how to register your book to access the FREE Web Edition.
Table of Contents:
Foreword xi
Preface xiii
Chapter 1 Microservices 1
What are Microservices? 2
Autonomous Services 4
Small Services 5
Benefits of Microservices 6
Independent Deployments 6
Continuous Innovation 8
Improved Scale and Resource Utilization 9
Technology Diversity 10
Small Focused Teams 12
Fault Isolation 12
Challenges 13
Complexity 14
Network Congestion and Latency 14
Data Consistency 15
Testing 16
Integration and Versioning 17
Service Discovery and Routing 17
Monitoring and Logging 18
Skillset and Experience 18
Uptime Service Level Agreement 18
Best Practices 19
Encapsulation 20
DevOps Principles and Culture 21
Automation 22
Monitoring 23
Fault Tolerance 23
Summary 26
Chapter 2 Containers on Azure Basics 29
VMs, Containers, and Processes 29
When Would We Use a Container Over a Virtual Machine or a Process? 30
Containers on Azure 34
Creating an Azure VM with Docker 35
Generating an SSH Public Key on Windows 37
Generating an SSH Public Key on Mac OS X 39
Choosing a Virtual Machine Image 40
Connecting to the VM Using SSH and Git Bash on Windows 44
Connecting to the VM Using SSH and Git Bash on Mac OS X 46
Docker Container Basics 47
Summary 68
Chapter 3 Designing the Application 69
Determining Where to Start 70
Coarse-Grained Services 70
Starting with Microservices 72
Defining Services and Interfaces 73
Decomposing the Application 74
Service Design 76
Service to Service Communication 78
Synchronous Request/Response 78
Asynchronous Messaging 79
Monolith to Microservices 80
Flak.io e-Commerce Sample 83
Flak.io 84
Requirements 84
Architecture Overview 85
Considerations 86
Summary 87
Chapter 4 Setting Up Your Development Environment 89
Using Docker for Local Development 89
Docker for Local Development 89
Docker for Production Validation 90
Docker as a Build/Test Host 90
Developer Configurations 90
Local Development 90
Local and Cloud 91
Cloud Only 91
Managing Docker Authentication 91
Choosing a Base Image 92
Build a Hierarchy of Images 95
Setting up your Local Dev Environment 101
Install Docker Tools 101
Install Developer Tools 102
Install Windows Utilities 102
Install OSX Utilities 103
Docker for Local Development 103
Local Development Settings 103
Starting your Local Docker Host 104
Connecting to a Docker Host 105
Cloning Samples 105
Enabling Live Reload in a Docker Container 107
Volumes 108
Preparing your Microservice for Production 110
Docker Compose 112
Debugging Docker Issues 116
Unable to Connect to the Docker Host 116
Containers That Won’t Start 117
Diagnosing a Running Container 118
Summary 118
Chapter 5 Service Orchestration and Connectivity 119
Orchestration 121
Provisioning 123
Infrastructure as Code 123
Azure Resource Manager 126
Azure Container Service 132
Multivendor Provisioning 135
Scheduling and Cluster Management 136
Challenges 136
A Scheduling Solution 138
Docker Swarm 141
Kubernetes 144
Apache Mesos 147
Using Apache Mesos to Run Diverse Workloads 150
Service Discovery 150
Service Registration 152
Service Lookup 153
Service Registry 155
Technologies 156
Other Technologies 158
Application/API Gateway 159
Overlay Networking 161
Summary 165
Chapter 6 DevOps and Continuous Delivery 167
DevOps Overview 167
Modern DevOps 169
DevOps Culture 170
Continuous Integration, Delivery, and Deployment 171
Creating Environments in Azure 173
Deploying a Microservice with Continuous Delivery 182
Application Configuration Changes Across Different Environments 184
Continuous Integration 185
Testing in a QA Environment 192
Deploying to Staging 195
Testing in Production 196
Choosing a Continuous Delivery Tool 200
On-Premises or Hosted? 200
On-Premises or Hosted Build Agents? 201
Best-of-breed or Integrated Solution? 201
Does the Tool Provide the Extensibility You Need? 202
Comparison of Jenkins, Team Services, Bamboo, and Tutum 205
Docker Cloud (Formerly Called Tutum) 206
Summary 207
Chapter 7 Monitoring 209
Monitoring the Host Machine 210
Monitoring Containers 212
Monitoring Services 216
Monitoring Solutions 222
Azure Diagnostics 222
Application Insights 227
Operations Management Suite (OMS) 231
Recommended Solutions by Docker 232
Summary 232
Chapter 8 Azure Service Fabric 233
Service Fabric Overview 234
Service Fabric Subsystems 234
Cluster Management 236
Resource Scheduling 240
Service Fabric Application 240
Custom Applications (Existing Applications) 242
Container Integration 243
Service Discovery 244
Programming Model 244
Stateless Services 244
Stateful Services 245
Reliable Actors 247
Reliable Services 249
Application Lifecycle 251
Service Updates 251
Application Upgrades 252
Testability Framework 253
Summary 254
Appendix A ASP.NET Core 1.0 and Microservices 255
A New Version of ASP.NET 255
Getting Started 256
Choosing the Right ASP.NET Docker Image 262
Visual Studio 2015 Tooling 263
ASP.NET Microservices Best Practices 265
Index 275
About the Author :
Boris Scholl is a Principal Program Manager on the Microsoft Azure compute team, looks after Service Fabric custom application orchestration, container integration, and Azure’s OSS developer and DevOps story for container based workloads Prior to this, he was leading the Visual Studio Cloud Tools team focusing on architectural and implementation patterns for large scale distributed Cloud applications, IaaS developer tooling, provisioning of Cloud environments and the entire ALM life cycle. Boris gained his experience by working as an architect for global cloud and SharePoint solutions with Microsoft Services. In addition to being a speaker at various events, Boris is author on many articles related to Azure development and Diagnosing cloud applications as well as co-author of the book SharePoint 2010 development with Visual Studio 2010 (Addison Wesley Professional).
Trent Swanson is a typical entrepreneur. As a co-founder and consultant with Full Scale 180, he works with some of Microsoft’s largest customers, helping them migrate and build applications on the Microsoft Azure platform. He has been involved in building some of the largest applications running on Microsoft Azure today, some of which now utilize Docker and a microservices architecture. Trent often works with the Microsoft Patterns and Practices team developing guidance and best practices for cloud applications where he also co-authored a book on cloud design patterns. As a co-founder of Krillan and Threadsoft he has built applications based on a microservices architectural style using Docker, Node.js, Go, and Mesos. As a co-founder of B & S Enterprises, he dabbles with various IoT technologies for commercial building management.
Dan Fernandez is a Principal Director managing the Developer Content teams for Visual Studio, Team Services, ASP.NET and parts of Azure. Prior to this, Dan worked as a Principal Program Manager managing the developer experience for Docker including Visual Studio, Visual Studio Code, and Docker continuous integration using Visual Studio Team Services. Dan is also the author of the Channel 9 video series Docker for .NET Developers. You can find Dan on Twitter at @danielfe.