29,99 €
Companies face several challenges during cloud adoption, with developers and architects needing to migrate legacy applications and build cloud-oriented applications using Azure-based technologies in different environments. A Developer’s Guide to Cloud Apps Using Microsoft Azure helps you learn how to migrate old apps to Azure using the Cloud Adoption Framework and presents use cases, as well as build market-ready secure and reliable applications.
The book begins by introducing you to the benefits of moving legacy apps to the cloud and modernizing existing ones using a set of new technologies and approaches. You’ll then learn how to use technologies and patterns to build cloud-oriented applications. This app development book takes you on a journey through three major services in Azure, namely Azure Container Registry, Azure Container Instances, and Azure Kubernetes Service, which will help you build and deploy an application based on microservices. Finally, you’ll be able to implement continuous integration and deployment in Azure to fully automate the software delivery process, including the build and release processes.
By the end of this book, you’ll be able to perform application migration assessment and planning, select the right Azure services, and create and implement a new cloud-oriented application using Azure containers and orchestrators.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 281
Veröffentlichungsjahr: 2023
Migrate and modernize your cloud-native applications with containers on Azure using real-world case studies
Hamida Rebai Trabelsi
BIRMINGHAM—MUMBAI
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rahul Nair
Publishing Product Manager: Surbhi Suman
Senior Editor: Divya Vijayan / Romy Dias
Technical Editor: Arjun Varma
Copy Editor: Safis Editing
Project Coordinator: Ashwin Kharwa
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Ponraj Dhandapani
Marketing Coordinator: Nimisha Dua
First published: January 2023
Production reference: 1190123
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80461-430-3
www.packtpub.com
To my mother, Rafika Boukari, and to the memory of my father, Mongi Rebai, for their sacrifices, their blessings, and the constant support that they have been for me. To my husband, Mohamed Trabelsi, for supporting me during my writing journey. To my son, Rayen Trabelsi, and my baby daughter, Eya Trabelsi, for their smiles every day that keep me always motivated.
While I don’t have a crystal ball, perhaps in a few years we will look back at this digital age and consider it to be an inflection point in how we host, build, and manage applications. Cloud services have already transformed how developers can build amazing applications and services, and this trend is only starting; there is so much more to come. As I am writing this foreword, we can see that AI will become the next tool in the developer’s toolbox, making it easier to transform amazing ideas into reality.
The adoption of cloud-native services, containers, and orchestration platforms as key building blocks in application architectures may appear to you like new(ish) ideas, but ultimately, I believe that this book will show you how they can enable you to deliver more value and focus on what counts the most. Capabilities that not too long ago were reserved for mega-scale scenarios have become available and accessible to all types and sizes of applications.
I have had the opportunity to collaborate with Hamida over the last few years on a number of initiatives in my role at Microsoft and witnessed first hand how she has been a change driver of this transformation, notably in terms of guiding individuals and organizations in leveraging the power of the cloud, but perhaps more importantly, in adopting a growth mindset, fostering a learning culture, and embracing change and curiosity.
I truly think that we are on a lifelong journey of change, and we should not be daunted by this, but rather embrace it, and you may be surprised where this will take you.
This book will provide you with meaningful and practical scenarios and examples that I think will resonate with you, regardless of where you are in your journey as a cloud practitioner, and give you new perspectives on how you can build highly resilient and scalable applications.
Throughout the chapters of this book, you will go through several technical scenarios where Hamida provides guided steps on how this can be implemented. I will leave you with this very small proposal: make sure you set some time aside for hands-on experimentation. It has become very simple to leverage a number of free options for practice and learning, such as Microsoft Learn sandboxes, and, like Hamida, I have found them extremely useful to fuel my curiosity and creativity.
I wish you success in your journey.
Marc-Andre Laniel
Senior Program Manager, Enterprise Skilling @Microsoft
Hamida Rebai Trabelsi has been working in the computing domain for over 12 years. She started her professional career in Tunisia working for MNCs as a software developer, then served as a .NET consultant at CGI, Canada, and currently, she is a senior advisor and information and solution integration architect at Revenu Québec, Canada. She has been awarded Most Valuable Professional in Developer Technologies and Microsoft DevHero by Microsoft and holds several Azure certifications. Besides being a Microsoft Certified Trainer and a member of .NET Foundation, Hamida is a blogger, an international speaker, and one of the finalists in the Women in IT Award Canada 2019.
This is my first book, and I have been overwhelmed by the support I have received from the Packt team, who encouraged me during the process. I feel proud that I was able to finish this book and share my experience as a developer starting with Azure. To the memory of my father, Mongi Rebai, I offer this book to you and I hoped that you were with me sharing this new adventure in my professional career. Thank you to my mum, Rafika Boukari, for her sacrifices and support. Thank you to my husband, Mohamed Trabelsi, for believing in me. Every day, I wake up and see my son, Rayen Trabelsi, and my baby girl, Eya Trabelsi, and I feel more motivated, so thank you for this energy.
Ryan Mangan is a cloud and an end user computing technologist focusing on application migration and modernization. He's an international speaker on a wide range of topics, an author, and has helped customers and technical communities over the past decade. Ryan is a chartered fellow of the British Computer Society, a Microsoft Most Valuable Professional (MVP), as well as a VMware vExpert, and Very Important Parallels Professional (VIPP).
Stefano Demiliani is a Microsoft MVP on Azure and business applications, a Microsoft Certified Solution Developer (MCSD), an Azure Certified Architect, and an expert in other Microsoft-related technologies. His main activity is architecting and developing enterprise solutions based on the entire stack of Microsoft technologies (mainly focused on ERP and serverless architectures). He has worked with Packt Publishing on many IT books related to Azure cloud applications and Dynamics 365 Business Central, and is a frequent speaker at conferences around Europe. You can reach him on Twitter (@demiliani) or LinkedIn.
Azure is a public Cloud computing from Microsoft provider. It provides a range of Cloud services including compute, network, storage and analytics. Users are able to select from them to develop and scale new or existing application in the Cloud.
Further development of applications, processes, and infrastructure is critical to successfully modernizing your organization and achieving your strategic goals. To increase business value, enterprises are adopting new application architectures that can deliver new capabilities quickly and flexibly. Agile business processes optimize operational efficiency and accelerate response to changing market conditions. Essentially, cloud-based infrastructure allows companies to control costs and, importantly, benefit from new innovations. Containers are one of the key technologies for modernizing and optimizing IT.
The goal of this book is to modernize your application by adopting containers and processes. We’ll learn which Azure services to choose to run your application and how select the suitable service based on your needs. There are many options in Azure to run your applications. These range from VMs to Container to Cloud Services and we will explore the foundational knowledge of the Microsoft Azure landscape that will help you as you move forward to pick the right services in Azure for your applications.
This book is essentially intended for Cloud developers, software architects, system administrators, developers, and computer science students looking to understand the new role of software architect or developer in the cloud world.
This book is also for Professionals looking to enhance their cloud and cloud-native programming concepts will also find this book useful and looking to explore the possibilities on Azure. But they should have a strong background in C#, ASP.NET Core, Visual Studio (any recent version) and a basic knowledge of cloud computing will be helpful when using this book.
Chapter 1, An Introduction to the Cloud-Native App Lifecycle, starts by introducing a basic concept of building and deploying Cloud-based apps. Cloud-native is the core of application innovation and modernization. It compares monolithic and microservices and their architectures. It also briefly discusses the application lifecycle dans design and serverless applications that help to build and run scalable applications. It focusses also on the 12 Factor Application design methodology.
Chapter 2, Beginning Your Application Migration, covers Cloud Adoption Framework that is a guidance and best practices to adopt the Cloud. It also briefly discusses the difference between Cloud Migration and Cloud Adoption and the different steps to consider to prepare the migration. Cloud Adoption Strategy Assessment and Cloud rationalization are discussed. It evaluates different migration considerations. Azure presents different hosting options to migrate existing or new application using Azure Virtual machines as Infrastructure as a service (IaaS), and different Azure service as platform as service (PaaS).
Chapter 3, Migrating Your Existing Applications to a Modern Environment, begins with the benefits of moving legacy apps to the cloud and modernizing the existing legacy applications using a set of new technologies and approaches. It covers the migration of an ASP.NET Web solution to different environments: Azure VM using Microsoft migration tools and services or Azure App Service or Windows container. It covers also the database migration to Azure using different tools and services including the assessment phase.
Chapter 4, Exploring the Use Cases and Application Architecture, presents the solution reference and its architecture that will be used in the book to understand the different services to be used in Azure. This chapter will define the difference between monolithic architecture and microservices architecture. To build large-scale applications, we need to consider the different challenges and the solutions for distributed data management.
Chapter 5, Learning Cloud Patterns and Technologies, covers the different Cloud Design Pattern and technologies to build reliable, scalable and secure Cloud-based applications.
Chapter 6, Setting Up an Environment to Build and Deploy Cloud-Based Applications, covers the environment preparation to build Cloud-Native application. The book will define the prerequisites. It presents the different tools, framework, and technologies in Windows and Linux.
Chapter 7, Using Azure App Service to Deploy Your First Application, covers the creating and the deploying of an Azure App Service resource using different operating systems and platforms. This chapter will help you to select the right App Service plan and exploring a set of features like App Service deployment slots and scaling options. It discusses the deployment of a Cloud-based application to App Service.
Chapter 8, Building a Containerized App Using Docker and Azure Container Registry, starts by discussing the development process for Docker-based applications. It starts by defining the basic concepts related to Docker container, images dans Dockerfile implementation. This chapter presents Azure Service to deploy containers in the Cloud. It discusses the creating of Azure Container Registry and Azure Container Instances..
Chapter 9, Understanding Container Orchestration, covers the container orchestration. This chapter start by comparing between Docker containers and orchestrators and Kubernetes cluster architecture. This chapter will present Azure Kubernetes Services and Azure Container Apps. For multi-container applications, we will deploy microservices using Docker Desktop and Kubernetes.
Chapter 10, Setting Up a Kubernetes Cluster on AKS, covers the creating of Kubernetes Cluster on Azure Kubernetes Service. This chapter will discuss the deployment of an application to the cluster. Azure DevOps Starter will be detailed to deploy a Kubernetes Cluster. To deploy an application deployed in Azure Kubernetes Services, we will present Bridge to Kubernetes extension in Visual Studio.
Chapter 11, Introduction to Azure DevOps and GitHub, starts by defining DevOps and the basic concepts. In this chapter, we will discuss about DevOps tools like Azure DevOps and GitHub.
Chapter 12, Creating a Development Pipeline in Azure DevOps, covers the setting up of Azure DevOps environment. In this book, we will create a build pipeline and release pipeline in Azure Pipeline and we will create a continuous integration and continuous deployment pipeline for GitHub repo using Azure DevOps Starter.
The most of examples presenting the solution reference are presented using .NET 6, basic knowledge in C# and .NET technology is essential to understand described topics.
Software/hardware covered in the book
Operating system requirements
.NET 6 and .NET 7
Windows, macOS, or Linux
Docker Desktop
Windows, macOS, or Linux
Visual Studio 2022 (community edition)
Windows or macOS
Visual Studio Code
Windows, macOS, or Linux
Service fabric runtime
Window or Linux
We assume that you are able to install Visual Studio Code as an IDE or Visual Studio 2022, the community edition is enough to run the examples if you don’t have access to the commercial license.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
All examples are used to explain the use of every Azure Service.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/A-Developer-s-Guide-to-Cloud-Apps-Using-Microsoft-Azure If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/63FuQ.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “You can add the --deployment-local-git parameter at the end if you use Git to deploy your application.”
A block of code is set as follows:
apiVersion: apps/v1 kind: Deployment metadata: name: booking-frontend-deployment spec:When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
apiVersion: v1 kind: Service metadata: name: booking-frontend-serviceAny command-line input or output is written as follows:
$ az appservice plan create --name myserviceplan --resource-group packtrg --sku D1 --is-linuxBold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Open your solution, right-click on the application to containerize, and then select Add and then Docker Support….”
Tips or important notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read A Developer’s Guide to Cloud Apps Using Microsoft Azure, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781804614303
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyIn this part of the book, we will present the cloud migration journey and the benefits of moving apps to the cloud.
This part comprises the following chapters:
Chapter 1, An Introduction to the Cloud-Native App LifecycleChapter 2, Beginning Your Application MigrationChapter 3, Migrating Your Existing Applications to a Modern EnvironmentChapter 4, Exploring the Use Cases and Application ArchitectureThis first chapter is about introducing the basic concepts of cloud-native development and the lifecycle involved. You will learn the basic concepts behind building and deploying applications on any cloud platform, including adopting a microservices architecture, containerization, and orchestration.
To enable developers to build applications with more flexibility and more portability compared to applications hosted on traditional servers or virtual machines (VMs), we will learn how to use containers and serverless architecture.
To accelerate the product development process and improve the quality of our apps, we will follow the Twelve-Factor Application design principles and methodology. As projects grow, code bases also become more complex, and it is strongly recommended that you test new versions of software.
In this chapter, we’re going to cover the following main topics:
An introduction to cloud-native applicationsApplication designApplication lifecyclesThe Twelve-Factor Application design methodologyServerless applications of cloud-native applicationsIn the continuously competitive market of digital companies, the main issue is IT agility.
However, with technology evolving every day, companies are struggling to catch up with digital transformation, adopt new trends such as the cloud, artificial intelligence (AI), mobility, or the Internet of Things (IoT), and change their business models in order to be able to adapt to the new reality of the market.
This delay is caused by the interdependencies of services related to the lifecycle of an IT project, where changes to the source code of a classic monolithic client-server application can destabilize systems in the maintenance phase.
For this reason, companies are looking to adopt more optimized, scalable architectures to ensure resiliency and continuous availability, while minimizing resource consumption costs and implementing cloud-native applications.
This change should be made quickly, especially for start-ups that want to build rigid infrastructures with minimal costs.
A cloud-native approach includes all the concepts of building and deploying scalable applications in modern, dynamic environments on any cloud platform, be it a public, private, or hybrid cloud. Organizations use cloud-native technologies to build and run scalable applications.
Today, application environments are modern, automated, and dynamic because we can publish any application and store data in a public, private, or hybrid cloud. We can use technologies such as containers, service fabric, and immutable infrastructure, and patterns such as microservices, declarative APIs, and event buses. These techniques help us implement loosely coupled solutions that are easy to maintain, resilient, and observable.
The robust automation of environments, as in the case of infrastructure as code, allows engineers to make major changes frequently without worrying about the impact and with minimal effort.
A cloud-native application has specific features that present the pillars of cloud-native architecture and a design pattern, used to build a new application from scratch that can be deployed in a cloud environment.
Microservices are a part of cloud-native application architecture and run as a bundle independently of each other on a containerized and orchestrated platform. They connect and communicate through APIs.
Figure 1.1 – The pillars of cloud-native architecture
Applications based on cloud-native application architecture are reliable and provide scalability and performance to meet the recurring goal of achieving a fast time to market, if they are well designed.
One of the most important steps in the lifecycle of an application is the design and architecture of the app. This is the most critical aspect prior to starting the implementation, deployment, continuous delivery, and maintenance of an application. The evolution in technologies and patterns always influences the design of applications as we seek to ensure performance and security.
What happens if the application stops working, or crashes for no reason or due to a lack of resources? How are you going to debug it if the error isn’t clear, or if the logs aren’t really good enough?
If you need to ask these questions, then you are on the wrong path – you are not working in a cloud-native application context.
The design of cloud-oriented applications has the objective of taking advantage of the benefits of the cloud. Even the software and services that manage these applications will be deployed in the cloud.
Cloud-native applications are typically microservices embedded in containers running on cloud computing infrastructure. Cloud-native applications use a microservice architecture. This architecture ensures the allocation of resources to each service used by the application more efficiently than the old approaches, such as monolithic applications. This makes an application flexible and adaptable to a cloud-oriented architecture.
It is really important to understand the difference between the traditional monolithic approach and the microservices approach before defining the concept of microservices.
To scale a monolithic application, we have to clone the entire application on multiple servers or VMs. But for a microservices application, scaling is done by deploying every service in multiple instances across servers or VMs.
In a microservices approach, every application is composed of a collection of services that are related to specific functionalities. Every service can be developed, tested, deployed, versioned, and scaled. Monolithic applications are simple to use and easy to develop, deploy, and test, but they have limitations in size and complexity. Despite the simplicity of horizontal scaling, where we run multiple application copies behind a load balancer, it is difficult to do in the case of multiple modules that have conflicting resource requirements.
Microservices are very similar to beehives. Within a hive, thousands of bees coexist and help each other for a single common goal – the survival of the colony. The queen, the workers, and the drones – each one has their peculiarities and must, therefore, assume distinct tasks.
Microservices are regularly discussed now in articles, on blogs, on social media, and even at conference presentations.
How do we use microservices to tackle complexity? In recent years, software architecture has evolved rapidly, from spaghetti-oriented architected where everything was a big jumble, to lasagna-oriented architecture where we can see the layers of architecture, to ravioli-oriented architecture where we talk about microservices. In this latter architecture, we split the application into sets of services instead of building a monolithic application. Maybe we will see pizza-oriented architecture next, where we use a serverless approach. Let’s now take a look at the layered architecture pattern and compare it to microservices.
The layered architecture pattern is the most common architecture pattern and is otherwise known as the n-tier architecture pattern. For distributed n-tier client/server applications, when taking a monolithic approach, you start with a hexagonal modular architecture, where you separate the domain model and the adapters (the devices used for inputs and outputs).
A monolithic application is composed of several layers, including different types of components or layers.
In this classic example, illustrated in Figure 1.2, we have four layers, from the user interface to the database where we store our data:
Presentation layer: This presents the user interface layer; it can be a web or mobile or desktop application.Services layer: This is a set of standards, techniques, and methods. An application is split into services based on functionality and domain. This layer is responsible for handling HTTP requests and responding with either HTML or JSON/XML, as in the case of API services.Business logic layer: This holds the application’s business logic, the heart of our application. This entails custom business rules, such as operation definitions, constraints, and algorithms, that manage the exchange of information between the database layer and the presentation layer.Database access layer: This is an abstraction of the logical data model. The modification of the logical data model is done in the business layer, but we can perform even more complex data manipulations from multiple sources and send them back to the business layer. This layer will ensure access to the database.Figure 1.2 – N-tier architecture pattern for monolithic and microservices architectures
The architecture presented here is logically modular, but the application is packaged and deployed in a single package as a monolith.
Let’s explore the different elements of the monolithic approach:
Monolithic applications are easy to set up because they involve a single complete package. They include all the components, such as the GUI, business layer, data, and related necessary services encapsulated in a single package.This single package is developed in sequential order. At the start of each project, the designers work on the design of the product as well as the necessary documents to meet the needs of the client user. Then, the developers implement code and send it to the quality assurance department in order to carry out the necessary tests.The team of testers runs different types of tests, including integration tests, interface tests, and even performance tests, to identify errors and evaluate the performance of the cloud-native application.If they detect errors, code is sent back to the developers so that it can be debugged and corrected.Once the code passes all the tests, it is deployed in a test production environment similar to the final environment and then deployed in a real environment.If you want to modify the code, add a new feature, or even remove an old feature, you have to start the whole process again. If several teams are working on the same project, taking into account the changes in the teams as developers come and go, coordinating code changes is a challenge and will take a lot of time. Moreover, the deployment of a software project always requires a specific infrastructure configuration as well as the implementation of an extended functional test mechanism. Therefore, in a complex project with dynamic requirements, the whole process is inefficient and time-consuming. Microservices architecture can help to solve most of these challenges.For microservices, the idea is very simple – we divide our application into a set of smaller interconnected services instead of creating a single monolithic application. This is an architectural design model based on the architectural principles of domain-driven design and DevOps – that is, if we have several domains in our application that can interact independently.
Each microservice represents a small application with its own hexagonal architecture. This application is composed of business logic and data.
Some microservices may implement a user interface, such as a web page or mobile application, while others may expose or consume a Representational State Transfer (REST), Application Programming Interface (API), or even a Remote Procedure Call (RPC). Services may be using a message-based system or simply consuming APIs provided by other services.