Building Microservices Applications On Microsoft Azure

2y ago
14 Views
3 Downloads
312.27 KB
14 Pages
Last View : 1d ago
Last Download : 3m ago
Upload by : Camille Dion
Transcription

BuildingMicroservicesApplications onMicrosoft AzureDesigning, Developing,Deploying, and MonitoringHarsh ChawlaHemant Kathuria

Building Microservices Applications on Microsoft Azure: Designing,Developing, Deploying, and MonitoringHarsh ChawlaGurugram, IndiaHemant KathuriaNew Delhi, IndiaISBN-13 (pbk): 2-4828-7ISBN-13 (electronic): 978-1-4842-4828-7Copyright 2019 by Harsh Chawla and Hemant KathuriaThis work is subject to copyright. All rights are reserved by the Publisher, whether the whole orpart of the material is concerned, specifically the rights of translation, reprinting, reuse ofillustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,and transmission or information storage and retrieval, electronic adaptation, computer software,or by similar or dissimilar methodology now known or hereafter developed.Trademarked names, logos, and images may appear in this book. Rather than use a trademarksymbol with every occurrence of a trademarked name, logo, or image we use the names, logos,and images only in an editorial fashion and to the benefit of the trademark owner, with nointention of infringement of the trademark.The use in this publication of trade names, trademarks, service marks, and similar terms, even ifthey are not identified as such, is not to be taken as an expression of opinion as to whether or notthey are subject to proprietary rights.While the advice and information in this book are believed to be true and accurate at the date ofpublication, neither the authors nor the editors nor the publisher can accept any legalresponsibility for any errors or omissions that may be made. The publisher makes no warranty,express or implied, with respect to the material contained herein.Managing Director, Apress Media LLC: Welmoed SpahrAcquisitions Editor: Smriti SrivastavaDevelopment Editor: Matthew MoodieCoordinating Editor: Shrikant VishwakarmaCover designed by eStudioCalamarCover image designed by Freepik (www.freepik.com)Distributed to the book trade worldwide by Springer Science Business Media New York,233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is aCalifornia LLC and the sole member (owner) is Springer Science Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/rights-permissions.Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBookversions and licenses are also available for most titles. For more information, reference our Printand eBook Bulk Sales web page at http://www.apress.com/bulk-sales.Any source code or other supplementary material referenced by the author in this book is availableto readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-4827-0.For more detailed information, please visit http://www.apress.com/source-code.Printed on acid-free paper

Dedicated to my son Saahir, my wife Dharna andmy parents—Harsh ChawlaDedicated to my brother who is the guiding force inmy life and career, to my parents who arealways there for me!—Hemant Kathuria

Table of ContentsAbout the Authors xiAbout the Technical Reviewer xiiiAcknowledgments xvIntroduction xviiChapter 1: Evolution of Microservices Architecture 1Key Evaluation Parameters 2Scalability 3Agility 3Resilience 3Manageability 4Monolithic Architecture 4Scalability 6Agility 7Resilience 8Manageability 9Microservices Architecture 10Scalability 12Agility 13Resilience 14Manageability 15Comparison Summary 15v

Table of ContentsChallenges of Microservices 17Database Redesign 17Interservice Communication 18Higher Initial Expense 19Deployment Complexities 19Monitoring 19Versioning 19Summary 20Chapter 2: Implementing Microservices 21Client-to-Microservices Communication 22API Gateway 22The API Gateway Pattern on Azure 28Interservice Communication 29Data Considerations 31Common Database Techniques and Patterns Indexed Views 32Data Warehouse for Reporting Needs 33Security 33Monitoring 34Microservices Hosting Platform Options 34Using Virtual Machines 35Using a Container 36Azure Service Fabric 39Azure Kubernetes Service 40Docker Swarm and Compose 40Mesos DC/OS 41Summary 41vi

Table of ContentsChapter 3: Azure Service Fabric 43What Is Service Fabric? 43Core Concepts 44Service Fabric Application Model 45Scale by Increasing or Decreasing Stateless Service Instances 46Scale by Adding or Removing Named Services Instances 47Supported Programming Models 48Containers 48Reliable Services 49Guest Executable 53ASP.NET Core 54Reliable Actors 54Service Fabric Clusters 54Naming Service 55Image Store Service 55Failover Manager Service 55Repair Manager Service 55Cluster on Azure 55Standalone Cluster or Any Cloud Provider 56Develop and Deploy Applications on Service Fabric 56Develop an ASP.NET Core Stateless Web App 57Develop a Spring Boot Application 84Summary 109Chapter 4: Monitoring Azure Service Fabric Clusters 111Azure Application Insights 112Resource Manager Template 112Application Monitoring 112vii

Table of ContentsAdding Application Monitoring to a Stateless ServiceUsing Application Insights 113Cluster Monitoring 140Infrastructure Monitoring 146Summary 150Chapter 5: Azure Kubernetes Service 151Introduction to Kubernetes 151Kubernetes Cluster Architecture 152Kubernetes Master 153Kubernetes Nodes 154Kubernetes Node Pools 155Pods 155Deployment 155Namespaces 157What Is Azure Kubernetes Service? 157AKS Development Tools 158Set up AKS and Development Tools for Labs 159Create an Azure Kubernetes Service Cluster 159Enable Azure Dev Spaces on an AKS Cluster 161Configure Visual Studio to Work with an Azure Kubernetes Service Cluster 161Configure Visual Studio Code to Work with an AzureKubernetes Service Cluster 163Deploy Application on AKS 166Develop ASP.NET Core Web App and Deploy on AKS 166Create an ASP.NET Core Web API 166Develop Node.js Using Visual Studio Code and Deploy It on AKS 170Create a Node.js API 170Summary 177viii

Table of ContentsChapter 6: Monitoring Azure Kubernetes Service 179Monitoring 179Azure Monitor and Log Analytics 180Create an AKS Cluster from the Portal 180Create an AKS Cluster with Azure CLI 182Monitoring AKS Clusters 183Monitor from AKS 184Monitoring a Multi-Cluster from Azure Monitor 188Native Kubernetes Dashboard 189Prometheus and Grafana 190Summary 191Chapter 7: Securing Microservices 193Authentication in Microservices 193Implementing Security Using an API Gateway Pattern 195Azure API Management 195Ocelot 197Hands-on Lab: Creating an Application Gateway Using Ocelot andSecuring APIs with Azure AD 198Setting up a Development Environment 198Azure AD Application Registrations 199Develop an API Gateway, Back-end Service, and Client Application 202Summary 223Chapter 8: Database Design for Microservices 225Data Stores 225RDBMS 226NoSQL 227Monolithic Approach 229ix

Table of ContentsMicroservices Approach 230Two-Phase Commit 231Eventual Consistency 233Harnessing Cloud Computing 233Infrastructure as a Service (IaaS) 234Platform as a Service (PaaS) 235Database Options on Microsoft Azure 236RDBMS Databases 236Azure SQL DB 237SQL Managed Instance 238NoSQL Databases 240Overcoming Application Development Challenges 241Challenge 1 242Challenge 2 242Challenge 3 243Challenge 4 244Summary 244Chapter 9: Building Microservices Applications on Azure Stack 245Azure Stack 246Services Available in Azure Stack 246Azure Stack Deployment Modes 247Offering IaaS 248PaaS On-Premises Simplified 249SaaS on Azure Stack 251Summary 255Index 257x

About the AuthorsHarsh Chawla has been part of Microsoftfor last 11 years and has done various roles currently, a Solutions Sales Professional withMicrosoft GSMO. He has been working withlarge IT enterprises as a strategist to optimizetheir solutions using Microsoft technologieson both private and public cloud. He is anactive community speaker and blogger on dataplatform technologies.Hemant Kathuria is a consultant withMicrosoft Consulting Services. He is assistingtop Indian IT companies and customers indefining and adopting cloud and mobilestrategies. He is an advocate of MicrosoftAzure and a frequent speaker at various publicplatforms such as Microsoft Ignite, TechReady,Tech-Ed, Azure Conference, and FutureDecoded.xi

About the Technical ReviewerDevendra G. Asane is currently working as aCloud, BigData and Microservices Architectwith Persistent Systems. Prior to this he hasworked with Microsoft.Devendra lives with wife Seema and sonTeerthank in Pune, India.xiii

AcknowledgmentsHarsh Chawla – I’d like to thank my wife and our families who alwayssupported me and believed in me. Writing this book has been an enrichingjourney. I am eternally grateful to all my mentors especially NarinderKhullar, Pranab Mazumdar and Ashutosh Vishwakarma for their selflesssupport and inspiration. Lastly, thanks to the entire Apress team for theirsupport to complete this book on time.Hemant Kathuria – Thanks to entire Apress team especially Matthew,Shrikanth and Smriti, for helping us complete this book on time. A specialthanks to Varun Karulkar for his contribution to this book.xv

IntroductionIn the era of digital disruption, every organization is going through a majortransformation. Every organization is rushing towards building businessesonline. Business applications are becoming mission critical and anydowntime can cause huge business impact. There is a critical need to buildhighly agile, scalable and resilient applications. Therefore, microservicesarchitecture has gained huge momentum over the past few years.This book covers the need and the key evaluation parameters ofmicroservices architecture. It covers the scenarios where microservicesarchitecture is preferred over the monolithic architecture, based on thelearning from large-scale enterprise deployments.The book covers practical scenarios and labs to gain hands onexperience. There is an in-depth focus on the critical components forbuilding, managing and orchestrating the microservices applications.You will learn the following: Need, Evolution and Key Evaluation parameters forMicroservices Architecture Understand the scenarios where microservicesarchitecture is preferred over monolithic architecture Architecture patterns to build agile, scalable andresilient microservices applications Develop and Deploy Microservices using Azure ServiceFabric and Azure Kubernetes Service (AKS)xvii

Introductionxviii Secure microservices using Gateway Pattern Deployment options for Microservices on Azure stack Database patterns to handle complexities introducedby Microservices

support and inspiration. Lastly, thanks to the entire Apress team for their support to complete this book on time. Hemant Kathuria – Thanks to entire Apress team especially Matthew, Shrikanth and Smriti, for helping us complete this book on time. A special thanks to Varun Ka

Related Documents:

applications. However, the advent of Microservices in the recent past has been so great and capable that organizations across the globe have started to implement Microservices in order to re-build their existing applications. According to the Red Hat 2017 Microservices Survey, "According to 67% Middleware customers and 79% Openshift

7. Refactoring a Monolith into Microservices – In a perfect world, we would always get . building, and deploying microservices You will learn about the microservices approach and . large number of developers over many years to create such a beast. Once your application h

Microservices are an approach to distributed systems that promote the use of finely grained services with their own lifecycles, which collaborate together. Because microservices are primarily modeled around business domains, they avoid the problems of traditional tiered architectures. Microservices also integrate new technologies and

To be cloud native, applications need to have the following architecture elements: Microservices Service Oriented Architecture has evolved into a more loosely coupled microservices architecture. Modern architecture is microservices-oriented and based on the 12 factor app principles. Microservices enable greater agility and speed,

service-oriented thinking, we have found that this . Microservices adoption moved quickly from an emerging concept to the . de facto. . One of the key drivers for microservices architecture is the ability to scale horizontally and dynamically. Microservices granularity levels.

YoY cost savings of more than 20% on enterprise IT budgets for API/microservices adoption. Software reuse via microservices adoption reduces TCO by 25-30%. New services adoption time reduced by more than 90%. End-to end business agility established through DevOps/Cloud Ops methodologies which are tailor-made for microservices implementation.

utilization at low cost. The monolithic design approach for building such cloud services makes them hard to build, to update, and to scale. As a result modern cloud applications are increasingly being built using a microservices architecture. This philosophy involves building smaller and modular components (the microservices), con-nected via .

introduce concepts, explain their importance to building production-ready microservices, offer examples of each concept, and share strategies for their implementation. Importantly, this book is not an encyclopedic account of all the possible ways that microservices and microservice ecosystems can be built and run. I will be the first to admit