Professional Documents
Culture Documents
Developing Solutions
for Microsof t
Azure Certification
Companion
Hands-on Preparation
and Practice for Exam AZ-204
›
Brian L. Gorman
Certification Study Companion Series
The Apress Certification Study Companion Series offers guidance and
hands-on practice to support technical and business professionals
who are studying for an exam in the pursuit of an industry certification.
Professionals worldwide seek to achieve certifications in order to advance
in a career role, reinforce knowledge in a specific discipline, or to apply for
or change jobs. This series focuses on the most widely taken certification
exams in a given field. It is designed to be user friendly, tracking to topics
as they appear in a given exam. Authors for this series are experts and
instructors who not only possess a deep understanding of the content, but
also have experience teaching the key concepts that support readers in the
practical application of the skills learned in their day-to-day roles.
Brian L. Gorman
Developing Solutions for Microsoft Azure Certification Companion:
Hands-on Preparation and Practice for Exam AZ-204
Brian L. Gorman
MajorGuidanceSolutions
Jesup, IA, USA
Acknowledgments�������������������������������������������������������������������������� xxvii
Introduction������������������������������������������������������������������������������������� xxix
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
xii
Table of Contents
Monitoring���������������������������������������������������������������������������������������������������246
Deployment Options������������������������������������������������������������������������������������247
Slots������������������������������������������������������������������������������������������������������������249
Creating the Application Code���������������������������������������������������������������������������250
Create the Function App������������������������������������������������������������������������������250
Function Apps and Functions����������������������������������������������������������������������251
Triggers��������������������������������������������������������������������������������������������������������252
The Default HTTP Trigger Function��������������������������������������������������������������257
Deploy the Function App������������������������������������������������������������������������������260
Test the Function App����������������������������������������������������������������������������������263
Bindings�������������������������������������������������������������������������������������������������������266
The function.json File����������������������������������������������������������������������������������276
WebJobs vs. Functions�������������������������������������������������������������������������������������282
Durable Functions���������������������������������������������������������������������������������������������282
Task Hubs����������������������������������������������������������������������������������������������������282
Storage Resources��������������������������������������������������������������������������������������285
Durable Orchestrations��������������������������������������������������������������������������������286
Durable Function Types�������������������������������������������������������������������������������286
Patterns�������������������������������������������������������������������������������������������������������288
Review Your Learning���������������������������������������������������������������������������������������298
Complete the AZ-204: Implement Azure Functions�������������������������������������������299
Chapter Summary���������������������������������������������������������������������������������������������299
xiii
Table of Contents
xiv
Table of Contents
Authorization Flows������������������������������������������������������������������������������������������332
Authorization Code��������������������������������������������������������������������������������������332
Client Credentials����������������������������������������������������������������������������������������332
Device Code�������������������������������������������������������������������������������������������������333
Implicit���������������������������������������������������������������������������������������������������������333
Integrated Windows�������������������������������������������������������������������������������������334
Interactive and Non-Interactive�������������������������������������������������������������������334
On-Behalf-Of�����������������������������������������������������������������������������������������������334
Username/Password�����������������������������������������������������������������������������������335
Shared Access Signatures��������������������������������������������������������������������������������335
Identity and Authorization in Applications���������������������������������������������������������336
Create the App Registration������������������������������������������������������������������������������337
Working with the Microsoft Authentication Library (MSAL)�������������������������339
Working with the Microsoft Graph SDK�������������������������������������������������������344
Review Your Learning���������������������������������������������������������������������������������������347
Complete the AZ-204: Implement User Authentication and Authorization��������348
Chapter Summary���������������������������������������������������������������������������������������������349
xv
Table of Contents
Data Encryption�������������������������������������������������������������������������������������������364
Keys, Secrets, and Certificates��������������������������������������������������������������������364
Access Policies��������������������������������������������������������������������������������������������373
Connect to Azure Key Vault From Azure App Service����������������������������������������377
Configure the Application to Read From Key Vault��������������������������������������378
Azure Application Configuration������������������������������������������������������������������������383
Centralized Configuration����������������������������������������������������������������������������384
Azure Managed Service�������������������������������������������������������������������������������384
Creating a New Azure App Configuration�����������������������������������������������������384
Data Encryption�������������������������������������������������������������������������������������������386
Create a System-Managed Identity�������������������������������������������������������������387
Keys and Values������������������������������������������������������������������������������������������389
Feature Flag Management��������������������������������������������������������������������������392
Connecting an App Service Web Application to an Azure Application
Configuration����������������������������������������������������������������������������������������������������395
Configure the Security Settings�������������������������������������������������������������������396
Review the Application��������������������������������������������������������������������������������402
Connect to Azure Key Vault Through Azure Application Configuration��������������404
Make the Code Change�������������������������������������������������������������������������������405
Update Azure App Configuration������������������������������������������������������������������406
Review Your Learning���������������������������������������������������������������������������������������408
Complete the AZ-204: Implement Secure Cloud Solutions�������������������������������409
Chapter Summary���������������������������������������������������������������������������������������������410
xvi
Table of Contents
xvii
Table of Contents
Redis Commands�����������������������������������������������������������������������������������������443
Working with Redis Cache via .NET�������������������������������������������������������������444
Cache-Aside in an ASP.Net MVC Application�����������������������������������������������450
Review Your Learning���������������������������������������������������������������������������������������456
Complete the AZ-204: Integrate Caching and Content Delivery Within
Solutions�����������������������������������������������������������������������������������������������������������457
Chapter Summary���������������������������������������������������������������������������������������������457
xviii
Table of Contents
xix
Table of Contents
xx
Table of Contents
xxi
Table of Contents
Index�������������������������������������������������������������������������������������������������721
xxii
About the Author
Brian L. Gorman is a Microsoft Azure MVP,
developer, computer science instructor,
and trainer. He has been working in .NET
technologies as long as they have existed. He
was originally MCSD certified in .NET 1 and
recertified with MCSA: Web Apps and MCSD:
App Builder certifications in 2019. From 2019
on, Brian has earned 11 Azure certifications,
including the Azure, Security, and Data Fundamentals certifications, the
Azure Administrator, Database Administrator, Security Engineer, and
Developer Associate certifications, the Azure Solutions Architect and DevOps
Expert certifications, and the IoT and Cosmos DB Specialty certifications.
Additionally, Brian became an MCT as of April 2019 and is focusing
on developing and training developers with full-stack web solutions
with .NET Core and Azure. Most recently, Brian has found purpose as an
instructor for the Microsoft Software and Systems Academy (MSSA) in the
cloud application development program.
In addition to working with .NET technologies, Brian was also an
adjunct faculty member in the computer science department at Franklin
University for over ten years, where his courses included data structures,
algorithms, design patterns, and full-stack solutions in the computer
science capstone practicum course. Brian has created many online
technical training courses that can be found online on various platforms.
Brian is also the author of the Apress books Practical Entity Framework
and Practical Entity Framework Core 6.
xxiii
About the Technical Reviewer
Gerald Versluis is a Senior Software Engineer
at Microsoft, working on .NET MAUI. Since
2009, Gerald has been working on a variety of
projects, ranging from frontend to backend
and anything in between that involves
Azure, ASP.NET, and all kinds of other .NET
technologies. At some point, he fell in love
with cross-platform and mobile development
with Xamarin (now .NET MAUI). Since then
he has become an active community member, writing, tweeting, and
presenting about all things tech. Gerald can be found on Twitter
@jfversluis, blogging at https://blog.verslu.is or on his YouTube
channel at https://youtube.com/@jfversluis.
xxv
Acknowledgments
I would not have been able to write this book if it were not for a number of
people who have both influenced and helped me throughout my career, as
well as the multitudes of grace and support that I have received from my
family throughout this process.
I’d like to begin by thanking Gerald Versluis for his hard work reviewing
this material. It’s been great to have a chance to work with him through this
project and I’m very appreciative of the excellent feedback and suggestions
he’s provided along the way. This book would not be what it is without the
hours of work he put into reviewing chapters, calling out questions, and
making sure the content was accurate.
I’d like to next thank a few of the people who have believed in me
as I’ve been working on building out Major Guidance Solutions and
the unique Azure Training programs that I offer. Specifically, I’d like to
thank Mike Cole, Javier Lozano, Alec Harrison, and Brian McKeiver, who
either attended or sent their team through my Azure certification training
program. I’d also like to thank John Unsen and his colleagues at VGM for
giving me the chance to take them through this material as well as material
on the Azure administration side in my Azure Expert Training programs.
I’d also like to thank the many friends and acquaintances I’ve made at
various tech conferences in the past few years. I’ve learned so much from
all of you, and I had a blast making music in the hotel Lobby in Lincoln.
I’m looking forward to more of those fun times ahead!
Thank you to Apress and the team who have believed in me and have
helped to make this book possible. Thanks to Jonathan Gennick and Jill
Balzano, as well as to Nirmal Salvaraj and Shaul Elson for running the
project, editing, and overseeing the entire schedule and process.
xxvii
Acknowledgments
I would be remiss if I didn’t also thank Dustin Behn, the leader of the
Inspired Nation, and his life coaching and his Emergence program. Thank
you for coaching me these past few years and for helping me get out of my
own way to do things like this book. I also want to say thanks to Dr. Ashley
Lang of GoalDigger for helping me to identify my strengths and coaching
me past the writer’s block I was having early in the process of starting
this book. Finally, I want to thank the staff and owners of Panther Lanes
for providing some awesome pictures of a bowling alley to help illustrate
partitioning of data in Cosmos DB (used in Chapter 2).
xxviii
Introduction
The Azure Developer Associate Certification (AZ-204 at the time of this
writing) is the premier Azure certification for developers. Adding the Azure
Developer Associate Certification to your resume can be one way to set
yourself apart from other developers applying for positions, or it can help
you get noticed or qualify for promotions or raises. As such, it’s definitely
a great certification to earn and one that you most likely are interested in
achieving if you are considering this book.
The main goal of this book is to help you prepare for that certification.
Unlike most prep books, this book does not present practice questions.
Instead, what you will find in the pages of this book are practical examples
and discussions related to the important topics that could show up on your
certification exam.
If you are mainly concerned about practice questions, you should
invest your money in a MeasureUp (www.measureup.com) practice test,
which is officially sponsored by Microsoft. Additionally, Microsoft has
released some official practice assessments which can be found here:
https://learn.microsoft.com/en-us/certifications/practice-
assessments-for-microsoft-certifications. You can find the AZ-204 in
the list to take the practice assessment.
As the book is written to aid you in developing solutions for Azure,
the idea is that you can complete any chapter in any order, based on your
needs and desires for studying the solution. The one exception to this is
that a number of chapters rely on a provisioned app service with a default
application (found in the source materials for this book). With that, while you
can still jump around, you will need to first deploy the application and any
features you turn on would need to also be provisioned (for example, you
can’t read from the app config and Key Vault if you haven’t deployed them).
xxix
Introduction
xxx
Introduction
xxxi
Introduction
xxxii
Introduction
I added this last one because if you are interested in becoming an MCT,
this certification will be half of the qualification you need. You also need to
get a valid technical training certification and then apply to the program,
but this exam is one that qualifies you for the program.
Shameless Self-Promotion
I would also like to point you to a video that I made last year regarding the
benefits of getting certified. In that video, I discuss the exam experience
and talk about a number of additional resources you can leverage
in your general study. You can find the video at https://training.
majorguidancesolutions.com/courses/blog-posts-and-talks/
contents/622a5be022172.
xxxiii
Introduction
xxxiv
Introduction
You are also asked to check a couple of boxes to opt in for some
marketing and offers. You must check the box that reads “I have read and
agree to the terms …”.
xxxv
Introduction
When you choose the test center option, you get the benefit of having
a live proctor. This means you can rely on the center for providing a secure
location to take the test and you will have a bit more flexibility (you can
raise your hand for a restroom break, for example). Your stuff will be
locked in a cabinet somewhere so you can’t get to it but you know it’s safe.
At a test center, you can use scratch-paper, and you don’t have to worry
about any problems connecting to the exam and/or getting rescheduled if
something is wrong with the Internet.
xxxvi
Introduction
Some of the drawbacks of taking the exam from home are as follows:
As you can see, it sounds pretty scary to take an exam from home with
all the restrictions. That being said, it’s actually a great experience and how
I prefer to take exams at this point. I can schedule them at 10 PM when
everyone is in bed, and I take them from a coworking office I rent for the
three hours around the exam. Usually, there are no issues with anyone else
even being in the building.
xxxvii
Introduction
xxxviii
Introduction
Make sure to read through these terms if you’ve never taken an exam
before. There are a number of important pieces of information on these
screens.
Included on these pages is all the pertinent information about the
reschedule policy, how to check in, and all the acceptable forms of ID you
can use.
Note that a number of the paragraphs have a checkbox next to them.
You must manually check each one to prove you read the page.
xxxix
Introduction
xl
Introduction
When it comes to the exam, here are a few hints I can give you on how I
work through any exam:
xli
Introduction
xlii
Introduction
xliii
Introduction
Renewing is easy and free, so don’t stress. You can take the renewal
assessment over and over again, it’s open book, and you don’t pay
anything to take it, so just make sure you do this so your certification
doesn’t expire.
Also note that you’ll get an email 180 and 90 days out that reminds
you to renew your certification. You can see what certifications need to be
renewed in your Microsoft Learn Profile at any time.
xliv
Introduction
On the report, look for the “three areas you can improve.” The report
will show you your weaknesses in regard to the concepts on the exam. Use
that to focus your efforts for your next attempt. You still want to review
more than just these three things, but these are the “needle movers” that
might take you over the hump to pass.
Review the bar chart and identify any other areas that hurt you.
You didn’t get to write the questions down, but surely there was that one
question you can remember that was about something you never expected.
What was that again? Go read about it and make sure you won’t ever be
stumped on a question like that again. (Even if it that question doesn’t show
up in your retake, you learned something new and that’s awesome.)
xlv
Introduction
If you passed the exam, let’s celebrate. If you didn’t, I want to help you
get there, so please reach out so I can work with you to find ways to help
you get over the final hump.
Also, one last thing. I struggle with social interactions, and I go to a lot
of conferences and speak. If you happen to be at one and you would like to
chat, please don’t hesitate to talk with me if you see me in person. I would
be honored to hear your story and find out more about how this book or
anything else in your journey has helped you to move toward your goals.
Let’s do this!
xlvi
PART I