0% found this document useful (0 votes)
31 views

_OceanofPDF.com_Microsoft_Certified_Azure_Developer_Associate_-_Adora_Nwodo

The document is a study guide for the Microsoft Certified Azure Developer Associate (AZ-204) exam, authored by Adora Nwodo, and published by O'Reilly Media. It provides early release content covering the role of an Azure Developer, the benefits of certification, prerequisites for the exam, and essential cloud computing concepts. The guide emphasizes the importance of Azure in the cloud market and outlines the skills required for Azure Developers, while also offering insights into preparing for the certification exam.

Uploaded by

shah234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

_OceanofPDF.com_Microsoft_Certified_Azure_Developer_Associate_-_Adora_Nwodo

The document is a study guide for the Microsoft Certified Azure Developer Associate (AZ-204) exam, authored by Adora Nwodo, and published by O'Reilly Media. It provides early release content covering the role of an Azure Developer, the benefits of certification, prerequisites for the exam, and essential cloud computing concepts. The guide emphasizes the importance of Azure in the cloud market and outlines the skills required for Azure Developers, while also offering insights into preparing for the certification exam.

Uploaded by

shah234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Microsoft Certified Azure

Developer Associate (AZ-204)


Study Guide
In-Depth Guidance and Practice

With Early Release ebooks, you get books in their earliest form—the
author’s raw and unedited content as they write—so you can take
advantage of these technologies long before the official release of these
titles.

Adora Nwodo

OceanofPDF.com
Microsoft Certified Azure Developer Associate (AZ-204) Study
Guide
by Adora Nwodo
Copyright © 2026 Adora Nwodo. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales
promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
[email protected].

Acquisitions Editor: Megan Laddusaw

Development Editor: Jill Leonard

Production Editor: Christopher Faucher

Interior Designer: David Futato

Cover Designer: Karen Montgomery

Illustrator: Kate Dullea

March 2026: First Edition


Revision History for the Early Release
2024-12-18: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781098173494 for release


details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
Microsoft Certified Azure Developer Associate (AZ-204) Study Guide, the
cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
The views expressed in this work are those of the author and do not
represent the publisher’s views. While the publisher and the author have
used good faith efforts to ensure that the information and instructions
contained in this work are accurate, the publisher and the author disclaim all
responsibility for errors or omissions, including without limitation
responsibility for damages resulting from the use of or reliance on this
work. Use of the information and instructions contained in this work is at
your own risk. If any code samples or other technology this work contains
or describes is subject to open source licenses or the intellectual property
rights of others, it is your responsibility to ensure that your use thereof
complies with such licenses and/or rights.
978-1-098-17343-2

OceanofPDF.com
Brief Table of Contents (Not Yet
Final)

Preface (unavailable)
Chapter 1: Introduction to the Azure Developer Associate Exam (available)
Chapter 2: Azure App Service (available)
Chapter 3: Azure Functions (unavailable)
Chapter 4: Infrastructure as Code (IaC) with Azure Bicep (unavailable)
Chapter 5: Managing Data with Azure Storage Solutions (unavailable)
Chapter 6: Building Containerized Solutions (unavailable)
Chapter 7: Implementing Azure Security (unavailable)
Chapter 8: API Management in Azure (unavailable)
Chapter 9: Event-Driven Architecture with Azure (unavailable)
Chapter 10: Application Insights for Monitoring and Troubleshooting
(unavailable)
Chapter 11: Caching Strategies in Azure (unavailable)
Chapter 12: Networking in Azure (unavailable)
Chapter 13: Developer Practices in Azure (unavailable)
Chapter 14: Putting It All Together (unavailable)

OceanofPDF.com
Chapter 1. Introduction to the
Azure Developer Associate
Exam

A NOTE FOR EARLY RELEASE READERS


With Early Release ebooks, you get books in their earliest form—the
author’s raw and unedited content as they write—so you can take
advantage of these technologies long before the official release of these
titles.
This will be the 1st chapter of the final book. Please note that the
GitHub repo will be made active later on.
If you have comments about how we might improve the content and/or
examples in this book, or if you notice missing material within this
chapter, please reach out to the editor at [email protected].

“The beginning is the most important part of any work, especially in the
case of a young and tender thing, for that is the time at which the
character is being formed and the desired impression is more readily
taken”
—Plato
Becoming Azure certified provides many benefits. In this chapter, you will
learn about the role of an Azure Developer, as well as the benefits of
becoming Microsoft Certified. I’ll also share what’s required of you and
walk through how the exam is structured. Additionally, this chapter will
share tips on how you can create a study plan to further set yourself up for
success. Beginnings lay the foundation for exceptional work.
Understanding the fundamentals of the Azure Developer Associate Exam is
crucial for anyone looking to take this exam in order to make the best of it.
By the end of this chapter, you will be equipped with a clear understanding
of what lies ahead and how to approach your study journey. The road to
certification may be challenging, but with the right preparation and mindset,
it is entirely achievable. Let’s get started on your path to becoming a
certified Azure Developer Associate!

The State of Azure in the Cloud Market


Learning Azure is increasingly important due to its substantial market share
and the expanding role it plays in cloud computing. Azure is one of the
most popular cloud computing platforms right now. As of 2024, Azure
holds a significant position in the global cloud infrastructure market,
capturing approximately 25% of the market share. This places Azure firmly
in second place, just behind AWS, which has a market share of around 31%.
Google Cloud follows with about 11% of the market share. In addition to
market share, it’s also important to consider Azure’s extensive customer
base, which has grown in recent years. As of early 2024, Azure served
nearly 350,000 businesses globally, reflecting a 14.2% increase in its
customer base from the previous year.
Learning Azure gives you the knowledge to take full advantage of its global
network, and this can enhance your ability to support and drive growth for
businesses of different sizes through effective cloud strategies. With
increasing reliance on the cloud, this is a timely skill to develop.

Understanding the Role of an Azure


Developer
The role of an Azure Developer is important in the modern cloud
ecosystem. As businesses increasingly migrate to the cloud, the demand for
skilled Azure Developers who can design, build, and maintain cloud-based
applications and services continues to grow significantly. As you read this
section, it’s important to think of yourself as an Azure Developer in training
and know that these skills are about to become yours as you continue to
develop your knowledge in this area.
Azure Developers are responsible for various tasks, including designing
applications that run on cloud solutions, making sure those applications are
compliant with specified security standards, and optimizing performance.
They work with services like Azure Functions, Azure Kubernetes Service,
VPNs, Azure Security Services, and more to create and maintain secure
applications.
Let’s examine the skills of an Azure Developer:
Technical proficiency
Developers should have a blend of cloud specific skills and
programming knowledge. This means understanding programming
languages like C#, TypeScript, or Python, and also understanding Azure
SDKs, APIs, and development tools like Visual Studio and Azure
DevOps.

Collaboration
Azure Developer’s work across multidisciplinary teams and collaborate
with product managers, security professionals, data analysts, other
software engineers, and more. As a result, it’s important to effectively
communicate and also be a good team player, so that projects meet
technical requirements and business objectives.

Continuous Improvement
The Azure organization within Microsoft is constantly innovating and
creating new cloud services for different things, as well as
improvements to their already existing services. As a result, you should
be committed to continuous learning and improvement so that you
consistently have up-to-date knowledge.
Developing for Scalability
Most of our daily interactions are currently influenced by distributed
applications, and this shows how important they are in technology
today. Working in this discipline involves understanding networking and
using load balancing, auto-scaling, and microservices architecture to
ensure that applications can handle increased traffic and remain
available under various conditions.

Monitoring and Support


In some cases and depending on how your team is structured, you may
also be tasked with monitoring, troubleshooting, and optimization.
Here, you may be required to use tools like Azure Monitor and Azure
Log Analytics to track application performance and identify issues.

Now that you’re clear on some of the priorities of an Azure Developer, let’s
talk about the benefits you get from being Microsoft Certified.

Benefits of Becoming a Microsoft Certified


Azure Developer
Becoming Microsoft Certified can have different benefits that may add
long-term value to your cloud engineering career. Let’s explore a few:

Certifications are a formal validation of your skills and knowledge.


It shows that you have the ability to design, build, test, and
maintain cloud applications and services using Azure. This formal
validation can separate you from your peers that are non-certified,
and gives you an edge when recruiters are assessing candidates.
With a certification, recruiters and hiring managers can quickly see
your expertise, which can lead to more interview opportunities and
potential job offers. This is particularly beneficial in highly
competitive fields where employers are looking for candidates who
have proven their capabilities through recognized credentials.
Earning this certification gives you professional recognition from
both your peers and industry leaders. It highlights your dedication
to professional growth and shows that you are committed to
maintaining high standards in your work. This acknowledgement
can enhance the respect and trust you receive within your
organization and your broader professional network.
Getting certified takes work. It requires a lot of commitment and
involves rigorous study and practical application of your skills.
This contributes to personal growth and increased confidence in
your abilities. As you overcome the challenges of certification, you
build resilience and a deeper understanding of Azure, which can be
applied to different disciplines.
Certifications give you a comprehensive understanding of Azure
that extends beyond the scope of typical project work. As you build
projects, you may only use a limited subset of Azure’s offerings.
Certifications, on the other hand, expose you to the full range of
Azure services and capabilities. This broad knowledge can enhance
your ability to innovate and solve diverse challenges in your cloud
engineering career.
Certifications can make you more attractive to employers,
especially those looking to meet Microsoft partner status
requirements. This demand can increase your job prospects and
make you a valuable candidate for many companies.

Ultimately, the decision to pursue certification is personal, but the rewards


in career advancement, recognition, and personal development make it a
worthwhile endeavor.

Prerequisites
Here are some of the prerequisites you’ll need as you get ready to take the
exam. Having these foundations will also be very helpful as you continue
reading this book.
Cloud Fundamentals
Before diving into Azure-specific skills, it’s important to have a solid
understanding of fundamental cloud computing concepts. This includes
knowledge of different cloud service models such as Infrastructure as a
Service (IaaS), Platform as a Service (PaaS), and Software as a Service
(SaaS). It’s also important to understand cloud deployment models - public,
private, and hybrid clouds. Let’s do a quick review:

Cloud service models


Cloud service models are frameworks that define how cloud services are
delivered and utilized. Here are the three main cloud service models:
Infrastructure as a Service
IaaS provides businesses with virtualized computing resources over the
internet. It allows businesses to have on-demand access to cloud
infrastructure such as servers, storage, and networking.

Platform as a Service
PaaS provides businesses with tools, or platforms, over the internet.
These tools are designed to help businesses with building, testing,
deploying, and managing cloud applications.

Software as a Service
SaaS provides everyone with software applications over the internet, on
a subscription basis.

Cloud deployment models


Cloud deployment models specify the configuration of a cloud
infrastructure. These models define how cloud services are made available
to users and how resources are allocated and managed. The four main cloud
deployment models are:
Public Cloud
With this model, services are delivered publicly over the internet and
shared across multiple organizations. These services are usually owned
by third-party cloud providers.

Private Cloud
With the private cloud, an organization has access to a cloud computing
environment that is dedicated exclusively to its use. This setup can be
hosted on-premises in the organization’s own data center or by a third-
party service provider.

Hybrid Cloud
In the hybrid cloud, an organization combines public and private clouds,
allowing data and applications to be shared between them. This model
combines the scalability and cost-efficiency of public cloud services
with the control and security of a private cloud.

Multicloud
In a multicloud model, organizations use multiple cloud computing
services from different providers simultaneously. This allows them to
distribute workloads across various cloud environments, optimizing for
performance, cost, and specific service features. Unlike hybrid cloud,
which integrates public and private clouds to create a unified
environment, multicloud does not necessarily connect these clouds;
instead, it focuses on using the best services from each provider
independently. This approach helps businesses avoid vendor lock-in,
enhance reliability by diversifying their cloud strategy, and take
advantage of the unique strengths and pricing options of each provider..

Community Cloud
A community cloud is shared by a group of organizations with similar
needs, like security, compliance, or business goals. It provides a cloud
environment tailored to these shared needs, allowing the organizations
to work together while keeping control over their data and resources.
Knowing these deployment models helps you choose the right one for your
needs. Each model has its benefits and can be customized to fit what you
require. I assume you have this knowledge if you’re preparing for the Azure
developer certification. If these topics are unfamiliar to you, I recommend
you take time to familiarize yourself with them prior to continuing with this
book so you’re able to get the most out of this publication. To learn more
about the fundamentals of the cloud, you can read my third book called
Confident Cloud. You also can read Essentials of Cloud Computing by K.
Chandrasekaran, Cloud Computing by A. Srinivasan, or Cloud Computing
Basics: A Non-Technical Introduction by Anders Lisdorf.

An Azure Account
Having an active Azure account is important for hands-on practice and
learning. Microsoft gives free Azure accounts with a limited amount of
credits to get started. You can create a free account by visiting
https://portal.azure.com. It’s important to note that while you do need to
enter your credit card details to sign up, you won’t be charged unless you
choose to upgrade or exceed the free tier limits. Microsoft provides clear
alerts before any charges are incurred, ensuring you stay within your budget
and avoid unexpected costs. An active Azure account allows you to:

Explore the Azure Portal


Deploy resources like web apps, databases, storage accounts,
virtual machines, and more.
Use Azure’s monitoring tools to track resource usage and
performance.

Azure CLI
The Azure CLI is a set of commands that you can use to create and manage
Azure resources. This CLI allows you to interact with Azure services
through the command line. With the Azure CLI, you can:
Write command line scripts to automate tasks on Azure.
Perform actions that help you manage your Azure resources.
Retrieve information about your Azure resources and troubleshoot
issues.

You can get the Azure CLI on Microsoft’s website. It’s available for
Windows, MacOS, Linux, and you can also run it in your Docker container.

Azure PowerShell
Azure PowerShell is another command-line tool that allows you to manage
your Azure resources using PowerShell cmdlets. It provides an alternative
to the Azure CLI and is particularly useful for people who are already
familiar with PowerShell scripting. With Azure PowerShell you can:
Automate tasks on Azure and manage your Azure resources.
Add more complex scripts to your CI/CD pipeline to make it more
dynamic.
Retrieve information about your Azure resources and troubleshoot
issues.

You can download Azure PowerShell on Windows, Linux, MacOS, or your


Docker container.
PowerShell, the underlying framework, is a cross-platform command-line
shell and scripting language used for automating tasks and managing
configurations. It passes objects between commands for efficient data
handling and supports a wide range of extensions through modules, such as
Azure PowerShell. This makes it a versatile tool for managing systems
across different environments, integrating with other Microsoft products,
and enhancing automation workflows. For more information or to
download PowerShell for your machine, visit the Microsoft PowerShell
page.
Eligibility Criteria
In addition to the prerequisites, here are some eligibility criteria for taking
the Azure certification exam:

Candidates should have at least one to two years of professional


experience in developing cloud applications with Azure.
Candidates should also be able to program in an Azure supported
language such as Python, C#, JavaScript, and Java.
Candidates should be proficient in Azure because this is the
knowledge that the certification exam checks for. Specifically, they
should be proficient in Azure SDKs, data storage options, data
connections, APIs, security features (authentication and
authorization), container services, and debugging.
They should also be proficient in Azure CLI, Powershell, and
CI/CD. This familiarity is important for implementing and
managing Azure DevOps pipelines.
Additionally, the skills measured for this certification cover several critical
areas. These include developing Azure compute solutions, which involve
creating and managing virtual machines and containerized applications.
Candidates must also know how to develop for Azure storage using services
like Azure Blob Storage and Databases. Implementing Azure security is
another key area, focusing on safeguarding data and applications using tools
such as Azure Active Directory and role-based access control. Additionally,
the certification covers monitoring, troubleshooting, and optimizing Azure
solutions to maintain and enhance performance.
All of these areas will be covered in this book.

Overview of the Exam Structure


The Microsoft Certified: Azure Developer Associate certification (Exam
AZ-204) validates essential skills for developing applications and services
on Microsoft Azure. Here’s an overview of its structure:

Exam Format
The AZ-204 exam is an online, monitored exam. It typically lasts 100
minutes and includes a variety of question types. Candidates should allocate
approximately two hours for the entire process, which includes reviewing
instructions, signing the non-disclosure agreement, and providing feedback.

Exam Registration and Policies


Candidates can register for the exam through the Microsoft Certification
Dashboard. The exam fee varies by location, but is generally around $165
USD. The exam may contain interactive components, is supervised, and
isn’t a closed book assessment. If a candidate fails, a 24-hour wait is
required before retaking the exam.
Candidates can also take unscheduled breaks during the exam, but the exam
clock will continue to run, so it’s important to note this and schedule your
time accordingly.

Preparing a Study Plan


Preparing for the AZ-204 exam requires a structured study plan to help you
cover the exam objectives so that you are ready. Here’s how you can create
an effective study plan:

Understand the subject areas the exam covers: We’ve talked about
this in this chapter, so you should now have an idea of the skills
measured and topics covered. This will help you to focus your
studying on the important things you really need to know.
Study: Reading this book is a great first step because this study
guide will cover all the key areas needed for the exam. You’ll find
detailed explanations, practical examples, and tips to help you
understand and apply the concepts. This book, combined with
hands-on practice, will prepare you thoroughly for the certification
exam.
Set a study schedule and track your goals: Break down your study
sessions into manageable chunks and allocate time to each exam
objective. For example, you can do something like this:

Week 1-2: Developing Azure compute solutions


Week 3-4: Developing for Azure storage
Week 5: Implementing Azure security
Week 6: Monitoring and optimizing solutions
Week 7: API Management
Weeks 8-10: Review and practice exams

Note that the number of weeks you allocate to each exam objective
and how you break down your learning should be based on:

Your Current Knowledge: Spend more time on areas


where you have less experience.
Learning Style: Adjust the pace and methods to suit your
personal learning preferences.
Schedule Flexibility: Consider your availability and other
commitments you might have and account for this when
creating your study plan so that it’s sustainable.
Practice: Theoretical knowledge is necessary, but practicing on
Azure is how you verify that you know what you’ve read about.
Create case studies for problems you’re passionate about and
implement solutions using various Azure services. Experiment
with deploying applications, setting up storage, configuring
security, and integrating third-party services. This hands-on
practice not only reinforces your learning but also helps you build
a portfolio of real-world projects that demonstrate your skills to
potential employers. Beyond practicing for your certification, these
portfolio projects may also help you get jobs.
Join communities: If there are Azure user groups, or other
communities around you, you could join them to meet people
currently building on Azure, too. These communities can provide
support and tips from fellow learners, certified professionals, and
other builders in the ecosystem.
Take mock exams: Regularly review what you’ve learned to
reinforce your knowledge. Take mock exams to test your
understanding and adjust your study plan based on your
performance. As you iterate, you should also identify weak areas
and focus more on those topics.
Final revision: In the final weeks leading up to the exam, you
should focus on revision (as opposed to learning something new).
Go over all the exam objectives, ensure you understand key
concepts, and take several full-length practice exams to build
confidence.
With a structured plan and consistent effort, you’ll be well-prepared to pass
the AZ-204 exam and advance your career in Azure and the cloud.

Summary
Effective preparation is essential for understanding the exam objectives and
structure. Achieving the Azure Developer Associate certification not only
validates your skills but also opens up numerous career opportunities,
making you a valuable asset in the tech industry. With dedication and the
right preparation strategy, you are well on your way to becoming a certified
Azure Developer Associate. The following chapters will focus on the core
concepts of Azure. Good luck on your journey!

OceanofPDF.com
Chapter 2. Azure App Service

A NOTE FOR EARLY RELEASE READERS


With Early Release ebooks, you get books in their earliest form—the
author’s raw and unedited content as they write—so you can take
advantage of these technologies long before the official release of these
titles.
This will be the 2nd chapter of the final book. Please note that the
GitHub repo will be made active later on.
If you have comments about how we might improve the content and/or
examples in this book, or if you notice missing material within this
chapter, please reach out to the editor at [email protected].

Azure App Service makes it easy to deploy, manage, and scale your web
apps. It’s a fantastic platform for developers to leverage so they can focus
on what they do best: building great applications. Azure App Service
supports multiple programming languages including .NET, Java, Node.js,
PHP, or Python, and provides a managed platform (PaaS) that abstracts
away the underlying infrastructure. This means that developers can deploy
their applications without worrying about server management, patching, or
networking. Additionally, Azure App Service automatically handles scaling,
load balancing, and high availability, ensuring that applications remain
responsive and resilient under varying loads.
In this chapter, you will see how to use Azure App Service for your web
application development and deployment processes. First, you will be
introduced to the features and benefits of Azure App Service, providing a
solid foundation for understanding its capabilities. Next, you will go
through the process of building and deploying web applications using this
platform, highlighting best practices and tips for optimal performance.
You’ll also see how you can use Azure DevOps and GitHub Actions to
deploy an app to App Service. Finally, you will learn about advanced
deployment techniques such as blue-green deployments using deployment
slots.

Introduction to Azure App Service


Azure App Service is a comprehensive cloud offering from Microsoft Azure
that allows developers to build, deploy, and scale web applications, mobile
back-ends, and RESTful APIs quickly and efficiently. As a fully managed
platform-as-a-service (PaaS), it abstracts away the underlying
infrastructure, enabling developers to focus solely on application
development.
Another significant advantage of Azure App Service is its managed
production environment. This platform automatically handles the patching
and maintenance of the operating system and language frameworks, freeing
developers from routine administrative tasks. This allows them to focus on
writing great applications while Azure takes care of the underlying platform
maintenance. Additionally, Azure App Service supports containerization
and Docker, enabling developers to dockerize their applications and host
custom Windows or Linux containers. This feature also supports running
sidecar containers, making it easier to migrate Docker-based applications to
Azure.
Azure App Service is optimized for DevOps practices, and it is fairly
straightforward to use it with continuous integration and deployment tools
like Azure DevOps, GitHub, BitBucket, Docker Hub, and Azure Container
Registry. App Service also supports scaling applications globally with high
availability, allowing developers to host their apps anywhere within
Microsoft’s extensive data center infrastructure. Azure’s global reach and
the App Service SLA (Service Level Agreement) ensure that applications
remain highly available and performant.
Security and compliance are top priorities for Azure App Service, which is
ISO, SOC, and PCI compliant. These standards are important for keeping
data safe and ensuring that cloud services are secure and reliable:

ISO Compliance refers to standards set by the International


Organization for Standardization, which ensures best practices for
security management.
SOC Compliance stands for Service Organization Controls, which
are reports that verify a service’s controls, like security and data
handling, are effective.
PCI Compliance refers to the Payment Card Industry standards that
ensure secure handling of credit card information.

Azure App Service also provides robust security features, including IP


address restrictions, managed service identities, and protection against
subdomain takeovers. Now that you’ve been introduced to Azure App
Services and their advantages, the next section will cover how to build and
deploy web apps.

WHAT IS A SERVICE LEVEL AGREEMENT?


An SLA is an agreement from a cloud provider (e.g., Microsoft) that
defines the expected level of service, such as uptime and performance.
It’s essentially a promise that the service will be available a certain
percentage of the time, like 99.99%, and outlines what happens if the
provider fails to meet these expectations. This helps you understand the
reliability you can expect for your applications.

Building and Deploying to App Service


Building and deploying web apps to Azure App Service involves several
steps.
Minimally, you’ll need:
The Azure CLI: The Azure Command-Line Interface (CLI) is a set
of commands used to create and manage Azure resources. You can
download it from Microsoft.
Azure PowerShell: Azure PowerShell has a set of commands used
to create and manage Azure resources. You can download it from
Microsoft.
To create an Azure Account: You’ll be creating an Azure service
and also deploying your code to Azure. If you don’t have an Azure
account, sign up through Microsoft .

Next, I’ll walk through how to create your app service infrastructure and
deploy your web app to it using the Azure CLI, Azure PowerShell and the
Azure Portal.

Using Azure App Service in the Azure CLI


To get access to Azure through the CLI, you need to run:

$ az login

This command allows you to access your Azure account through the Azure
CLI. When you run this command, it will open a web page where you can
sign in with your Azure credentials. After signing in, the CLI will have
access to your Azure resources and you can start executing various Azure
commands to manage your services and infrastructure.
In order to create an App Service, you will need to create a resource group
first. In Azure, a resource group is a logical container that holds related
resources for an Azure solution. You can manage and organize resources
like databases, storage accounts, and web apps within a resource group.
When creating resources in Azure, it’s important to understand the concept
of scopes. Scopes in Azure define the boundaries within which permissions
are granted. The main levels of scope are:
Tenant
A tenant is a dedicated instance of Microsoft Entra ID (previously
known as Active Directory) that an organization receives when it signs
up for a Microsoft cloud service such as Azure. A tenant can contain one
or more subscriptions. It’s the highest level of organization in Azure,
and it manages users, groups, and applications across all subscriptions
within the tenant.

Management Group
This is the second-highest level of scope. Management groups help you
organize your subscriptions, making it easier to manage access, policies,
and compliance for multiple subscriptions. You can apply policies and
access controls to a management group, and they will be inherited by all
subscriptions and resources within that group.

Subscription
Each subscription can have multiple resource groups and is associated
with billing. Subscriptions help you separate resources for different
projects, environments, or teams. They also act as a security boundary
for resources.

Resource Group
Within a subscription, resource groups help you organize and manage
related resources. A resource group acts as a container for resources that
share the same lifecycle, allowing you to deploy, update, and delete
them together. You can apply policies, permissions, and monitoring at
the resource group level.

Resource
This is the smallest scope. A resource could be any service instance you
create, such as a virtual machine, storage account, or web app.
Resources inherit permissions and policies from their parent resource
group, subscription, and management group.
Now that you know what scopes are and the different scopes in Azure, run
the following command to create an Azure resource group that will hold the
Azure App Service resource.

$ az group create --name SampleRg --location eastus

The code snippet above creates a resource group named SampleRg in the
eastus region. In Azure, regions are specific geographic locations where
data centers are situated. Choosing a region is important because it
determines where your resources are physically located, which can affect
performance, compliance, and availability. For example, you might choose
a region close to your users for faster access or select a region that meets
specific regulatory requirements.
Now that you’ve created your resource group, you can create the app
service plan.

WHAT IS AN APP SERVICE PLAN?


An App Service plan in Azure provides the resources for your web apps
to run. When you create an App Service plan, you select the region,
pricing tier, and instance size(s) that determine the compute resources
available for your web applications. Essentially, the App Service plan
acts as a container for your web apps, and defines the resources and
features available to them. It supports different tiers such as Free,
Shared, Basic, Standard, Premium, and Isolated. Each of these tiers
offer different levels of performance, scalability, and features​.

The following command is used to create an app service plan:

$ az appservice plan create --name


--resource-group
[--app-service-environment]
[--hyper-v]
[--is-linux]
[--location]
[--no-wait]
[--number-of-workers]
[--per-site-scaling]
[--sku {B1, B2, B3, D1, F1, FREE, I1,
I1MV2, I1V2, I2, I2MV2, I2V2, I3, I3MV2, I3V2, I4MV2, I4V2,
I5MV2, I5V2, I6V2, P0V3, P1MV3, P1V2, P1V3, P2MV3, P2V2, P2V3,
P3MV3, P3V2, P3V3, P4MV3, P5MV3, S1, S2, S3, SHARED, WS1, WS2,
WS3}]
[--tags]
[--zone-redundant]

The parameters in the square brackets [ ] are optional, so if you create an


app service plan with only its name and resource group, it defaults to the
basic tier. When using optional parameters, make sure to remove the
brackets and just include the parameter and its value. For example, to
specify the region, you would use --location eastus without brackets.
To create an app service plan with the name SamplePlan, in the sampleRg
resource group, and with the P1V2 SKU, the command would look like
this: .

$ az appservice plan create --name SamplePlan


--resource-group SampleRg
--sku P1V2

For detailed information on all parameters and options, please refer to the
official Azure CLI documentation for az appservice plan create. To
understand and differentiate between the various SKUs available, you can
check the App Service pricing details which provides a comprehensive
comparison of features, costs, and use cases for each SKU.
Once the app service plan is created, you can now create the app service
that will use that plan. This happens with the az webapp command. The
code snippet below will create an app service (also known as a web app).

$ az webapp create --resource-group SampleRg


--plan SamplePlan
--name sampleApp
Please note that running this (and future resource creation commands) may
start to use your Azure credits or incur expenses. Make sure to monitor your
Azure usage and understand the pricing details for the resources you create.
Azure supports various deployment methods. Here, we’ll cover zip
deployment using the Azure CLI. This method involves zipping your build
artifacts and deploying them directly to Azure. To run a zip deployment, run
the command below:

$ az webapp deploy
--resource-group SampleRg
--name sampleApp
--src-path ./path/to/file.zip
--type zip
--async true

In the code snippet above, the az webapp deploy command deploys the
artifact to Azure Web Apps. For this to work, you will need to pass in the
name of the resource group where the app service is deployed, the name of
the app service, and the path to the built artifacts. In this command,
./path/to/file.zip refers to the path where your zip file is located on your
local machine. This zip file should include all the components of your web
application that you want to deploy. The path should be adjusted to point to
the actual location of your zip file. For example, if your zip file is named
myapp.zip and is located in your current directory, you would use --src-path
./myapp.zip. Make sure your zip file is structured correctly and
includes everything needed for your app to run properly.

Using Azure App Service in the Azure Portal


You can also carry out the same steps in the Azure Portal. First, check that
you are logged in. As shown in the previous section, you will need to create
a resource group first. To do this, search for Resource groups in the search
bar at the top and click on the result under Services (Figure 2-1). This will
launch a page with the list of already existing resource groups in the current
directory (Tenant).
Figure 2-1. List of Resource Groups in the current directory

Hit Create. This will launch the window where you will enter all the
information required to create the resource group. Follow the wizard and
specify all the necessary details. Once this step is completed, you can
review changes and if there are no errors, go ahead to create your resource
group. This process might take a few seconds (or minutes) depending on
your internet connection and other factors. Figure 2-2 shows what the Azure
Portal looks like when you attempt to create a resource group.
Once the resource group is successfully created, you will be able to see it in
the list of resource groups available to you and you will be able to add more
resources there. If you were successful creating your resource group, the
next step will be for you to create your App Service Plan (also known as
Hosting Plan).
Figure 2-2. Creating a Resource Group in Azure

To create your App Service Plan, search for App Service Plans in the search
bar at the top of the window and click on the result under Services. This
will launch a page with the list of already existing App Service Plans in the
current directory (Tenant). Hit Create to launch the window where you will
enter all the information required to create the App Service Plans. Follow
the wizard and specify all the necessary details. Once this step is completed,
you can review changes and if there are no errors, go ahead to create your
App Service Plan.
Once the App Service Plan is successfully created, you will be able to see it
in the list of App Service Plans available to you and you will be able to add
more resources there. If you were successful in creating your App Service
Plan, the next step will be for you to create your App Service (also known
as Web App).
To create your App Service, search for App Services in the search bar at the
top and click on the result under Services, this will launch a page with the
list of already existing App Services in the current directory (Tenant). Hit
Create to launch the window where you will enter all the information
required to create the App Service. Follow the wizard and specify all the
necessary details. Once this step is completed, you can review changes and
if there are no errors, go ahead to create your App Service.

Using Azure App Service in Azure PowerShell


Here, you’d see how to create an Azure App Service using PowerShell.
First, you need to authenticate to Azure. Figure 2-3 shows how to login
using Connect-AzAccount using PowerShell.
Figure 2-3. Login using Connect-AzAccount
Once you are logged into Azure on the terminal using the Connect-
AzAccount command, you can run the following PowerShell command to
create a resource group.

$ New-AzResourceGroup -Name SampleRg -Location EastUS

The code snippet above creates a resource group named SampleRg in the
eastus region. As mentioned earlier in the chapter, there are multiple regions
available, and in practice/production you’ll want to select the most
appropriate for your application. Now that you’ve created your resource
group, you can create the app service plan.

$ New-AzAppServicePlan
-Name SamplePlan
-ResourceGroupName SampleRg
-Tier Premium

Once the app service plan is created, you can now create the app service
that will use that plan. The following command will create an app service.

$ New-AzWebApp
-Name sampleApp
-ResourceGroupName SampleRg\
-AppServicePlan SamplePla

After running all the commands to create your infrastructure, you can verify
the creation of your app service by navigating to the Azure portal or using
the following command to get details about the app service:

$ Get-AzWebApp -ResourceGroupName SampleRg -Name sampleApp

These commands give you an alternative way to interact with Azure beyond
the portal and the Azure CLI. But it doesn’t stop here, there’s more you can
do in app services.
Configuring and Scaling App Services
When you created your web app infrastructure, you probably set it to have
one instance, which might be sufficient for a small app. However, in
production, you may need more instances to accommodate the scale that
your application demands. This is where configuring and scaling Azure App
Services becomes crucial. Proper configuration ensures your app is
optimized for performance, security, and cost-efficiency. Azure gives you
tools and features for scaling, including vertical scaling (scaling up) to
increase resource capacity and horizontal scaling (scaling out) to add more
instances to handle increased loads.

Configuring App Services


When you create infrastructure for the applications you want to put on the
cloud, you need to consider deployment. Your applications could be
deployed to different regions and may require unique settings, such as
database connection settings, app settings, or other parameters that vary
between environments (e.g., development, testing, and production). These
settings are often managed using environment variables—commonly stored
in a file known as an ENV file—rather than being hardcoded into the
application. . These configurations ensure that each deployment
environment operates with the correct parameters and things are not
hardcoded. They make your applications dynamic. Azure App Services
offer various tools to manage these settings efficiently, and this section will
cover that.
Configuring your Azure App Service involves setting up the environment to
meet the specific needs of your application. This includes defining
application settings, configuring connection strings, and setting up
deployment slots.

Application Settings
Application Settings (also known as environment variables) include
configuration keys and values that your application needs to run. They can
be set directly in the Azure portal or through configuration files. For
instance, you might set API keys, feature flags, or any other environment-
specific settings.
To add an app setting using Azure CLI, use the following command:

$ az webapp config appsettings set


--resource-group <ResourceGroupName>
--name <AppName>
--settings <SettingName>=<SettingValue>

For example:

$ az webapp config appsettings set


--resource-group SampleRg
--name sampleApp
--settings Environment=Production

This command sets an application setting named Environment with the


value Production for the web app sampleApp in the resource group
SampleRg.
You can also add an app setting using Azure PowerShell using the
following command:

$ settings = @{"MySetting" = "MyValue"}


Set-AzWebApp
-ResourceGroupName <ResourceGroupName>
-Name <AppName>
-AppSettings $settings

For example:

$ settings = @{"Environment" = "Production"}


Set-AzWebApp
-ResourceGroupName <ResourceGroupName>
-Name <AppName>
-AppSettings $settings
There are other ways to include app settings in your application. You can
use infrastructure as code to add the different configurations or add them
directly in the Azure portal.
Figure 2-4. Environment Variable in Azure

Deployment Slots
Deployment Slots provide isolated environments for testing new versions of
your application. For example, you can have a staging slot where you
deploy and test new features before swapping them into production to
ensure that your main application remains unaffected by any potential
issues during deployment. I’ll cover deployment slots in the blue-green
deployments section of this chapter.

Connection Strings
Connection Strings are secure values used to connect your app to databases
or other services. To add a connection string using Azure CLI, use the
following command:

$ az webapp config connection-string set


--resource-group <ResourceGroupName>
--name <AppName>
--settings MyConnectionString="Server=myServer;Database=myDB;User
Id=myUser;Password=myPassword;"
--connection-string-type SQLAzure

Note that the only accepted values for connection string type are ApiHub,
Custom, DocDb, EventHub, MySql, NotificationHub, PostgreSQL,
RedisCache, SQLAzure, SQLServer, ServiceBus. Meaning that if you have
an external service or API key that you’d like to add as a connection string,
you’d need to do it as an application setting.
When defining connecting strings using PowerShell, you can use the
following command:

$ $connectionStrings = @{"MyConnectionString" =
@{Value="Server=myServer;Database=myDB;User
Id=myUser;Password=myPassword;"; Type="SQLAzure"}}
Set-AzWebApp
-ResourceGroupName <ResourceGroupName>
-Name <AppName>
-ConnectionStrings $connectionStrings
These commands give you alternative ways to add settings to your web app
infrastructure as you build dynamic applications.

Scaling Your App Services Vertically


Vertical scaling involves upgrading the service plan to a higher tier with
more resources, such as CPU, memory, and additional features like custom
domains and SSL support. This type of scaling is beneficial for applications
that need more power per instance rather than adding more instances (which
is known as horizontal scaling and will be covered next). For instance,
moving from a Standard to a Premium plan can provide enhanced
performance and features that are crucial for high-demand applications.
To scale up your App Service through the Azure portal, navigate to your
App Service and select Scale up (App Service plan) from the
left menu. Choose the desired pricing tier and click Apply to upgrade your
service plan (Figure 2-5).
Figure 2-5. Scaling up an App Service Plan in the Azure Portal

To scale up your App Service using the Azure CLI, you can update the App
Service Plan resource using the following command:

$ az appservice plan update


--name <AppServicePlanName>
--resource-group <ResourceGroupName>
--sku <SkuToScaleTo>

The value of SkuToScaleTo could be P1v3 or any other tier that fits your
needs.
To scale up your App Service using Azure PowerShell, you can update the
App Service Plan resource using the following command:

$ Set-AzAppServicePlan
-ResourceGroupName <ResourceGroupName>
-Name <AppServicePlanName>
-Tier <SkuToScaleTo>
-WorkerSize Large

The value of SkuToScaleTo could be PremiumV3 or any other tier that fits
your needs.

Scaling Your App Services Horizontally


Horizontal scaling, or scaling out, adds more instances of your app to
distribute the load. Azure App Services support autoscaling, which
automatically adjusts the number of instances based on predefined rules and
real-time metrics like CPU usage, memory usage, or HTTP queue length.
This ensures that your application can handle different traffic patterns
efficiently without manual intervention.

Creating the autoscale Settings


The Azure CLI command below creates the autoscale settings to scale
between 2 and 9 instances, leaving 4 as the default.
$ az monitor autoscale create
--resource-group {resource-group-name}
--resource {resource-id}
--min-count 2
--max-count 9
--count 4

This command is used to establish autoscale settings for an Azure


resource.
This parameter denotes the resource group where these settings will be
applied, which you replace with your actual resource group name.
Identifies the specific resource, such as an App Service, that the
autoscale setting will govern, using its unique resource ID.
Ensures that there will always be a minimum of two instances running,
providing a baseline capacity to handle basic traffic.
Sets an upper limit of nine instances, preventing excessive scaling that
could lead to high operational costs.
This parameter sets the default number of instances to start with,
meaning that under typical conditions, the application will operate with
four instances.

Creating the scale-out rule


The Azure CLI command below creates a scale-out rule.

$ az monitor autoscale rule create


--resource-group {resource-group-name}
--autoscale-name {resource-name}
--scale out 1
--condition "Percentage CPU > 75 avg 5m"

This parameter indicates the name of the autoscale setting that will use
this rule.
This parameter defines the action to be taken when the condition is met,
which in this case is to add one instance.
This parameter specifies the condition that triggers this scaling action.
This rule states that if the average CPU usage exceeds 75% over a five-
minute period, an additional instance will be added to handle the
increased load.

In this example, the condition Percentage CPU > 75 avg 5m


represents a scaling rule based on CPU usage. Azure’s autoscaling feature
allows you to define such rules using a flexible syntax, which means you
can create scaling conditions tailored to your specific needs. These rules
govern when and how scaling events occur by monitoring various metrics,
such as CPU load, memory, or other application-specific performance
indicators.
There are two main types of rules you can configure:
Metric-based rules
These trigger scaling actions based on performance metrics. For
instance, if a certain resource, like CPU or memory, exceeds a set
threshold, the system can automatically scale out to handle increased
demand.

Time-based rules
These allow you to scale your resources based on a predefined schedule.
For example, you could set a rule to scale out during peak hours, like
weekday afternoons, when traffic to your app is typically higher.

You can also define multiple scaling rules in an autoscale profile to address
different conditions. Azure supports combining up to 10 rules, and when
scaling out, if any of the conditions in your rules are met, the system will
automatically add more instances. However, for scaling in (reducing
resources), all conditions across your rules must be met, making scaling in
more controlled. This flexibility allows you to ensure your application
responds dynamically to varying workloads, improving performance while
controlling costs.

Creating the scale-in rule


The Azure CLI command below creates a scale-in rule.

$ az monitor autoscale rule create


--resource-group {resource-group-name}
--autoscale-name {resource-name}
--scale in 1
--condition "Percentage CPU < 25 avg 5m"

This command follows the same structure as the scale-out rule, starting with
the creation directive and specifying the resource group with --
resource-group {resource-group-name}. The --
autoscale-name {resource-name} parameter again indicates
which autoscale setting will use this rule. The --scale in 1 parameter
defines the action to be taken, which in this case is to remove one instance.
The condition for this action, specified by --condition
"Percentage CPU < 25 avg 5m", means that if the average CPU
usage drops below 25% over a five-minute period, one instance will be
removed to reduce resource usage and cost.

Autoscaling in the Azure Portal


In the Azure portal, you can also specify rules based or automatic scaling.
Click on the Scale out (App Service Plan) tab on the side bar
and you will see the option to either select automatic scaling or rules based
scaling (Figure 2-6). If you choose automatic scaling, you have two
required parameters to set:
Maximum burst
Number of instances your app service plan can scale out under load. Its
value should be greater than or equal to current instances for the plan.

Always ready instances


Number of instances that are always ready for the web app to use by
default

You can also choose to enforce a scale out limit and have that limit
specified so that your web app will never scale beyond that specific number
of instances.
Figure 2-6. Automatic Scaling (App Service Plan)

For rules based scaling Figure 2-7), you will need to configure the scaling
rules. Bear in mind that if you have automatic scaling enabled, rules based
scaling will be ignored. Once you click “configure”, it will take you to a
different page to complete the process. Select Custom autoscale to
define a new profile. Within this profile, you can set the minimum,
maximum, and default instance counts to control the range of scaling. Add
scaling rules to specify the conditions under which scaling occurs. For
example, you can create rules based on metrics such as CPU utilization or
memory usage. Define whether the action should increase or decrease
instances and set the threshold values that will trigger these actions.
Additionally, configure the cooldown period, which is the time Azure waits
before applying additional scaling actions after a previous action.
Figure 2-7. Rules based auto scaling

Blue-Green Deployment with Slots


Now that you know how to create an app service, deploy code to it, add app
settings to make it dynamic, and configure autoscaling, let’s talk about
deploying apps and reducing negative customer impact. There are several
strategies for achieving smooth and reliable deployments, and one of the
most effective is blue-green deployments.
Blue-Green Deployment is a technique that reduces downtime and risk by
running two identical production environments, known as Blue and Green.
At any time, only one of these environments is live, serving all production
traffic. For example, Blue is the current live environment while Green is the
environment where the new version of the application is deployed. After
thorough testing in the Green environment, traffic is switched from Blue to
Green, making Green the live environment. If any issues are detected, you
can quickly roll back to the Blue environment.
In Azure App Service, blue-green deployments can be implemented using
deployment slots. Deployment slots are live apps with their own hostnames.
You can deploy your application to a non-production slot, test it, and then
swap it with the production slot to complete the deployment with minimal
downtime.
Here’s how you can set up blue-green deployments using deployment slots
with both Azure CLI and Azure PowerShell.
First, create a new deployment slot named staging for an App Service
named SampleApp in the resource group SampleRg. I’ve provided
examples below for both Azure CLI and Azure PowerShell.
Azure CLI

$ az webapp deployment slot create


--name sampleApp
--resource-group SampleRg
--slot staging
Azure Powershell

$ New-AzWebAppSlot
-ResourceGroupName "SampleRg"
-Name "sampleApp"
-Slot "staging"

After successfully creating your staging slot, deploy your new application
to the staging slot.
Azure CLI

$ az webapp deploy
--resource-group SampleRg
--name sampleApp
--src-path "./path/to/file.zip"
--slot "staging"
--type zip
--async true

Azure Powershell

$ Publish-AzWebApp
-ResourceGroupName SampleRg
-Name sampleApp
-Slot staging
-ArchivePath "./path/to/file.zip"

Once your app has been deployed to the slot, you may run all your tests
there until they pass or you get a satisfactory result. Once the tests pass and
it’s validated the code works and the slot is healthy, you can swap the
staging slot with the production slot (the main app service).
Azure CLI

$ az webapp deployment slot swap


--resource-group SampleRg
--name sampleApp
--slot staging

Azure Powershell
$ Swap-AzWebAppSlot
-ResourceGroupName "SampleRg"
-Name "sampleApp"
-SourceSlotName "staging"
-DestinationSlotName "production"

If any issues arise with the new version as you test, you can quickly swap
the slots back.
Beyond using Azure CLI and Powershell, you can also create and manage
slots directly from the dashboard from the Deployment slots tab on the
sidebar as shown in Figure 2-8.
Figure 2-8. Dashboard showing deployment slots

Automating App Service Deployments


In a real project, you will not run CLI commands from your local computer
to deploy to production. Changes will be automated, and things will flow
through a CI/CD pipeline to ensure consistency, reliability, and efficiency.
Automating deployments for Azure App Service can be achieved using
different CI/CD tools, but this section will introduce you to how you can do
it using Azure DevOps and GitHub Actions.

Using Azure DevOps


When you create a pipeline in Azure DevOps, you define your build and
release process using a YAML file. Here’s an example pipeline definition:

trigger:
branches:
include:
- main

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.x'
installationPath: $(Agent.ToolsDirectory)/dotnet

- script: dotnet build --configuration Release


displayName: 'Build project'

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(System.DefaultWorkingDirectory)
includeRootFolder: false
archiveType: 'zip'
archiveFile:
$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: drop
publishLocation: 'Container'

- task: AzureWebApp@1
inputs:
azureSubscription: 'your-service-connection'
appName: 'MyAppService'
package:
$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip

This YAML file defines a pipeline that triggers on changes to the main
branch. It sets up the .NET SDK, builds the project, creates a zip archive of
the build artifacts, and deploys the application to an Azure App Service. The
AzureWebApp task uses a service connection to authenticate with Azure
and deploy the package to the specified App Service.
In Azure, a service connection allows you to securely connect and
authenticate with Azure resources from external tools or services, such as
Azure DevOps, GitHub Actions, or other CI/CD pipelines. It serves as a
bridge, enabling these external systems to perform various operations on
your Azure resources without requiring direct user credentials each time an
action is performed.
To set up a service connection using the Azure CLI, you typically create a
service principal and assign it a role with the required permissions. For
example, to create a service principal with Contributor permissions for a
specific resource group, you would use the following commands:

# Create a service principal


$ az ad sp create-for-rbac
--name http://my-service-connection
--role contributor
--scopes /subscriptions/{subscription-id}/resourceGroups/{rg-
name}
The az ad sp create-for-rbac command creates a new service principal and
assigns it the Contributor role for the specified resource group. The scopes
parameter defines the scope of permissions.

Using GitHub Actions


When you create a workflow in GitHub Actions, you define the steps for
your CI/CD process directly in your GitHub repository using a YAML file.
Here’s an example workflow:

name: Build and Deploy to Azure Web App

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up .NET


uses: actions/setup-dotnet@v2
with:
dotnet-version: '5.x'

- name: Build project


run: dotnet build --configuration Release

- name: Publish artifact


run: dotnet publish -c Release -o ./publish

- name: Deploy to Azure Web App


uses: azure/webapps-deploy@v2
with:
app-name: 'MyAppService'
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE
}}
package: './publish'
This workflow triggers pushes to the main branch. It checks out the code,
sets up the .NET environment, builds and publishes the project, and then
deploys the application to an Azure Web App using the azure/webapps-
deploy action. The deployment uses a publish profile stored as a secret in
the GitHub repository for authentication.

Cleaning Up: Deleting App Service


Resources and Resource Groups
Once you’ve finished working with the resources and resource groups
created in this chapter, it’s essential to clean them up to avoid unnecessary
charges. In Azure, resources left running will continue to incur costs, so it’s
a good practice to delete any resources and resource groups you’re no
longer using. Below are the steps to delete both individual resources and
entire resource groups using Azure CLI and PowerShell.
To delete specific resources, such as an App Service, you can use the
following command:

$ az webapp delete
--name <app-name>
--resource-group <resource-group-name>

This command will remove the specified web app from your resource
group. However, if you’ve created other resources like databases or storage
accounts, you’ll need to delete them individually or delete the entire
resource group, as shown below. To delete the entire resource group (and all
resources within it), use this command:

$ az group delete
--name <resource-group-name>
--yes
--no-wait

This will permanently delete the resource group and all associated resources
in one step. The --yes flag skips the confirmation prompt, and --no-
wait allows the deletion to proceed asynchronously.
Similarly, if you’re using PowerShell, you can delete an individual App
Service with the following command:

Remove-AzWebApp
-Name <app-name>
-ResourceGroupName <resource-group-name>

To delete the entire resource group, including all its resources, use:

Remove-AzResourceGroup
-Name <resource-group-name>
-Force

The -Force parameter skips the confirmation, ensuring the command runs
immediately.
Cleanup is important, because leaving unused resources in your Azure
account can lead to unexpected billing, even if those resources are not
actively being used. Azure charges for various services based on
consumption, so keeping your account clean by regularly deleting unused
resources and resource groups helps avoid unnecessary costs. Always
review your resources after completing your work to ensure you’re not
incurring charges for resources you no longer need. By following these
steps, you can easily manage your Azure resources and ensure that your
account stays organized and cost-effective.

Summary
This chapter covered Azure App Service. Here, you learned about the
fundamentals of Azure App Service, including how to configure and scale
App Services to ensure optimal performance and reliability. You were also
introduced to blue-green deployments using deployment slots,
demonstrating how to minimize downtime and risk during application
updates by using two identical production environments. Additionally, the
chapter explored the automation of App Service deployments using Azure
DevOps and GitHub Actions, showing how to implement continuous
integration and continuous deployment (CI/CD) pipelines. In the next
chapter, you will learn about Serverless Computing using Azure Functions.

OceanofPDF.com
About the Author
Adora Nwodo is a multi-award winning experienced Senior Software
Engineer & Engineering Manager. She currently works at the intersection of
Cloud Engineering, and Developer Platforms and is passionate about the
Cloud and Emerging Technologies. Prior to her current role, she was a
Software Engineer at Microsoft, building Mixed Reality on the Azure Cloud
for four years. She is also the Vice President of the Nigerian chapter for
VRAR Association. Her work there involves creating more awareness for
Virtual and Augmented Reality Technologies.

OceanofPDF.com

You might also like