20532D ENU TrainerHandbook
20532D ENU TrainerHandbook
20532D
Developing Microsoft Azure Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
ii Developing Microsoft Azure Solutions
Information in this document, including URL and other Internet Web site references, is subject to change
without notice. Unless otherwise noted, the example companies, organizations, products, domain names,
e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with
any real company, organization, product, domain name, e-mail address, logo, person, place or event is
intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the
user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in
or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,
photocopying, recording, or otherwise), or for any purpose, without the express written permission of
Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property
rights covering subject matter in this document. Except as expressly provided in any written license
agreement from Microsoft, the furnishing of this document does not give you any license to these
patents, trademarks, copyrights, or other intellectual property.
The names of manufacturers, products, or URLs are provided for informational purposes only and
Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding
these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a
manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links
may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not
responsible for the contents of any linked site or any link contained in a linked site, or any changes or
updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission
received from any linked site. Microsoft is providing these links to you only as a convenience, and the
inclusion of any link does not imply endorsement of Microsoft of the site or the products contained
therein.
© 2018 Microsoft Corporation. All rights reserved.
Microsoft and the trademarks listed at http://www.microsoft.com/trademarks are trademarks of the Microsoft
group of companies. All other trademarks are property of their respective owners.
Released: 04/2018
MCT USE ONLY. STUDENT USE PROHIBITED
MICROSOFT LICENSE TERMS
MICROSOFT INSTRUCTOR-LED COURSEWARE
These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its
affiliates) and you. Please read them. They apply to your use of the content accompanying this agreement which
includes the media on which you received it, if any. These license terms also apply to Trainer Content and any
updates and supplements for the Licensed Content unless other terms accompany those items. If so, those terms
apply.
BY ACCESSING, DOWNLOADING OR USING THE LICENSED CONTENT, YOU ACCEPT THESE TERMS.
IF YOU DO NOT ACCEPT THEM, DO NOT ACCESS, DOWNLOAD OR USE THE LICENSED CONTENT.
If you comply with these license terms, you have the rights below for each license you acquire.
1. DEFINITIONS.
a. “Authorized Learning Center” means a Microsoft IT Academy Program Member, Microsoft Learning
Competency Member, or such other entity as Microsoft may designate from time to time.
b. “Authorized Training Session” means the instructor-led training class using Microsoft Instructor-Led
Courseware conducted by a Trainer at or through an Authorized Learning Center.
c. “Classroom Device” means one (1) dedicated, secure computer that an Authorized Learning Center owns
or controls that is located at an Authorized Learning Center’s training facilities that meets or exceeds the
hardware level specified for the particular Microsoft Instructor-Led Courseware.
d. “End User” means an individual who is (i) duly enrolled in and attending an Authorized Training Session
or Private Training Session, (ii) an employee of a MPN Member, or (iii) a Microsoft full-time employee.
e. “Licensed Content” means the content accompanying this agreement which may include the Microsoft
Instructor-Led Courseware or Trainer Content.
f. “Microsoft Certified Trainer” or “MCT” means an individual who is (i) engaged to teach a training session
to End Users on behalf of an Authorized Learning Center or MPN Member, and (ii) currently certified as a
Microsoft Certified Trainer under the Microsoft Certification Program.
g. “Microsoft Instructor-Led Courseware” means the Microsoft-branded instructor-led training course that
educates IT professionals and developers on Microsoft technologies. A Microsoft Instructor-Led
Courseware title may be branded as MOC, Microsoft Dynamics or Microsoft Business Group courseware.
h. “Microsoft IT Academy Program Member” means an active member of the Microsoft IT Academy
Program.
i. “Microsoft Learning Competency Member” means an active member of the Microsoft Partner Network
program in good standing that currently holds the Learning Competency status.
j. “MOC” means the “Official Microsoft Learning Product” instructor-led courseware known as Microsoft
Official Course that educates IT professionals and developers on Microsoft technologies.
k. “MPN Member” means an active Microsoft Partner Network program member in good standing.
MCT USE ONLY. STUDENT USE PROHIBITED
l. “Personal Device” means one (1) personal computer, device, workstation or other digital electronic device
that you personally own or control that meets or exceeds the hardware level specified for the particular
Microsoft Instructor-Led Courseware.
m. “Private Training Session” means the instructor-led training classes provided by MPN Members for
corporate customers to teach a predefined learning objective using Microsoft Instructor-Led Courseware.
These classes are not advertised or promoted to the general public and class attendance is restricted to
individuals employed by or contracted by the corporate customer.
n. “Trainer” means (i) an academically accredited educator engaged by a Microsoft IT Academy Program
Member to teach an Authorized Training Session, and/or (ii) a MCT.
o. “Trainer Content” means the trainer version of the Microsoft Instructor-Led Courseware and additional
supplemental content designated solely for Trainers’ use to teach a training session using the Microsoft
Instructor-Led Courseware. Trainer Content may include Microsoft PowerPoint presentations, trainer
preparation guide, train the trainer materials, Microsoft One Note packs, classroom setup guide and Pre-
release course feedback form. To clarify, Trainer Content does not include any software, virtual hard
disks or virtual machines.
2. USE RIGHTS. The Licensed Content is licensed not sold. The Licensed Content is licensed on a one copy
per user basis, such that you must acquire a license for each individual that accesses or uses the Licensed
Content.
2.1 Below are five separate sets of use rights. Only one set of rights apply to you.
2.2 Separation of Components. The Licensed Content is licensed as a single unit and you may not
separate their components and install them on different devices.
2.3 Redistribution of Licensed Content. Except as expressly provided in the use rights above, you may
not distribute any Licensed Content or any portion thereof (including any permitted modifications) to any
third parties without the express written permission of Microsoft.
2.4 Third Party Notices. The Licensed Content may include third party code tent that Microsoft, not the
third party, licenses to you under this agreement. Notices, if any, for the third party code ntent are included
for your information only.
2.5 Additional Terms. Some Licensed Content may contain components with additional terms,
conditions, and licenses regarding its use. Any non-conflicting terms in those conditions and licenses also
apply to your use of that respective component and supplements the terms described in this agreement.
a. Pre-Release Licensed Content. This Licensed Content subject matter is on the Pre-release version of
the Microsoft technology. The technology may not work the way a final version of the technology will
and we may change the technology for the final version. We also may not release a final version.
Licensed Content based on the final version of the technology may not contain the same information as
the Licensed Content based on the Pre-release version. Microsoft is under no obligation to provide you
with any further content, including any Licensed Content based on the final version of the technology.
b. Feedback. If you agree to give feedback about the Licensed Content to Microsoft, either directly or
through its third party designee, you give to Microsoft without charge, the right to use, share and
commercialize your feedback in any way and for any purpose. You also give to third parties, without
charge, any patent rights needed for their products, technologies and services to use or interface with
any specific parts of a Microsoft technology, Microsoft product, or service that includes the feedback.
You will not give feedback that is subject to a license that requires Microsoft to license its technology,
technologies, or products to third parties because we include your feedback in them. These rights
survive this agreement.
c. Pre-release Term. If you are an Microsoft IT Academy Program Member, Microsoft Learning
Competency Member, MPN Member or Trainer, you will cease using all copies of the Licensed Content on
the Pre-release technology upon (i) the date which Microsoft informs you is the end date for using the
Licensed Content on the Pre-release technology, or (ii) sixty (60) days after the commercial release of the
technology that is the subject of the Licensed Content, whichever is earliest (“Pre-release term”).
Upon expiration or termination of the Pre-release term, you will irretrievably delete and destroy all copies
of the Licensed Content in your possession or under your control.
MCT USE ONLY. STUDENT USE PROHIBITED
4. SCOPE OF LICENSE. The Licensed Content is licensed, not sold. This agreement only gives you some
rights to use the Licensed Content. Microsoft reserves all other rights. Unless applicable law gives you more
rights despite this limitation, you may use the Licensed Content only as expressly permitted in this
agreement. In doing so, you must comply with any technical limitations in the Licensed Content that only
allows you to use it in certain ways. Except as expressly permitted in this agreement, you may not:
• access or allow any individual to access the Licensed Content if they have not acquired a valid license
for the Licensed Content,
• alter, remove or obscure any copyright or other protective notices (including watermarks), branding
or identifications contained in the Licensed Content,
• modify or create a derivative work of any Licensed Content,
• publicly display, or make the Licensed Content available for others to access or use,
• copy, print, install, sell, publish, transmit, lend, adapt, reuse, link to or post, make available or
distribute the Licensed Content to any third party,
• work around any technical limitations in the Licensed Content, or
• reverse engineer, decompile, remove or otherwise thwart any protections or disassemble the
Licensed Content except and only to the extent that applicable law expressly permits, despite this
limitation.
5. RESERVATION OF RIGHTS AND OWNERSHIP. Microsoft reserves all rights not expressly granted to
you in this agreement. The Licensed Content is protected by copyright and other intellectual property laws
and treaties. Microsoft or its suppliers own the title, copyright, and other intellectual property rights in the
Licensed Content.
6. EXPORT RESTRICTIONS. The Licensed Content is subject to United States export laws and regulations.
You must comply with all domestic and international export laws and regulations that apply to the Licensed
Content. These laws include restrictions on destinations, end users and end use. For additional information,
see www.microsoft.com/exporting.
7. SUPPORT SERVICES. Because the Licensed Content is “as is”, we may not provide support services for it.
8. TERMINATION. Without prejudice to any other rights, Microsoft may terminate this agreement if you fail
to comply with the terms and conditions of this agreement. Upon termination of this agreement for any
reason, you will immediately stop all use of and delete and destroy all copies of the Licensed Content in
your possession or under your control.
9. LINKS TO THIRD PARTY SITES. You may link to third party sites through the use of the Licensed
Content. The third party sites are not under the control of Microsoft, and Microsoft is not responsible for
the contents of any third party sites, any links contained in third party sites, or any changes or updates to
third party sites. Microsoft is not responsible for webcasting or any other form of transmission received
from any third party sites. Microsoft is providing these links to third party sites to you only as a
convenience, and the inclusion of any link does not imply an endorsement by Microsoft of the third party
site.
10. ENTIRE AGREEMENT. This agreement, and any additional terms for the Trainer Content, updates and
supplements are the entire agreement for the Licensed Content, updates and supplements.
12. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws
of your country. You may also have rights with respect to the party from whom you acquired the Licensed
Content. This agreement does not change your rights under the laws of your country if the laws of your
country do not permit it to do so.
13. DISCLAIMER OF WARRANTY. THE LICENSED CONTENT IS LICENSED "AS-IS" AND "AS
AVAILABLE." YOU BEAR THE RISK OF USING IT. MICROSOFT AND ITS RESPECTIVE
AFFILIATES GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. YOU MAY
HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT
CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT AND
ITS RESPECTIVE AFFILIATES EXCLUDES ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
14. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM
MICROSOFT, ITS RESPECTIVE AFFILIATES AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP
TO US$5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL,
LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
It also applies even if Microsoft knew or should have known about the possibility of the damages. The
above limitation or exclusion may not apply to you because your country may not allow the exclusion or
limitation of incidental, consequential or other damages.
Please note: As this Licensed Content is distributed in Quebec, Canada, some of the clauses in this
agreement are provided below in French.
Remarque : Ce le contenu sous licence étant distribué au Québec, Canada, certaines des clauses
dans ce contrat sont fournies ci-dessous en français.
EXONÉRATION DE GARANTIE. Le contenu sous licence visé par une licence est offert « tel quel ». Toute
utilisation de ce contenu sous licence est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie
expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection dues
consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties
implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits
prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre
pays si celles-ci ne le permettent pas.
Acknowledgments
Microsoft Learning would like to acknowledge and thank the following for their contribution towards
developing this title. Their effort at various stages in the development has ensured that you have a good
classroom experience.
Tiago has retained several Microsoft Certifications and is also a Microsoft Certified Trainer. In 2013 he was
nominated MCT Regional Lead by Microsoft Corp and had been renewed every year. In 2016 he has been
awarded the MVP Award in Office Server and Services for his community efforts in sharing his knowledge
and experience. This award gives him the opportunity to go even further in getting more opportunities to
share passion for Cloud, SharePoint, and Office 365 Development.
Contents
Module 1: Overview of the Microsoft Azure Platform
Module Overview 1-1
Lesson 1: Azure Services 1-2
Lab: Creating an Azure Virtual Machine for Development and Testing 2-28
Lab: Creating an ASP.NET Web App by Using Azure Web Apps 3-21
Lab: Using Queues and Service Bus to Manage Communication in Azure 8-24
Lab: Automating the Creation of Azure Assets using PowerShell and Azure CLI 9-18
Lab: Integrating Azure Active Directory with the Events Administration Portal 11-16
Module Review and Takeaways 11-17
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course xvii
Course Description
This course offers students the opportunity to take an existing web application and expand its
functionality as part of moving it to Azure. The course does not require any existing experience with
the ASP.NET platform but does require experience with C#. This course focuses on the development
considerations and decisions necessary when building a highly available solution in the cloud. This course
also prepares the students for the 70-532: Developing Microsoft Azure Solutions certification exam.
Audience
This course is intended for students who have experience building web applications. Students should also
have experience with the Microsoft Azure platform and a basic understanding of the services offered in
Azure.
The candidates targeted by this training have basic experience in implementing and monitoring Microsoft
Azure solutions. Candidates are also proficient with the development tools, techniques and approaches
used to build application solutions using C#.
Student Prerequisites
This course requires that students have the following knowledge and skills:
Course prerequisites can be met by having knowledge equivalent to, or by attendance at, courses 10979D:
Microsoft Azure Fundamentals and 20483D: Programming in C# as this current course will build upon
knowledge and skills covered in both courses.
Course Objectives
After completing this course, students will be able to:
Course Outline
The course outline is as follows:
Microsoft Azure provides a collection of services that you can use as building blocks for your cloud
applications.
Although many Microsoft Azure services use virtual machines, sometimes your application might have a
unique need where it requires a virtual machine that is completely unmanaged. Azure provides
networking, backup, and virtualization services as part of its Infrastructure-as-a-Service (IaaS) offering.
Dynamic web applications must store the data that is being managed and manipulated by end users.
ASP.NET technologies such as ADO.NET and Entity Framework provide a way for accessing data in SQL
Server. In the cloud, the Microsoft Azure platform provides a database as a service offering that allows
developers to use SQL in the same way as they would in an on-premises location.
Module 5, “Designing Cloud Applications for Resiliency”
As a developer, you should keep in mind certain considerations while designing applications for the cloud.
Although there are many platform improvements available in the ASP.NET ecosystem, you need to rethink
the way you design your applications, and the patterns that are used, with respect to the scalability and
reliability metrics present for the cloud applications. Lesson 1, “Application Design Practices for Highly
Available Applications,” discusses some of the considerations that are needed when you design
applications that are hosted in the cloud such that they result in minimal downtime.
When you want to scale to different cloud instances, storing files to a local disk becomes a difficult
process to maintain and eventually an unreliable method of storage. Azure provides a Blob storage
mechanism that not only offers high performance but also supports integration to Microsoft Azure
Content Delivery Network (CDN) for low latency downloads.
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course xix
With web applications presenting content and worker roles processing the logic, there needs to be a
mechanism that facilitates the communication between these different entities. Microsoft Azure provides
two queuing mechanisms that you can use for this purpose.
Although you can manage most of the Azure services by using both of the Azure portals or Microsoft
Visual Studio, you can use scripting to completely automate the management of the same resources. This
module will look at automating the lifecycle of the services by using client libraries, Windows PowerShell,
REST, and the Resource Manager.
Although you can deploy your cloud applications manually, it is in your best interest to begin automating
cloud-based deployments. Automation creates many benefits including the ability to trace past actions,
easier repetition of deployment tasks and reduced possibility of human error.
Course Materials
The following materials are included with your kit:
• Course Handbook is a succinct classroom learning guide that provides the critical technical
information in a crisp, tightly focused format, which is essential for an effective in-class learning
experience.
You may be accessing either a printed course handbook or digital courseware material via the Skillpipe
reader by Arvato. Your Microsoft Certified Trainer will provide specific details, but both printed and digital
versions contain the following:
o Lessons guide you through the learning objectives and provide the key points that are critical to
the success of the in-class learning experience.
o Labs provide a real-world, hands-on platform for you to apply the knowledge and skills learned
in the module.
o Module Reviews and Takeaways sections provide on-the-job reference material to boost
knowledge and skills retention.
• Modules include companion content, such as questions and answers, detailed demonstrations steps,
and additional reading links for each lesson. Additionally, modules include Lab Review questions and
answers and Module Reviews and Takeaways sections, which contain the review questions and
answers, best practices, common issues and troubleshooting tips with answers, and real-world issues
and scenarios with answers.
• Resources include well-categorized additional resources that give you immediate access to the
current premium content on TechNet, MSDN, and Microsoft Press.
• Course Evaluation. At the end of the course, you will have the opportunity to complete an online
evaluation to provide feedback on the course, training facility, and instructor.
o To provide additional comments or feedback on the course, send an email to
[email protected]. To inquire about the Microsoft Certification Program,
send an e mail to [email protected].
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course xxi
Note: At the end of each lab, you must revert the virtual machines to a snapshot. You can
find the instructions for this procedure at the end of each lab.
The following table shows the role of each virtual machine that is used in this course:
Software Configuration
The following software is installed on the virtual machine:
• Visual Studio Code
• Azure CLI
The following Windows Store apps are installed on the virtual machine:
• Ubuntu Linux Shell
Course Files
The files associated with the labs in this course are located in the <install_folder>\Labfiles\LabXX folder on
the student computers.
Classroom Setup
Each classroom computer will have the same virtual machine configured in the same way.
You may be accessing the lab virtual machines either in a hosted online environment with a web browser,
or by using Hyper-V on a local machine. The labs and virtual machines are the same in both scenarios;
however, there may be some slight variations because of hosting requirements. Any discrepancies will be
pointed out in the Lab Notes on the hosted lab platform.
Your Microsoft Certified Trainer will provide details about your specific lab environment.
MCT USE ONLY. STUDENT USE PROHIBITED
xxii About This Course
The instructor and student computers must meet the following hardware requirements:
o AMD:
AMD Virtualization (AMD-V)
Second Level Address Translation (SLAT)—nested page tables (NPT)
Hardware-enforced Data Execution Prevention (DEP) must be available and enabled (NX Bit)
Supports TPM 2.0 or greater
o Intel:
Intel Virtualization Technology (Intel VT)
Supports Second Level Address Translation (SLAT)—Extended Page Table (EPT)
Hardware-enforced Data Execution Prevention (DEP) must be available and enabled (XD bit)
Supports TPM 2.0 or greater
• Hard Disk: 500GB SSD System Drive
• RAM: 32 GB minimum
• Network adapter
In addition, the instructor computer must be connected to a projection display device that supports a
minimum resolution of WXGA 1280 x 800 (16x10) pixels, 16-bit colors.
MCT USE ONLY. STUDENT USE PROHIBITED
1-1
Module 1
Overview of the Microsoft Azure Platform
Contents:
Module Overview 1-1
Lesson 1: Azure Services 1-2
Module Overview
Microsoft Azure provides a collection of services that you can use as building blocks for your cloud
applications. Lesson 1, “Azure Services,” provides a recap of the services that you might have worked with
when using the Microsoft Azure platform in the past. Lesson 2, “Azure Portal,” describes the Azure portal
that is available for managing Azure subscriptions and services.
Objectives
After completing this module, you will be able to:
• Describe some of the common Azure services.
Lesson 1
Azure Services
This lesson describes some of the common services and features, used by many entry-level Azure
developers and IT professionals, which are available in Azure. Although not comprehensive, this feature
list represents many of the services that you might have used prior to taking this course.
Lesson Objectives
After completing this lesson, you will be able to:
o Web Apps
o Virtual Machines
o Storage
o SQL Database
o Virtual Network
Services Overview
The Azure platform is a collection of services that
allows you to host existing workloads, use
managed services instead of a workload, and
create greenfield workloads. In the majority of
projects, you might use only a subset of the
available services in the Azure platform. It is very
typical to find varying levels of experience
amongst your peers. In this course, you will learn
about the most common services that you can
use in new development projects that will be
hosted on the Azure platform.
Communication Infrastructure
Cloud applications are typically modular in nature and require a managed communication infrastructure,
such as Service Bus, to connect the various application modules. Service Bus provides features such as
event subscription and publishing, mobile notification infrastructure, WCF service relay, and a managed
queue service.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 1-3
Web Hosting
For low-friction development and deployment, the Web Apps service provides a web hosting platform for
your applications that integrate with File Transfer Protocol (FTP), source control providers, or the Web
Deploy protocol.
Mobile Connectivity
Mobile Apps is a fully managed back-end service solution for client devices. Together with SQL Databases,
Mobile Apps can help you design your data schema while you scale up to meet the demand from your
users.
Web Apps
Web Apps provides platform for your web
applications with many features to reduce the
friction of deployment. A high degree of
compatibility with Internet Information Server
(IIS) Web Apps allows you to configure your web
applications by using familiar IIS configuration
settings. Because the platform is highly managed,
you can scale up your web applications
automatically with load balancing, which is also
configured automatically.
Reference Link:
https://docs.microsoft.com/azure/app-service/app-service-web-overview
The Web Apps service allows you to use ASP.NET, Java, PHP, Node.js, or Python as an application
framework for your web applications out of the box. You can also use popular CMS solutions with custom
templates and markup languages, such as Drupal, Joomla, DotNetNuke, and Umbraco, with the platform
for your web solutions.
Deployment
Along with the current synchronous deployment methods, Web Apps also supports continuous
deployment from a source control provider. You can use a source control provider such as GitHub,
Bitbucket, Codeplex, or Microsoft Azure Visual Studio Online as the source for a continuous deployment
build.
No Ops
The Web Apps environment is fully managed, which allows you to have a scalable web hosting platform
that is resilient and highly available without having to specifically manage each Web App instance at a
low level. This also allows you to scale up your web application by simply configuring a set of values.
MCT USE ONLY. STUDENT USE PROHIBITED
1-4 Overview of the Microsoft Azure Platform
Virtual Machines
Virtual machines provide compute on demand
for your application workloads with a high
degree of compatibility with existing
virtualization workloads. By using the
standardized .vhd format from Hyper-V disks,
infrastructure administrators can easily on ramp
existing Hyper-V workloads to Azure.
Workloads
Virtual machines support a list of common
Microsoft application workloads. Software
platforms such as Microsoft SharePoint, SQL
Server, Dynamics GP, and BizTalk Server are fully
supported using the infrastructure hosted in Azure. By connecting Virtual Machines to your on-premises
network, you can enable disaster-recovery and high-availability solutions such as SQL Server AlwaysOn.
Templates
You can create the majority of supported workloads in Azure by using pre-built templates on the portal.
Microsoft and third-party images are available for both Linux and Microsoft-supported application
workloads. Standard operating system images for Windows and Linux are also available for new projects.
Choice in Sizing
You can configure virtual machines with a variety of options for CPU, memory, and IOPS, commonly
referred to as VM sizes. The Basic and Standard sizes are available for the most common application
workloads. Larger standard sizes are also available for memory intensive workloads. D-size virtual
machines are available with a faster processor and a local solid-state drive (SSD). G-size virtual machines
are available for workloads that require massive compute or memory resources.
Storage
Storage is a managed service that allows you to
store data that can be used throughout your
cloud applications. The data that is stored can
include loosely structured entities, queue
messages, and various files. You can access this
data by using client libraries, URLs, or the REST
API. You can store and manage files by using files
shares.
Blobs
Blobs are managed files that can be persisted
and accessed by using URLs, the REST API, or a
client library. You can use containers to logically
group blobs. Blobs are used throughout service instances, such as Virtual Machines that uses blobs to
store virtual hard disks.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 1-5
Queues
The Queue service provides a simple managed interface to push messages into a queue and consume the
same messages. Messages are stored as serialized strings. They can be stored or retrieved in a First-In
First-Out manner by using logical queue actions, such as enqueue, dequeue, and peek.
Tables
The Table service is a NoSQL store that allows you to store loosely structured sets of entities that can be
persisted en masse and retrieved with exception efficiency. By implementing common sharding concepts,
such as partitions and hash indexes, you can use tables to store large quantities of data for your
application.
Files
The Azure Files service provides an SMB 2.1 protocol file share that you can use when you migrate
existing application workloads from on-premises to Azure. The files that are persisted by using this
technology can also be accessed by using the REST API or client libraries.
SQL Database
SQL Database is a managed Database-as-a-
Service platform that you can use to host your
SQL objects. It is highly compatible with existing
data tools and therefore it provides you with
similar management experience that you will
have with SQL Server Standalone.
Compatibility
Many SQL features and objects can be used with
SQL Database. SQL Server 2014 provides tooling
that you can use to analyze and migrate your
databases from an on-premises server to Azure.
Data Tools
You can use many existing data tools such as SQL Server Data Tools for Microsoft Visual Studio and SQL
Server Management Studio with SQL Database. Other tools and application frameworks can use
connection strings to connect to the databases that are hosted in Azure. You can provide the connection
strings for SQL Database instances directly on either portal. SQL Database also provides a custom portal
for managing databases.
Scalability
Elastic Scale can be used with a SQL Database instance to automatically create and manage defined
partitions for applications with dynamic or large database workloads. Applications that can benefit from
this feature range from large data stores to multitenant Software-as-a-Service (SaaS) services.
MCT USE ONLY. STUDENT USE PROHIBITED
1-6 Overview of the Microsoft Azure Platform
Virtual Networks
Virtual networks are a security boundary that you
can create so that service instances can
communicate with each other privately. Virtual
networks support instances of the Web Apps,
SQL Databases, and Virtual Machines services.
Through the various connectivity options, virtual
networks can be connected to each other or to
an existing on-premises machine or network.
Site Connectivity
You can connect virtual networks with each other
or with an existing on-premises network by using
the Internet Protocol Security (IPSec) protocol.
This allows a secure link between multiple networks and various hybrid cloud scenarios. VPN Devices that
support this connectivity can be determined by using a list of known supported VPN devices or a list of
features that are required to be supported by a device that will be used with a Site-to-Site connection.
Reference Link:
https://docs.microsoft.com/azure/vpn-gateway/vpn-gateway-about-vpn-devices
Direct Connectivity
The Secure Sockets Tunneling Protocol (SSTP) can also be used to allow an individual device or a
computer to directly connect to a virtual network by using a Point-to-Site virtual private network (VPN)
connection. This is useful in scenarios where an on-premises location does not have the hardware that
supports IPSec or a network needs to be used by multiple remote workers.
App Services
Azure provides many other services for your
cloud applications. The following sections
describe some of these services.
Media Services
Media Services is a service that allows you to encode and stream multimedia for a wide variety of
customers and devices. Media Services can dynamically scale up to meet the spikes in demand for the
transformation and retrieval of audio or video. You can use Jobs with Media Services to monitor the
progress of the encoding operations that are in the queue.
Mobile Services
Mobile Services is a back-end service platform that you can use to store and provide application data for
mobile devices. Mobile Services uses SQL Database to store the actual data and manage the schema of
the data that is posted to the back-end web service.
Automation
Automation extends your management features by allowing you to use Windows PowerShell to automate
common management tasks. Automation uses Windows PowerShell workflows in the same manner as
Microsoft System Center. Automation also includes an extensive Runbook library of scripts that are
provided by Microsoft and the open-source community.
MCT USE ONLY. STUDENT USE PROHIBITED
1-8 Overview of the Microsoft Azure Platform
Lesson 2
Azure Portal
Many iterations of Azure services and the web applications to manage those services are currently
available.
This lesson describes the last two iterations of the Azure Portal, which you can use for configuring
instances of Azure services. This lesson also provides a walkthrough of how to switch between the two
Azure Portals when the functionality you require is not available in one of the portals.
Lesson Objectives
After completing this lesson, you will be able to:
The latest version of the portal was released at //build 2014. The focus of this new portal is to display
more metadata about each service instance and group the services logically for monitoring and billing.
Additional features are released for the new portal on a weekly basis and this rapid cadence.
Billing
Previously, you had to switch from the Classic Portal to the Account Portal to view the billing data for your
services. In the Portal, you can view the up-to-date billing data for your entire subscription in the form of
charts and infographics. The charts and infographics will help you understand the impact of individual
service instances and service types. Charts, such as the Burn rate, also help you forecast the charges to
your account in each billing period.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 1-9
Resource Groups
Resource groups represent a new way of logically grouping your service instances. Service instances are
known as resources and a collection of resources can exist in a resource group. By using resource groups,
you can view the metrics and billing data for a specific group in your subscription. Resource groups also
allow your service instances to share a common lifecycle, where you can create a group with multiple
resources defined or remove a group and the Resource Manager ensures that the individual resources are
also removed. Resource groups are covered in depth in Module 11, “Automating Integration with Azure
Resources.”
Portal Features
Blades
When you view the settings for a service instance
or take an action, the details are displayed in a
vertical dialog box known as a blade. You can
stack these blades horizontally so that you can
view the details of a service (or an action) and
some of the follow-up actions without having to
scroll horizontally. You can close a blade by
clicking the close (X) button at the top-right
corner. You can click the pin icon at the top-right
corner to pin the blade to your Dashboard for
future access. You can minimize the blades to
place them on the left side of the screen and maximize them to fill the entire width of your screen. You
can hide the labs on the top command bar to create more screen space for your tiles. Finally, you can
customize the order and layout of the tiles in most blades.
Journeys
Journeys are a collection of sequential blades that you can use to create or modify a service. For example,
to create a Web App, you can go to the gallery blade, and then view the Web App gallery options blade.
After you select a specific Web App template, a blade describing the template displays. If you click Create,
another blade displays with basic options for the new Web App. You could drill down further and specify
advanced options. Many of these advanced options might display a subsequent blade. These blades that
are displayed in a horizontal sequence are known as a journey. In a journey if you try to close a blade,
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 1-11
which is to the left of another blade, without saving the changes, a message displays informing you about
the loss in progress. Journeys are sometimes broken down in to Journey Parts, but this is not currently
visualized in the user interface.
The following image depicts a journey from the “All Resources” blade to a specific “Storage Account”
blade:
Dashboard
The Dashboard is the first screen you see when you log on to the Portal. It is a collection of tiles that you
can reorganize, resize, and remove. As you view the blades in your subscription, you can pin them to the
Dashboard so that you can return to them at a later point in time. You can also resize the tiles to
emphasize specific data.
Many tiles show different metrics and icons depending on their size. For example, the Service health tile
displays a world map in the largest size, but in the smallest size it displays only a count of the services that
are healthy. By default, when you create a new instance of a service, the option to add a tile to the
Dashboard for that instance is selected.
MCT USE ONLY. STUDENT USE PROHIBITED
1-12 Overview of the Microsoft Azure Platform
You can opt to resize a tile by dragging the bottom-right corner of the tile:
Note: To view the latest demo steps, visit the GitHub repository for the course.
For this demonstration, you will use the available host machine. Before you begin this demonstration, you
must complete the following step:
• Verify that you received the credentials to sign in to the Azure portal from your training provider. You
will use these credentials and the Azure account throughout the labs in this course.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 1-13
Objectives
After you complete this lab, you will be able to:
• Identify a blade.
• Identify a journey.
Lab Setup
Estimated Time: 15 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Best Practice
Many of the services that are covered in this module are pre-requisites for the course. If you never worked
with any of services that are mentioned in this module, please take time to review these services before
completing the subsequent modules. This will ensure that you are prepared for the later modules in this
course.
Review Question
Question: You are building an iOS and Android application. Your application will need a
back-end web service, and you decided to host the service in Azure. What services can you
use to accomplish this task?
MCT USE ONLY. STUDENT USE PROHIBITED
2-1
Module 2
Building Application Infrastructure in Azure
Contents:
Module Overview 2-1
Lesson 1: Azure Virtual Machines 2-2
Lab: Creating an Azure Virtual Machine for Development and Testing 2-28
Module Overview
Although many Microsoft Azure services use virtual machines, sometimes your application might have a
unique need where it requires a virtual machine that is completely unmanaged. Azure provides
networking, backup, and virtualization services as part of its Infrastructure-as-a-Service (IaaS) offering.
Lesson 1, “Azure Virtual Machines,” introduces the Virtual Machines service and describes the options that
you can use for creating a virtual machine. Lesson 2, “Azure Virtual Machine Workloads,” provides details
on the types of workloads that you can deploy to a virtual machine. Lesson 3, “Migrating Azure Virtual
Machine Instances,” describes the options for migrating virtual machines to and from Azure. Lesson 4,
“Highly Available Azure Virtual Machines,” reviews the options and features that must be considered when
designing your Virtual Machine instances for high availability scenarios. Lesson 5, “Virtual Machine
Configuration Management,” describes the common methods for managing and duplicating the
configuration for virtual machines. Lesson 6, “Customizing Azure Virtual Machine Networking,” reviews
the options for managing inbound and outbound connection rules for your virtual machine. Lesson 7,
“Virtual Machine Scale Sets,” introduces the VMSS service and describes how it can be used to
automatically provision virtual machines for autoscale scenarios.
Objectives
After completing this module, you will be able to:
• Describe the Virtual Machines service in Azure.
Lesson 1
Azure Virtual Machines
The Virtual Machines service in Azure provides quick compute that can be scaled up or out and
completely customized. The Azure Management Portal provides a large collection of templates that
makes it very easy for you to get started with a popular server operating system.
This lesson describes the Virtual Machines service in Azure and provides the details on some of its unique
features.
Lesson Objectives
After completing this lesson, you will be able to:
Hyper-V
Virtual machines in Azure use the well-known Hyper-V virtual hard disk format (.vhd) for their hard drives.
Because Azure uses the .vhd format, you can simply upload fixed-size virtual hard disk files from your
existing infrastructure to Azure. You can also download virtual hard disk files from Azure to your
datacenter.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-3
Microsoft Images
Many of the Microsoft server software are
already supported in the Azure virtual machine
environment. Common Microsoft workloads that are supported include:
All the supported Microsoft workloads are not available as template images. For example, SQL Server
2008 is a supported workload, but a gallery image is available only for Microsoft SQL Server 2008 R2.
A virtual machine can be created using the Microsoft SQL Server 2012 SP1 gallery image in the
Management Portal:
• CoreOS
• Ubuntu
• openSUSE
• OpenLogic
You can also create your own custom Linux–based virtual machines and upload them to Azure as .vhd
files.
Creating an Ubuntu Server 14–based virtual machine from a gallery image in the Azure Preview Portal:
Custom Images
You can create custom images from an existing virtual machine. You use the custom images to create
duplicates of your virtual machine in scenarios where you need multiple instances of the virtual machine
to have a similar configuration. Custom images can either be generalized, so that you can clone as many
copies as you want, or specialized so that you can create a checkpoint of a virtual machine to maintain its
state at a certain point in time.
Generalized virtual machine images are operating system images that are de-provisioned (Sysprep in
Windows or waagent in Linux) so that you can provision them after they are cloned to other virtual hard
disks.
Note: In Azure, when you capture a generalized virtual machine image, the image will
delete the virtual machine without affecting the disk. You can then use this image to create as
many duplicate virtual machines as you need. You must stop a virtual machine before capturing a
generalized image.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-5
Specialized virtual machine images are a snapshot of a running virtual machine, which you can use later to
return the virtual machine to that point in time.
Note: In Azure, you can capture a specialized virtual machine image from a virtual machine
that is running or stopped. This will not affect the existing virtual machine. You can create a new
virtual machine by using the specialized image that need not be provisioned again.
Lesson 2
Azure Virtual Machine Workloads
You can deploy your existing application workloads to virtual machines in Azure that are running either
on the Windows or Linux operating system.
This lesson describes some of the considerations for deploying application workloads to the virtual
machines in Azure.
Lesson Objectives
After completing this lesson, you will be able to describe the key considerations for deploying Windows or
Linux workloads to Azure.
Windows Workloads
Many common Microsoft workloads (server
software) are already supported in Azure. Most of
these workloads also include corresponding
virtual machine templates in the Azure portals.
All software that is installed on an Azure virtual
machine must have the necessary licenses.
However, if you use a gallery template the cost of
the license is already included in the cost of the
virtual machine.
If you start with an operating system gallery template, and then install the server software, you must
immediately license the server software by using license migration.
Supplemental guidance articles are available, which will help you plan for the installation of many
common Microsoft software workloads on Azure Virtual Machines.
Linux Workloads
Many common Linux distributions are already
available on the Azure platform with gallery
images. Including the images in VM Depot, there
are enough images in the Azure platform to run
the most popular Linux workloads.
The Azure platform provides a common interface
for managing virtual machines, irrespective of
whether they run on Linux or Windows. Many
common features, such as capturing an image,
attaching a disk, and stopping a virtual machine,
use common buttons in either portal and
common actions in the Cross-Platform
Command-Line Interface. This enables you to manage your Linux–based virtual machines in the same
manner as you manage your Windows–based virtual machines.
After provisioning the virtual machine, virtual machine extensions are used to configure the Linux–based
virtual machine so that it can be accessed by using Secure Shell (SSH). You can then use tools such as
PuTTY to access your new Linux–based virtual machine.
A2 2 3.5 GB 4x300
A3 4 7 GB 8x300
A4 8 14 GB 16x300
A1 1 1.75 GB 2x500
A2 2 3.5 GB 4x500
A3 4 7 GB 8x500
A4 8 14 GB 16x500
A5 2 14 GB 4x500
A6 4 28 GB 8x500
A7 8 56 GB 16x500
A8 8 56 GB 16x500
A9 16 112 GB 16x500
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-9
D1 1 3.5 GB 50 GB 1x500
D2 1 7 GB 100 GB 2x500
D3 2 14 GB 200 GB 4x500
D4 4 28 GB 400 GB 16x500
G1 2 3.5 GB 406 GB
G2 4 7 GB 812 GB
G3 8 14 GB 1,630 GB
G4 16 28 GB 3,250 GB
G5 32 14 GB 6,500 GB
MCT USE ONLY. STUDENT USE PROHIBITED
2-10 Building Application Infrastructure in Azure
Lesson 3
Migrating Azure Virtual Machine Instances
Azure provides infrastructure options that make it easy to either extend your existing datacenter or create
a new environment in the cloud. With services such as Networking, Backup, Site Recovery, and Virtual
Machines, Azure has the necessary services to deploy your existing complex production applications.
This lesson describes the various methods that you can use to migrate your virtual machines to Azure.
Lesson Objectives
After completing this lesson, you will be able to:
Disk Mobility
Because Azure and Hyper-V support a common
.vhd format, you can easily upload and download
virtual hard disks by using a third-party storage
explorer or automation scripts. In Windows
PowerShell, you can use the following activities to add and save virtual machines:
• Add-AzureVhd
• Save-AzureVhd
In Cross-Platform Command-Line Interface, you can use the following commands to create and upload
virtual machine disks to Azure:
• vm disk create
• vm disk upload
In most cases, you must use scripts to upload the .vhd files to a storage account because you cannot
upload them by using any of the Azure portals. The .vhd files must be Generation 1 Hyper-V disks and
they must of a fixed size. Generation 2 Hyper-V disks (.vhdx) are currently not supported.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-11
Migration Accelerator
The Migration Accelerator is a tool that you can use to analyze your existing application workloads and
then perform a full migration of your virtual machine along with the network and endpoint configuration.
The migration is performed by using a series of agents and configuration or process servers. You can use
the Migration Accelerator to analyze the existing multi-tier application workloads that are running on
Windows Server 2008 R2 for an automated migration. Migration to Azure can happen automatically
without affecting your existing infrastructure and the target site can also be tested extensively before
cutover occurs. Migration Accelerator supports existing workloads on physical machines, VMWare,
Hyper-V, Amazon Web Services, and various other platforms.
You can use Migration Accelerator to discover existing workloads, perform a migration, and then perform
a cutover:
Readiness Assessment
The Virtual Machine Readiness Assessment analyzes existing servers to check if they are compatible with
the Azure platform. When you run the tool, you have to answer a series of questions about the workload
on your virtual machine. Depending on the analysis of the running virtual machine and the responses to
the questions, a detailed report is generated. The generated report contains suggestions for virtual
machine configuration in Azure and hyperlinks to the articles that you can read before you migrate your
workload.
You can use the Virtual Machine Readiness Assessment report to plan a migration to Azure:
Backup
Backup is a simple automated backup solution
that uses other common Azure services and
Windows Server features to minimize the amount
of management that is required to back up data.
Backup integrates directly with the data
protection functionality of Windows Server and System Center. The backup data is stored in a storage
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-13
account that can be geo-replicated. Backup is optimized such that it only synchronizes incremental
changes and all the data is secure during transit.
Site Recovery
Site Recovery is a comprehensive disaster recovery service that provides deep orchestration and
monitoring functionality. Site Recovery also uses existing technologies such as System Center, Hyper-V
Replica, and SQL Server AlwaysOn. You can use recovery plans to orchestrate the recovery of your services
by using distributed virtual machines and custom logic. You can regularly test recovery plans in isolation
from your primary location.
Reference Link:
https://docs.microsoft.com/azure/virtual-network/virtual-networks-create-vnet-classic-netcfg-ps
MCT USE ONLY. STUDENT USE PROHIBITED
2-14 Building Application Infrastructure in Azure
You can use the network configuration elements of the service configuration file to deploy cloud services
into a virtual network that was previously defined in a network configuration file.
Some of the network configuration settings that you can specify in the service configuration file are:
• The DNS servers that can be used for name resolution
Lesson 4
Highly Available Azure Virtual Machines
You can use horizontal or vertical scaling with virtual machines and load balancing for a high availability
scenario. Availability sets also affect the availability of your virtual machines during faults or upgrades.
This lesson describes the considerations for designing your virtual machine collections for high availability
scenarios.
Lesson Objectives
After completing this lesson, you will be able to:
• Describe how fault and upgrade domains affect virtual machine availability.
Availability Sets
Availability sets offer a mechanism that instructs
Azure to place the virtual machines in separate
fault or update domain. When a virtual machine
stops working because of a fault (or for regular
maintenance), at least one instance of your load
balanced virtual machine remains available.
Maintenance Events
In the Azure platform, planned maintenance can
occur at any time. Typically, these updates are
made by Microsoft to enable new features or
improve reliability and performance. Also, the
majority of these planned maintenance events
are announced and do not have an impact on running virtual machines or cloud services. However,
occasionally a planned maintenance event will require a reboot of a virtual machine or a restart of a cloud
service.
Unplanned maintenance events can occur when there is a physical or hardware fault that affects your
running Virtual Machine instance. Although the Azure platform automatically migrates your instances,
there could potentially be downtime between the physical fault and the recovery orchestration.
Availability Sets
You can use availability sets to group two or more virtual machines in a manner that provides redundancy
for an application. An availability set ensures that during planned or unplanned maintenance events, at
least one virtual machine remains available. Typically, virtual machines that are part of the same tier of an
application are placed into the same availability set.
MCT USE ONLY. STUDENT USE PROHIBITED
2-16 Building Application Infrastructure in Azure
Availability sets can be used to group virtual machines into application tiers:
Vertical Scaling
You can vertically scale virtual machine instances
by changing their size. If there is an application
that is running on a virtual machine and it
requires more resources, you can handle it by
increasing the virtual machine size. This can
potentially add more memory, disks, or CPU
cores.
Horizontal Scaling
If you have multiple Virtual Machine instances in
an availability set, you can make use of the
scaling functionality that is available in the Azure portals. You can manually change instance counts to
scale an application up or down.
MCT USE ONLY. STUDENT USE PROHIBITED
2-18 Building Application Infrastructure in Azure
When you scale up or scale down horizontally an application that is running on virtual machines in an
availability set, you can neither create new virtual machines nor delete the existing virtual machines.
Instead you turn on or turn off any previously created virtual machines in an availability set. You can
specify scaling based on the average percentage of CPU usage or based on the number of messages in a
queue.
Autoscaling by Metric
On the Scale page, you can configure your cloud service to automatically increase or decrease the number
of instances of virtual machines that are used by your application. You can configure scaling based on the
following parameters:
• Average CPU usage. If the average percentage of CPU usage goes above or below specified
thresholds, role instances are created or deleted, or virtual machines are turned on or turned off from
an availability set.
• Queue messages. If the number of messages in a queue goes above or below a specified threshold,
role instances are created or deleted, or virtual machines are turned on or turned off from an
availability set.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-19
When you define autoscale rules, you must specify the following values:
• Schedule. Defines the time and dates when the rules should be applied.
• Instance Range. The maximum and minimum number of instances to scale up or down to.
• Metrics
o Target CPU. The ideal CPU range for the application’s virtual machines. Scale up occurs when the
average percentage of CPU usage is above the range and scale down occurs when the average
percentage of CPU usage is below the range.
o Queue Target Per Machine. The target number of queue messages for each virtual machine
instance. Scale is determined by dividing the total number of queue messages by the ideal
number of queue messages for each instance.
• Scale Up/Down By. The number of instances to start or stop for each scale operation.
• Scale Up/Down Wait Time. The minimum amount of time to wait before performing another scale
operation.
MCT USE ONLY. STUDENT USE PROHIBITED
2-20 Building Application Infrastructure in Azure
Lesson 5
Virtual Machine Configuration Management
Although you can configure each virtual machine manually, automating the configuration of a virtual
machine can lead to repeatable, efficient, and testable deployment scenarios. Automating configuration
can also ensure that newly scaled instances of a virtual machine match the other instances.
This lesson discusses some of the most common methods of configuration management.
Lesson Objectives
After completing this lesson, you will be able to:
• Explain how Windows PowerShell desired state configuration (DSC) can be used for virtual machine
configuration management.
You have now defined the example configuration. Next, you will need to enact this configuration. You can
do this by invoking the configuration.
Invoking the configuration creates Managed Object Format (MOF) files and places them in a new
directory with the same name as the configuration block. The new MOF files contain the configuration
information for the target nodes.
Enable Configuration
Start-DscConfiguration -Wait -Verbose -Path .\WebServerConfig
DSC includes other extensibility features such as parameters and nesting configurations.
VM Agent
The virtual machine agent is a lightweight service
that is typically installed on Azure virtual
machines. This agent provides an extensibility
point where extensions can be installed. Virtual
machine extensions are custom extensions
created that can be installed in Azure virtual
machines, which have the virtual machine agent
installed. By using virtual machine extensions,
you can do the following:
• Automatically install custom or off-the-shelf
software components in a virtual machine.
• Install, update, or remove custom features
without having to recreate or update an existing virtual machine.
• Manage and view status or metrics for multiple virtual machines from a centralized tool or location.
• Revision History. Enables your team to determine who or what changes specific configuration
settings
• Replication. Enables your configuration changes to be replicated across multiple machines
• Agents. Software specifically installed on machines to receive configuration change requests and
apply them to the local machine
The configuration management utilities discussed in this topic support both Windows and Linux operating
systems.
Chef and Puppet are two of the most common examples of configuration management software used
throughout the industry. Both Chef and Puppet are written in Ruby and are licensed under the Apache
license. Template images are available for both Chef and Puppet in Azure.
Puppet
Puppet is an open-source configuration management utility that is produced by Puppet Labs. Puppet has
a unique declarative language that can be used to describe system configuration. These configuration
changes can be applied directly to a virtual machine or distributed to multiple virtual machines by using a
catalog. The Puppet agent periodically polls the machine for its current configuration and then syncs that
configuration data to the Puppet master, a machine that manages all of the other machines with agents
installed. The Puppet master ensures that the machines with the agent installed are in compliance with
the latest configuration defined in the catalog.
Chef
Chef is another popular open-source configuration management utility. Chef is unique because
configuration changes are composed into recipes. Recipes are composed of individual configuration
changes that are called resources, which can include:
• A file to store
Lesson 6
Customizing Azure Virtual Machine Networking
Although you can use Azure virtual machines right after you create them, you must perform additional
configuration before interfacing these virtual machines instances with external resources or other virtual
machines.
This lesson describes the methods used for customizing the network connectivity of an Azure virtual
machine.
Lesson Objectives
After completing this lesson, you will be able to:
• Customize the access control list for a virtual machine or cloud service.
A NSG is a top-level object that is associated to your subscription. An NSG contains access control rules
that allow or deny traffic to VM instances. The rules of an NSG can be changed at any time, and changes
are applied to all associated instances.
A network security group has a Name, is associated to a Region, and has a descriptive label. It contains
two types of rules, Inbound and Outbound. The Inbound rules are applied on the incoming packets to a
VM and the Outbound rules are applied to the outgoing packets from the VM. The rules are applied at
the host where the VM is located. An incoming or outgoing packet has to match an Allow rule for it be
permitted, if not it will be dropped.
Rules are processed in the order of priority. For example, a rule with a lower priority number (e.g. 100) is
processed before rules with a higher priority numbers (e.g. 200). Once a match is found, no more rules are
processed.
MCT USE ONLY. STUDENT USE PROHIBITED
2-24 Building Application Infrastructure in Azure
An NSG contains default rules. The default rules cannot be deleted, but because they are assigned the
lowest priority, they can be overridden by the rules that you create. The default rules describe the default
settings recommended by the platform. While connectivity to the Internet is allowed for Outbound
direction, it is by default blocked for Inbound direction. There is a default rule to allow Azure’s load
balancer (LB) to probe the health of the VM. You can override this rule if the VM or set of VMs under the
NSG does not participate in the load balanced set.
Inbound
SOURCE DESTINATION DESTINATION
NAME PRIORITY SOURCE IP PROTOCOL ACCESS
PORT IP PORT
Outbound
SOURCE SOURCE DESTINATION DESTINATION
NAME PRIORITY PROTOCOL ACCESS
IP PORT IP PORT
Firewall Rules
Windows Firewall is a built-in, host-based,
stateful firewall that is included in the client
version of Windows and Windows Server.
Windows Firewall drops incoming traffic that
does not correspond to either the traffic that is
sent in response to a request of the computer
(solicited, outbound traffic) or unsolicited traffic
that has been specified as allowed (excepted,
inbound traffic). Windows Firewall is configured
by using the Windows Firewall with Advanced
Security snap-in, which integrates rules for both
firewall behavior and traffic protection with
Internet Protocol security (IPsec).
Virtual machines that are migrated to Azure should have their Windows Firewall rules verified prior to
migration. It is possible that after a virtual machine is migrated to Azure, you might have issues
connecting to the virtual machine for management tasks because of the Windows Firewall rules.
VNET Connectivity
Site-to-Site
Point-to-Site
A point-to-site VPN also allows you to create a secure connection to your virtual network. In a point-to-
site configuration, the connection is configured individually on each client computer that you want to
connect to the virtual network. Point-to-site connections do not require a VPN device. They work by using
a VPN client that you install on each client computer. The VPN is established by manually starting the
connection from the on-premises client computer. You can also configure the VPN client to automatically
restart.
Lesson 7
Virtual Machine Scale Sets
It is possible to create a large number of virtual machines and manage their installed software and
configuration manually but it far from ideal. Virtual Machine Scale Sets is a service in Azure that can
deploy large quantities of virtual machines for you, add them to a load balancer, configure them and
auto-scale automatically for you.
This lesson will briefly introduce the Virtual Machine Scale Sets service and how you can create a VMSS
instance for application workloads.
Lesson Objectives
After completing this lesson, you will be able to:
An Azure VM Scale Set also requires no pre-provisioning of the Virtual Machine before adding to the
scale set. The network and load balancer are created, configured and managed automatically, including
the Network Address Translation (NAT) for access to and from the VM Instances.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 2-27
These features added to the ease of deployment through the portal, Azure PowerShell or Azure CLI make
the Azure VM Scale Set a powerful tool for the Azure cloud architect.
Objectives
After you complete this lab, you will be able to:
Lab Setup
Estimated Time: 90 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Module 3
Hosting Web Applications on the Azure Platform
Contents:
Module Overview 3-1
Lesson 1: Azure Web Apps 3-2
Lab: Creating an ASP.NET Web App by Using Azure Web Apps 3-21
Module Overview
This module provides an overview of the Azure Web Apps service. Lesson 1, “Azure Web Apps,” introduces
the Azure App Service platform-as-a-service offering available in Azure and specifically focuses on the
Web Apps feature of App service. Lesson 2, “Azure Logic and Function Apps,” explore two of the types of
apps available in Azure App Service. Lesson 3, “Configuring an App Service App,” discusses the various
configuration options available to change the behavior of your app. Lesson 4, “Publishing an App Service
App,” describes the process for publishing a web application to an app. Lesson 5, “Supplemental Services,”
introduces additional service offerings for web applications in Azure such as the intelligent service
offerings and the API Management service that can be used as a proxy to an App Service app.
Objectives
After completing this module, you will be able to:
Lesson 1
Azure Web Apps
In many scenarios, it is preferable to use a quick and easy way to deploy web applications to the cloud
rather than to reengineer the web applications as cloud projects. Web Apps allow you to quickly create a
new Web App and iterate changes to the Web App in an agile manner.
Lesson Objectives
After completing this lesson, you will be able to:
Flexibility
You can use a variety of integrated development
environments (IDEs) and frameworks, such as
.NET, Java, PHP, Node.js, or Python, to develop
your web applications that are eventually
deployed to Azure Web Apps. You can use Git
and Kudu to deploy Node.js or PHP web applications. You also can deploy web applications that are
developed in Microsoft Visual Studio to Web Apps by using the File Transfer Protocol (FTP) or the Web
Deploy protocol.
Scalability
Because Web Apps is a fully managed service implementation, you can focus on developing your
application and solving business problems instead of the hosting implementation and hardware scaling or
specifics. You can easily scale up a stateless web application by configuring auto-scale in the portal. Auto-
scale creates multiple instances of your Web App that are automatically load balanced so that your
application can meet potential spikes in demand.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-3
The Shared tier has a lot in common with the Free tier, but many restrictions are relaxed. For example, the
Outbound Data limit is removed and each instance is allowed 240 minutes of CPU time per day that is not
pooled. You can also have up to 100 Web App instances in this tier. In this tier, you also can use a custom
domain with your Web App. You also can manually scale out to six different instances of your Web App.
These Web App instances are hosted in different shared compute instances and are load balanced
automatically.
In the Basic tier, your Web App instances are not in a shared environment. Instead, you have a dedicated
compute instance where you can host as many Web App instances as you want. In addition to the
features offered by the Free and Shared tiers, this tier also supports AlwaysOn, Secure Socket Layer (SSL)
for custom domains, and a limited quantity of WebSocket connections (350 per Web App). You can
manually scale out this tier to a maximum of three dedicated compute instances.
The Standard tier offers the same functionality as the Basic, Free and Shared tiers, but includes additional
features such as Publishing Slots and Backups. With the auto-scale functionality, you can automatically
scale your Web App based on a metric or a schedule.
Reference Link:
https://github.com/projectkudu/kudu/wiki
• Deployment hooks
• Web hooks
• Web Jobs
You can access the Kudu console for your Web App by using the following URL format:
Kudu also provides an endpoint that the IIS Manager can use to remotely configure the web application.
This provides a safer way to modify the application’s Web.config file. Managing your web application
using KUDU or the IIS Manager endpoint is not prone to errors unlike the traditional method of accessing
the web application’s file system and editing the configuration files.
When you create a new Web App instance, you can either specify a App Service Plan or have a App
Service Plan selected for you. By default, if your subscription does not have any App Service Plan, a new
Standard tier App Service Plan is created automatically. If your subscription has an existing App Service
Plan, then that plan is selected, by default, when you create a new Web App instance. You can also create
a new App Service Plan when you create a new Web App instance.
All Web Apps within a App Service Plan are scaled together. Manual scale settings or auto-scale settings
are configured on the entire App Service Plan. For example, you can configure a Standard App Service
Plan to have a minimum of three instances and a maximum of five instances and auto-scale by
monitoring the disk queue depth metric. Under an average load, you can expect to have four instances.
This means that there are four dedicated compute instances and all your Web App instances have a copy
on each dedicated instance that are load balanced by using the internal load balancer of Web Apps.
Lesson 2
Azure Logic and Function Apps
Serverless computing promises agility and power in building the next generation of solutions. You can use
services such as Azure Functions or Azure Logic Apps to build these solutions. All of these services are
useful when "gluing" together disparate systems. They can all define input, actions, conditions, and
output. You can run each of them on a schedule or trigger. However, each service has unique advantages,
and comparing them is not a question of "Which service is the best?" but one of "Which service is best
suited for this situation?" Often, a combination of these services is the best way to rapidly build a scalable,
full-featured integration solution.
This lesson describes the similarities and differences between the Azure Functions and Azure Logic Apps
services.
Lesson Objectives
After completing this lesson, you will be able to:
• Compare the two services and decide when to use one or combine both in a solution.
Logic Apps
Logic Apps helps you build, schedule, and
automate processes as workflows so you can
integrate apps, data, systems, and services across
enterprises or organizations. Logic Apps
simplifies how you design and create scalable
solutions for app integration, data integration,
system integration, enterprise application
integration (EAI), and business-to-business (B2B)
communication, whether in the cloud, on
premises, or both.
• Process and route orders across on-premises systems and cloud services.
Every logic app workflow starts with a trigger, which fires when a specific event happens, or when new
available data meets specific criteria. Many triggers include basic scheduling capabilities so that you can
specify how regularly your workloads run. For more custom scheduling scenarios, start your workflows
with the Schedule trigger.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-7
Each time that the trigger fires, the Logic Apps engine creates a logic app instance that runs the
workflow's actions. These actions can also include data conversions and flow controls, such as conditional
statements, switch statements, loops, and branching. For example, this logic app starts with a Dynamics
365 trigger with the built-in criteria "When a record is updated". If the trigger detects an event that
matches this criteria, the trigger fires and runs the workflow's actions. Here, these actions include XML
transformation, data updates, decision branching, and email notifications.
You can build your logic apps visually with the Logic Apps Designer, available in the Azure portal through
your browser and in Visual Studio. For more custom logic apps, you can create or edit logic app
definitions in JavaScript Object Notation (JSON) by working in "code view" mode. You can also use Azure
PowerShell commands and Azure Resource Manager templates for select tasks.
Function Apps
Azure Functions is a solution for easily running
small pieces of code, or "functions," in the cloud.
You can write just the code you need for the
problem at hand, without worrying about a
whole application or the infrastructure to run it.
Functions can make development even more
productive, and you can use your development
language of choice, such as C#, F#, Node.js, Java,
or PHP.
Azure Functions integrates with various Azure and 3rd-party services. These services can trigger your
function and start execution, or they can serve as input and output for your code. The following service
integrations are supported by Azure Functions:
• Azure Cosmos DB
• GitHub (webhooks)
• On-premises (using Service Bus)
Azure Functions has two kinds of pricing plans. Choose the one that best fits your needs:
• Consumption plan: When your function runs, Azure provides all of the necessary computational
resources. You don't have to worry about resource management, and you only pay for the time that
your code runs.
• App Service plan: Run your functions just like your web, mobile, and API apps. When you are already
using App Service for your other applications, you can run your functions on the same plan at no
additional cost.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-9
Lesson 3
Configuring an App Service App
App Service provides many features that you can use to expand your web application’s capabilities. By
using the Portal, you can enable different features of an App and modify the custom settings for the App
without redeploying the web application.
This lesson lists the different configuration options that are available for an App.
Lesson Objectives
After completing this lesson, you will be able to:
AlwaysOn
When you host your ASP.NET applications on IIS,
you can isolate them into application pools. IIS
improves the performance of your web server by
automatically recycling application pools on a
scheduled basis and by running the initial
ASP.NET startup tasks for your web application
only when the first request is processed. This
prevents your application from using
unnecessary resources when it is not requested
by clients.
If your ASP.NET application is not precompiled,
the application is compiled just-in-time (JIT) at
startup and then the ASP.NET startup tasks will run. You can inject your own logic into ASP.NET’s startup
by implementing a Global.asax file with the HttpApplication class. If your ASP.NET application is
precompiled, the startup tasks run immediately. Regardless of your choice, these startup tasks can be long
and resource intensive. This will cause the first request or any request that is issued immediately after an
application pool recycle to take a lot longer than normal to process.
In IIS, this can be resolved by setting your application pool’s application start mode to Always Running. In
Apps, you can accomplish this by using the AlwaysOn feature. AlwaysOn prevents your application from
recycling due to going idle. AlwaysOn also improves your application startup time for early clients. This is
accomplished by the Azure platform that regularly pings your App so that it is always active and is in a
running state. This ensures that your application is already running before your first client requests are
issued. It also ensures that your application remains in the running state and starts up in case of a recycle.
AlwaysOn is available only for the Basic and Standard tier Apps.
MCT USE ONLY. STUDENT USE PROHIBITED
3-10 Hosting Web Applications on the Azure Platform
Domain Names
When you create a new App, a subdomain of the
azurewebsites.net domain is assigned by using
the following format:
[http|https]://<sitename>.azuresites.net
If you are using multiple instances within a single Web App, the virtual IP address will be load-balanced
across those instances. You can use your domain registrar’s Web App to configure a canonical name
(CNAME) record and an address (A) records by using the following information.
After you complete this, you can use the same dialog box in the Azure Management portal to enable the
custom domain on your Web App.
Reference Link:
https://docs.microsoft.com/azure/app-service/app-service-web-tutorial-custom-domain
If you want to host multiple App instances across regions, you can use a custom domain name with
Microsoft Azure Traffic Manager.
Reference Link:
https://docs.microsoft.com/azure/app-service/web-sites-traffic-manager-custom-domain-name
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-11
Autoscaling Apps
In many distributed application scenarios, you
might want to scale out (horizontally) your
application by increasing the number of
instances of the application. Using the built-in
load balancer, you can spread the load for your
web application across multiple instances. This
minimizes the per instance cost and ensures that
your application meets the increasing demand
from client devices or browsers.
You can use auto-scale to control horizontal scaling by using metrics and schedules. This gives you the
flexibility to have your application’s resource allocation closely aligned with the actual utilization. By using
auto-scale, you can:
• Minimize unnecessary resource cost by removing App instances when they are no longer needed.
• Maximize performance and client response by creating App instances when a measured threshold
is met.
MCT USE ONLY. STUDENT USE PROHIBITED
3-12 Hosting Web Applications on the Azure Platform
When you define the auto-scale configuration, you must specify the schedules. You can use schedules to
specify different auto-scale rules for different date and time periods. By default, a schedule is created for
all time. After you create or select a schedule, you can define a metric to measure configuration values
such as:
After you save this configuration, you can monitor your auto-scale history for your Web App by using the
same configuration dialogs. In the Portal, an enhanced list of auto-scale metrics is available that you can
use to scale your App such as:
• Average Memory
You also can use the Portal to specify more options that determine how long the web application has to
wait before scaling up or how long it has to wait between scale actions.
Lesson 4
Publishing an Azure App Service App
After developing a web application, you can use Web Deploy to publish the application to Azure. By using
the publish wizard in Visual Studio, you can customize the configuration settings and connection strings
before you publish the web application.
This lesson will focus on the deployment options for App Service Apps in Azure.
Lesson Objectives
After completing this lesson, you will be able to:
• Describe how to publish a web application by using the publish wizard in Visual Studio.
• Describe the difference between the standard Release and Debug builds.
• Binaries
• Content
• XML configuration
• Databases
• Registry modifications
You can create Web Deploy packages manually or by using an IDE such as Visual Studio or WebMatrix.
You can hand off the package to an administrator asynchronously so that he or she can install the
package in any IIS install with the Web Deploy add-in. At installation, the administrator provides
configuration values for items such as SQL database connection strings. You also can use Web Deploy can
to synchronize changes to an application among a server farm. You can extract a Web Deploy package
from an existing IIS Web App and import it into IIS Web Applications that are on other machines within
the same farm. Web Deploy can also expose an endpoint that allows developers to remotely deploy
applications to a web server without having direct access to the actual web server.
MCT USE ONLY. STUDENT USE PROHIBITED
3-14 Hosting Web Applications on the Azure Platform
You can use Web Deploy packages to synchronize development, test, staging, and production
environments regardless of where they are hosted:
Azure App Service allows developers to publish a Web Deploy package to an App instance by using the
remote deploy service. Connection strings and databases are already managed for you to provide a
seamless publish experience.
Lesson 5
Supplemental Services
Many applications can benefit from the inclusion of first-party and third-party services available in the
cloud. Whether the services add intelligent features to an application, or provides additional security and
management features, these services can be interwoven into a variety of application scenarios.
This lesson focuses on various intelligent services such as Cognitive Services, Bot Service, LUIS and QnA
Maker and the API Management proxy service.
Lesson Objectives
After completing this lesson, you will be able to:
• Describe the APIs available in Azure Cognitive Services and the related Bing APIs.
• Use Azure API Management to extend, enhance and protect and existing API endpoint.
Cognitive Services
Microsoft Cognitive Services are a set of APIs,
SDKs and services available to developers to
make their applications more intelligent,
engaging and discoverable. Microsoft Cognitive
Services expands on Microsoft’s evolving
portfolio of machine learning APIs and enables
developers to easily add intelligent features—
such as emotion and video detection; facial,
speech and vision recognition; and speech and
language understanding—into their applications.
Bing APIs
Cognitive Services, as a suite, also includes
various Bing APIs that can be used in your applications:
o Bing Web Search API provides an experience similar to Bing.com/search by returning search
results that Bing determines are relevant to a user's query. The results include Web pages and
may also include images, videos, and more.
o Bing Image Search API provides an experience similar to Bing.com/images by returning images
that Bing determines are relevant to a user's query.
• Bing Autosuggest
o Bing Autosuggest API lets you send a partial search query term to Bing and get back a list of
suggested queries that other users have searched on. For example, as the user enters each
character of their search term, you'd call this API and populate the search box's drop-down list
with the suggested query strings.
MCT USE ONLY. STUDENT USE PROHIBITED
3-16 Hosting Web Applications on the Azure Platform
QnA Maker
Microsoft QnA Maker is a REST API and web-based service that trains AI to respond to user's questions in
a more natural, conversational way. QnA Maker provides a graphical user interface that allows non-
developers to train, manage, and use the service for a wide range of solutions.
QnA Maker extracts a knowledge base from two types of input: FAQ pages and product manuals. The tool
supports extraction from FAQ web pages or documents in the question-answer format. The tool can also
extra QnA pairs from PDF-format product manuals.
Once extracted, the QnA Maker service creates a knowledge base and bot using the knowledge base. The
bot can then be used, via a REST API, in any existing web application or website to answer questions for
users. Over time, the knowledge base can be updated, retrained, and republished to meet the morphing
needs to a user-facing web application.
Prebuilt domain models include all these pieces for you and are a great way to start using LUIS quickly.
After the model is designed, trained, and published, it is ready to receive and process utterances. The LUIS
app receives the utterance as an HTTP request and responds with extracted user intentions. Your client
application sends the utterance and receives LUIS's evaluation as a JSON object. Your client app can then
take appropriate action.
Bot Services
Bot Service provides an integrated environment
that is purpose-built for bot development,
enabling you to build, connect, test, deploy, and
manage intelligent bots, all from one place. Bot
Service leverages the Bot Builder SDK with
support for .NET and Node.js. You can write a
bot, connect, test, deploy, and manage it from
your web browser with no separate editor or
source control required. For simple bots, you may
not need to write code at all. Bot Service
accelerates bot development with Five bot
templates you can choose from when you create
a bot. You can further modify your bot directly in the browser using the Azure editor or in an Integrated
Development Environment (IDE), such as Visual Studio and Visual Studio Code.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-17
o Bot Service leverages Bot Builder with support for .NET and Node.js.
• Bot templates
o Bot Service templates allow you to quickly create a bot with the code and features you need.
Choose from a Basic bot, a Forms bot for collecting user input, a Language understanding bot
that leverages LUIS to understand user intent, a QnA bot to handle FAQs, or a Proactive bot that
alerts users of events.
o Bots support NuGet and NPM, so you can use your favorite packages in your bot.
• Flexible development
o Code your bot right in the Azure portal or set up continuous integration and deploy your bot
through GitHub, Visual Studio Team Services, and other supported development tools. You can
also publish from Visual Studio.
• Connect to channels
o Bot Service supports several popular channels for connecting your bots and the people that use
them. Users can start conversations with your bot on any channel that you've configured your
bot to work with, including Skype, Facebook, Teams, Slack, SMS, and several others.
• Open source
API Management
API Management (APIM) helps organizations
publish APIs to external, partner, and internal
developers to unlock the potential of their data
and services. Businesses everywhere are looking
to extend their operations as a digital platform,
creating new channels, finding new customers
and driving deeper engagement with existing
ones. API Management provides the core
competencies to ensure a successful API program
through developer engagement, business
insights, analytics, security, and protection. You
can use Azure API Management to take any
backend and launch a full-fledged API program based on it.
MCT USE ONLY. STUDENT USE PROHIBITED
3-18 Hosting Web Applications on the Azure Platform
To use API Management, administrators create APIs. Each API consists of one or more operations, and
each API can be added to one or more products. To use an API, developers subscribe to a product that
contains that API, and then they can call the API's operation, subject to any usage policies that may be in
effect. Common scenarios include:
• Securing mobile infrastructure: by gating access with API keys, preventing DOS attacks by using
throttling, or using advanced security policies like JWT token validation.
• Enabling ISV partner ecosystems: by offering fast partner onboarding through the developer portal
and building an API facade to decouple from internal implementations that are not ripe for partner
consumption.
• Running an internal API program: by offering a centralized location for the organization to
communicate about the availability and latest changes to APIs, gating access based on organizational
accounts, all based on a secured channel between the API gateway and the backend.
• The Azure portal is the administrative interface where you set up your API program. Use it to:
o Manage users.
• The Developer portal serves as the main web presence for developers, where they can:
Developer Portal
The developer portal is where developers can learn about your APIs, view and call operations, and
subscribe to products. Prospective customers can visit the developer portal, view APIs and operations, and
sign up. The URL for your developer portal is located on the dashboard in the Azure portal for your API
Management service instance.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-19
Products
Products are how APIs are surfaced to developers. Products in API Management have one or more APIs,
and are configured with a title, description, and terms of use. Products can be Open or Protected.
Protected products must be subscribed to before they can be used, while open products can be used
without a subscription. When a product is ready for use by developers, it can be published. Once it is
published, it can be viewed (and in the case of protected products subscribed to) by developers.
Subscription approval is configured at the product level and can either require administrator approval, or
be auto-approved.
Policies
Policies are a powerful capability of API Management that allow the Azure portal to change the behavior
of the API through configuration. Policies are a collection of statements that are executed sequentially on
the request or response of an API. Popular statements include format conversion from XML to JSON and
call rate limiting to restrict the number of incoming calls from a developer, and many other policies are
available.
MCT USE ONLY. STUDENT USE PROHIBITED
3-20 Hosting Web Applications on the Azure Platform
Lesson 6
Lab Overview
This lesson provides a high-level overview of the Contoso Events web application. In this lesson, you will
see a demonstration of the Administration web application and the public-facing web front end of the
Contoso Events web application.
Lesson Objectives
After completing this lesson, you will have an understanding of how the Contoso.Events web solution
works.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 3-21
In this lab, you will create a Web App, deploy your existing application, and then configure the Web App
after deployment.
Objectives
After you complete this lab, you will be able to:
• Create a Web App.
Lab Setup
Estimated Time: 60 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Statement Answer
Best Practice
To deploy applications in an on-premises environment, you can follow the same process that is used to
publish a web application to Azure by using Web Deploy. Web Deploy can be used to decouple
developers from the release process. It provides a single package that can be used by an administrator to
deploy the application in the production environment.
Review Questions
Question: What are some of the business scenarios where you can scale your Web App on a
schedule?
Question: Why would you want to store logs in a central location for multiple Web App
instances?
Question: Why would you consider leaving log files on the file system for a Web App
instance?
MCT USE ONLY. STUDENT USE PROHIBITED
4-1
Module 4
Storing SQL Data in Azure
Contents:
Module Overview 4-1
Lesson 1: Azure SQL Database Overview 4-2
Module Overview
Dynamic web applications must store the data that is being managed and manipulated by end users.
ASP.NET technologies such as ADO.NET and Entity Framework provide a way for accessing data in SQL
Server. In the cloud, the Microsoft Azure platform provides a database as a service offering that allows
developers to use SQL in the same way as they would in an on-premises location. Lesson 1, “Azure SQL
Database Overview,” describes the Azure SQL Database service and reasons you would consider using it.
Lesson 2, “Managing SQL Databases in Azure,” describes the familiar and new management tools that are
available for use with a SQL database that is hosted in Azure. Lesson 3, “Azure SQL Database Tools,”
describes the SQL Server Data Tools (SSDT) templates, panes, and projects that are available in Microsoft
Visual Studio 2013. Lesson 4, “Securing and Recovering an Azure SQL Database Instance,” describes the
recovery scenarios relevant in Azure SQL Database. Lesson 5, “Azure Database for MySQL and
PostgreSQL,” introduces the two managed database options for PostgreSQL and MySQL hosting.
Objectives
After completing this module, you will be able to:
• Explain some of the advantages and disadvantages of hosting databases in Azure SQL Database.
• Explain some of the advantages and disadvantages of hosting databases in a SQL Server installation
on a virtual machine in Azure.
• Describe the tools that you can use to manage Azure SQL Database.
Lesson 1
Azure SQL Database Overview
SQL Database provides a database-as-a-service offering that allows you to take advantage of many
features that are familiar to developers and administrators who worked with SQL Server. SQL Database
exposes a tabular data stream (TDS) endpoint so that you can use many of your existing tools to connect
to and manage your SQL Database instance.
This lesson describes the SQL Database service, some of the advantages of using this service, and some of
the considerations for selecting between the SQL Database service and SQL Server on a virtual machine in
Azure.
Lesson Objectives
After completing this lesson, you will be able to:
• Explain the advantages of using SQL Server that is installed on a Virtual Machine in Azure.
Predictable Performance
By using a consistent unit of measurement, such
as Database Throughput Units, you can compare
the expected service level for each performance
tier that is offered in the SQL Database service.
Consistent and predictable performance allows
you to select a tier that very closely matches your
application’s real-world utilization.
High Compatibility
A Tabular Data Stream (TDS) endpoint is provided for each logical server that is created in the SQL
Database service. You can use existing SQL client applications and tools with SQL Database by using the
TDS protocol.
Simple Management
Additional tools are available in Azure to manage databases that are created by SQL Database. A portal
for managing database objects is available in the Azure Management Portal, which you can access by
clicking the Manage button. You also can manage SQL Database instances by using the portals, REST API,
Windows PowerShell, or the cross-platform command-line interface (Xplat CLI).
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 4-3
• Premium: Designed for applications that require large quantities of transactions at volume. These
databases support a large quantity of concurrent connections and parallel operations.
These tiers are further separated into performance levels. Performance levels are very specific categories
within a service tier that provides a specific level of service. For example, the P1 performance level in the
Premium tier offers a maximum database size of 500 gigabyte (GB) and a benchmarked transaction rate
of 105 transactions per second.
B 5 2 GB 7 Days
S0 10 250 GB 14 Days
S1 20 250 GB 14 Days
S2 50 250 GB 14 Days
• The databases that are stored in SQL Database are constrained by size. Solutions such as Elastic Scale
are available to scale databases across multiple instances of different tiers.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 4-5
• If you want to enable a resilient scenario for your data, you have to manually configure SQL Server
AlwaysOn.
One of the most common reasons for hosting SQL Server standalone in Azure is for lift and shift scenarios.
Lift and shift workloads are applications that are migrated from one platform to another with minimum
changes to the application’s source code or configuration. Migrating an existing SQL workload to Azure
IaaS is much easier to accomplish than migrating your application to SQL Database. After you migrate,
you can analyze your existing SQL workload and determine the degree of compatibility with SQL
Database. For new (greenfield) applications, SQL Database provides a near-zero maintenance experience
that can accelerate the time to market for the newly created applications.
Reference Link:
https://docs.microsoft.com/azure/sql-database/sql-database-paas-vs-sql-server-iaas
MCT USE ONLY. STUDENT USE PROHIBITED
4-6 Storing SQL Data in Azure
Lesson 2
Managing SQL Databases in Azure
The Management Portal provides convenient ways to create and manage databases. There is also a
unique portal that you can use to manage the tables, views, and other objects for your SQL database.
This lesson lists the various online management tools that are available for interacting with SQL databases
in Azure.
Lesson Objectives
After completing this lesson, you will be able to:
You also can create databases by using through the Management Portal. When you create a database,
you can place it in an existing server or create a new server:
Lesson 3
Azure SQL Database Tools
One of the advantages of SQL databases in Azure is the ability to use many monitoring tools that you use
for on-premises databases.
This lesson describes the existing management tools and how you can use them to manage SQL
databases in Azure.
Lesson Objectives
After completing this lesson, you will be able to:
• Manage your SQL Database instances by using SQL Server Management Studio.
Setup
When you configure your SQL Database server instance, you are required to specify a user name and
password. This login is the server-level principle for your SQL Database server. The login is similar to the
sa principal in SQL Server Standalone. At any time, you can use the master database that is created with
your server to manage logins and roles for your databases. You can create additional logins by using
standard T-SQL queries.
You can use the CREATE LOGIN, ALTER LOGIN, or DROP LOGIN statements to manage logins in SQL
Database.
Managing Logins
CREATE LOGIN login1 WITH password='<ProvidePassword>';
After you configure your server, you must also configure the following access rules:
• Firewall. You can configure the firewall to allow access to your SQL database from a pre-defined list
of IP address ranges. Any IP address that is not included in these ranges will not be able to connect to
the TDS endpoint.
• Azure Service Access. You can configure a Boolean configuration option to indicate whether other
Azure services can access the TDS endpoint of your SQL database.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 4-11
Visual Studio
Visual Studio provides several ways to manage SQL Server standalone and SQL Database instances. You
can use the Server Explorer pane to connect to and manage a SQL database. You also can use the Server
Explorer pane to manage various Azure services including SQL Database. You can use the SQL Server
Object Explorer to manage both individual databases and an entire server. You can use Visual Studio
database projects to design a database in a declarative way and publish the resulting script. You can
modify the options for these projects so that the script that is generated is compatible with the SQL
Database service.
Migration Tools
• The application package also contains the data that is stored in the different database objects.
Lesson 4
Securing and Recovering an Azure SQL Database Instance
Both SQL Server standalone and SQL Database offer a comprehensive set of replication and disaster
recovery options.
This lesson describes the high availability features for both SQL Server standalone and SQL as a Service in
Azure.
Lesson Objectives
After completing this lesson, you will be able to:
Point-in-time Any restore point within Any restore point within Any restore point
restore the past seven days the past 14 days within the past 35
days
Geo-restore Maximum downtime < Maximum downtime < Maximum downtime <
24 hours 24 hours 24 hours
Standard geo- Not included Maximum downtime < Maximum downtime <
replication 2 hours 2 hours
There are three primary recovery options available for SQL Database.
Point-in-Time Restore
Point-in-time restore returns your database and its data to an earlier point in time. The tier of your
database determines how far back you can restore your database.
Database Copy
The database copy feature creates a one-time copy of your database to a new instance in another
datacenter. When the operation is complete, the duplicate database is transactionally consistent with the
source database. Further transactions against the source database are not copied.
MCT USE ONLY. STUDENT USE PROHIBITED
4-14 Storing SQL Data in Azure
Geo-Restore
Geo-restore behaves in a similar manner to point-in-time restore. The primary difference is that geo-
restore replicates the database to a datacenter in another region. Geo-restore is typically used when there
is an outage in a specific Azure region.
Standard Geo-Replication
Geo-replication automates the failover of you primary SQL Database instance to another region. The
replica created is not available and cannot accept queries or incoming connections using the TDS
endpoint. All transactions to your primary database are replicated to the secondary in an asynchronous
manner. In the event of an outage, the primary database is flagged as having degraded service. You can
then use automation or application logic to connect to your secondary database.
Active Geo-replication
Out-of-the-box, active geo-replication offers the same functionality as standard geo-replication for a
simple failover scenario. Active geo-replication goes even further and can maintain up to four copies of
your database that are replicated in a synchronous (continuous) manner. The secondary databases are
readable so that your data is still available in an uninterrupted manner while you conduct your failover
orchestration.
Reference Link:
https://docs.microsoft.com/azure/sql-database/sql-database-geo-replication-overview
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 4-15
Lesson 5
Additional Managed Database Services
This lesson introduces the Azure Database services for MySQL and PostgreSQL and then compares the
database services to the previously introduced Azure SQL Database service.
Lesson Objectives
After completing this lesson, you will be able to:
These capabilities require almost no administration and all are provided at no additional cost. They allow
you to focus on rapid app development and accelerating your time to market rather than allocating
precious time and resources to managing virtual machines and infrastructure. In addition, you can
continue to develop your application with the open source tools and platform of your choice to deliver
with the speed and efficiency your business demands, all without having to learn new skills.
A list of drivers that have been tested and found to be compatible with Azure Database for MySQL 5.6
and 5.7 is provided below:
• PHP Driver >= 5.5
• Navicat >= 12
• PHPMyAdmin >= 4.x
PostgreSQL Extensions
PostgreSQL provides the ability to extend the functionality of your database using extensions. Extensions
allow for bundling multiple related SQL objects together in a single package that can be loaded or
removed from your database with a single command. After being loaded in the database, extensions can
function as do built-in features.
PostgreSQL extensions must be installed in your database before you can use them. To install a particular
extension, run the CREATE EXTENSION command from psql tool to load the packaged objects into your
database. Azure Database for PostgreSQL currently supports a subset of key extensions as listed below:
• chkpass
• citext
• cube
• hstore
• isn
• ltree
• earthdistance
• fuzzystrmatch
• intarray
• pgcrypto
• pg_partman
• pg_trgm
• tablefunc
• uuid-ossp
• dict_int
• unaccent
• btree_gin
• btree_gist
• plpgsql
• pg_buffercache
• pg_prewarm
• pg_stat_statements
• pgrowlocks
• pgstattuple
• postgres_fdw
• PostGIS
• postgis_topology
• postgis_tiger_geocoder
• postgis_sfcgal
MCT USE ONLY. STUDENT USE PROHIBITED
4-18 Storing SQL Data in Azure
• address_standardizer
• address_standardizer_data_us
• pgrouting
Extensions beyond the ones listed are not supported. You cannot create your own extension with Azure
Database for PostgreSQL service.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 4-19
Objectives
After you complete this lab, you will be able to:
• Create an Azure SQL Database server and a database instance by using the Management Portal.
• Use Entity Framework Code First to initialize and seed a database in the cloud.
Lab Setup
Estimated Time: 45 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
SQL Database provides a service offering for relational databases. It is built to provide the highest level of
compatibility with the existing management tools and SSDT in Visual Studio 2013. By using Entity
Framework, you can write your code once and rely on the configuration changes to point your ORM to
the right database depending on your environment.
Best Practice
You can use configuration settings and web.config transformations to point your application to a different
database depending upon the build definition or environment. This allows you to automate your build
and test processes with the least amount of code customizations for each environment.
Review Question
Question: When you implement database sharding, why is the federation distribution key
important? How does this key help drive performance?
MCT USE ONLY. STUDENT USE PROHIBITED
5-1
Module 5
Designing Cloud Applications for Resiliency
Contents:
Module Overview 5-1
Lesson 1: Application Design Practices for Highly Available Applications 5-2
Module Overview
As a developer, you should keep in mind certain considerations while designing applications for the cloud.
Although there are many platform improvements available in the ASP.NET ecosystem, you need |to
rethink the way you design your applications, and the patterns that are used, with respect to the
scalability and reliability metrics present for the cloud applications. Lesson 1, “Application Design Practices
for Highly Available Applications,” discusses some of the considerations that are needed
when you design applications that are hosted in the cloud such that they result in minimal downtime.
Lesson 2, “Application Analytics,” demonstrates the Application Insights service. Lesson 3, “Building High-
Performance Applications by Using ASP.NET,” describes the changes in the ASP.NET stack in .NET 4.5 that
improve the framework’s performance in web applications. Lesson 4, “Common Cloud Application
Patterns,” introduces a small set of example patterns from the MSDN cloud patterns reference. Lesson 5,
“Caching Application Data,” compares the Microsoft Azure Cache and Microsoft Azure Redis Cache
services.
Objectives
After completing this module, you will be able to:
• Describe the Valet Key, Retry and Transient Fault Handling Patterns.
Lesson 1
Application Design Practices for Highly Available
Applications
This lesson describes some of the common considerations that are needed for designing highly available
applications.
Lesson Objectives
After completing this lesson, you will be able to:
Partitioning Workloads
A modular application is divided into functional
units, also referred to as modules, which can be
integrated into a larger application. Each module
handles a portion of the application's overall
functionality and represents a set of related
concerns. Modular applications make it easier to
design both current and future iterations of your
application. Existing modules can be extended,
revised or replaced to iterate changes to your full
application. Modules can also be tested,
distributed and otherwise verified in isolation.
Modular design benefits are well understood by
many developers and architects in the software industry.
Load Balancing
Load balancing is a computing concept where
the application traffic or load is distributed
among various endpoints by using algorithms. By
using a load balancer, multiple instances of your
website can be created and they can behave in a
predictable manner. This provides the flexibility
to grow or shrink the number of instances in
your application without changing the expected
behavior.
Load-Balancing Strategy
After you select a specific load balancer you need to select a load balancing algorithm. You can use
various algorithms such as round robin or random choice. For example, round robin selects the next
instance for each request based upon a predetermined order that includes all of the instances.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 5-3
Other configuration options exist for load balancers such as affinity or stickiness. For example, stickiness
allows you determine whether a subsequent request from the same client machine should be routed to
the same service instance. This might be required in scenarios where your application servers have a
concept of state.
Queues
Queueing is both a mathematical theory and also
a messaging concept in computer science. In
cloud applications, queues are critical for
managing requests between application modules
in a manner such that it provides a degree of
consistency regardless of the
behavior of the modules.
Lesson 2
Application Analytics
Analytics software allow developers and operations the ability to explore the usage and behavior of their
web application. With cloud applications, using analytics becomes more important because you have to
make scaling and design decisions per iteration.
Lesson Objectives
After completing this lesson, you will be able to:
• Integrate the Application Insights scripts and assemblies with an ASP.NET project to monitor the web
application.
Application Insights
Application Insights is not just a monitoring
platform but also a set of application extensions
that allows you to expose enhanced telemetry for
your custom applications. To use Application
Insights, you need to add the telemetry
application extensions to your existing or new
application and then associate the application
with an Application Insights instance through
configuration. This gives you the flexibility to add
telemetry to your existing apps without having to
rewrite, or possibly redeploy, your application.
Application Insights is also flexible enough to
expose telemetry for those applications that are not hosted in Azure.
At its most basic level, you can use Application Insights to ensure that your application has the intended
amount of uptime. You can use a custom dashboard to view various metrics about your application.
You can use advanced metrics to determine long-term application behavior and from this behavior
analysis you can parse specific performance or application issues. Finally, Application Insights can also give
you an insight into the happy path for end users. This insight can be gathered by viewing usage telemetry
by page or client browser. You can use the insight to determine which areas of your application are
conducive for future development investment.
Note: To view the latest demo steps, visit the GitHub repository for the course.
Before starting this demo, you must complete the lab in Module 2. For this demo in this module, you will
use the available host machine. Also, you must complete the following steps:
1. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
2. In Remote Desktop Connection, provide the name of your virtual machine in the Computer box by
using the following format:
Note: The name and port for your virtual machine might be saved in the Computer drop-
down list. If this is the case, use this value instead of typing it in manually. If you are unsure about
your virtual machine’s RDP port, use either of the Azure portals to find your virtual machine’s
endpoints. The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your virtual machine from unauthorized access.
3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
o Password: AzurePa$$w0rd
Verify that you received the credentials to sign in to the Azure portal from your training provider. You will
use these credentials and the Azure account throughout the labs in this course.
MCT USE ONLY. STUDENT USE PROHIBITED
5-6 Designing Cloud Applications for Resiliency
Lesson 3
Building High-Performance Applications
by Using ASP.NET
The ASP.NET 4.5 release contained many improvements to the platform that help when building high-
performance applications both on premise and in the cloud.
This lesson describes the improvements to ASP.NET for high-performance web applications.
Lesson Objectives
After completing this lesson, you will be able to:
Similar to how the Windows startup moved from single-core to multi-core, JIT compilation for ASP.NET
web applications too moved from single-core to multi-core. Modern machines tend to use more
processors with less CPU speed per processor which could theoretically slow down JIT compilation. Multi-
core JIT compilation is enabled by default and spreads the compilation across all available processor
cores.
Prefetching for web applications
Windows prefetcher reduces the startup time for your most commonly used desktop applications by
preloading application components before you place a request to start the client application. By using IIS,
you can enable prefetcher for ASP.NET web applications through custom configuration options.
The advantage with the keywords is that they offer more readable code that can easily be parsed by other
developers. Traditional asynchronous applications are in general hard to understand, debug, and modify.
Typically, you would need large workflow diagrams to understand asynchronous applications developed
before the Task Parallel Library and async and await keywords were introduced. The compiler does the
translation from these keywords to their task equivalents.
State Management
ASP.NET provides a variety of state options that
should be considered when developing your
cloud application.
Client-Based State
Application or session state is typically hosted in-process for an ASP.NET application. In the cloud, this
becomes a problem because the load balancer might send you to a new application instance that might
not have the in-process session values. For example, assume that you have three application instances but
have signed in using the first. The load balancer might send you to the second application instance which
will not have any state information related to your sign-in. If you require a traditional ASP.NET server state
management then consider using a shared state server.
Lesson 4
Common Cloud Application Patterns
Although there are many application patterns, some application patterns have emerged with a new
generation of cloud-native web applications. MSDN includes a curated list of some of the most common
cloud application patterns.
This lesson describes in detail the three examples of the curated cloud application patterns.
Lesson Objectives
After completing this lesson, you will be able to:
These faults are typically self-correcting, and if the action that triggered a fault is repeated after a suitable
delay it is likely to be successful. For example, a database service that is processing a large number of
concurrent requests may implement a throttling strategy that temporarily rejects any further requests
until its workload has eased. An application attempting to access the database may fail to connect, but if
it tries again after a suitable delay it may succeed.
Solution: Application Logic to Retry Requests That Have Temporarily Failed
In the cloud, transient faults are not uncommon and an application should be designed to handle them
elegantly and transparently, minimizing the effects that such faults might have on the business tasks that
the application is performing.
If an application detects a failure when it attempts to send a request to a remote service, it can handle the
failure by retrying the application logic after a short wait. For the more common transient failures,
the period between retries should be chosen so as to spread requests from multiple instances of the
application as evenly as possible. This can reduce the chance of a busy service continuing to be
overloaded. If many instances of an application are continually bombarding a service with retry
requests, it may take the service longer to recover.
If the request still fails, the application can wait again and make another attempt. There should be a limit
on attempts to avoid sending endless requests to a service that may actually be completely inoperable. All
code that access the remote service should be implemented using a retry policy such as the one described
here.
Data stores have the capability to handle upload and download of data directly, without requiring the
application to perform any processing to move this data, but this typically requires the client to have
access to the security credentials for the store. While this can be a useful technique to minimize data
transfer costs and the requirement to scale out the application, and to maximize performance, it means
that the application is no longer able to manage the security of the data. Once the client has a connection
to the data store for direct access, the application cannot act as the gatekeeper. It is no longer in control
of the process and cannot prevent subsequent uploads or downloads from the data store.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 5-11
This is not a realistic approach in modern distributed systems that may need to serve untrusted clients.
Instead, applications must be able to securely control access to data in a granular way, but still reduce the
load on the server by setting up this connection and then allowing the client to communicate directly with
the data store to perform the required read or write operations.
This key or token is usually referred to as a valet key. It provides time-limited access to specific resources
and allows only predefined operations such as reading and writing to storage or queues, or uploading
and downloading in a web browser. Applications can create and issue valet keys to client devices and web
browsers quickly and easily, allowing clients to perform the required operations without requiring the
application to directly handle the data transfer. This removes the processing overhead, and the
consequent impact on performance and scalability, from the application and the server.
The client uses this token to access a specific resource in the data store for only a specific period, and with
specific restrictions on access permissions.
Sharding Pattern
Problem: Hosting Large Volumes of Data in a
Traditional Single-Instance Store
• Computing resources. A cloud application may be required to support a large number of concurrent
users, each of which run queries that retrieve information from the data store. A single server hosting
the data store may not be able to provide the necessary computing power to support this load,
resulting in extended response times for users and frequent failures as applications attempting to
store and retrieve data time out. It may be possible to add memory or upgrade processors, but the
system will reach a limit when it is not possible to increase the compute resources any further.
• Network bandwidth. Ultimately, the performance of a data store running on a single server is
governed by the rate at which the server can receive requests and send replies. It is possible that
the volume of network traffic might exceed the capacity of the network used to connect to the server,
resulting in failed requests.
• Geography. It may be necessary to store data generated by specific users in the same region as those
users for legal, compliance, or performance reasons, or to reduce latency of data access. If the users
are dispersed across different countries or regions, it may not be possible to store the entire data for
the application in a single data store.
Scaling vertically by adding more disk capacity, processing power, memory, and network connections may
postpone the effects of some of these limitations, but it is likely to be only a temporary solution.
A commercial cloud application capable of supporting large numbers of users and high volumes of data
must be able to scale almost indefinitely, so vertical scaling is not necessarily the best solution.
Abstracting the physical location of the data in the sharding logic provides a high level of control over
which shards contain which data, and enables data to migrate between shards without reworking the
business logic of an application should the data in the shards need to be redistributed later (for example,
if the shards become unbalanced). The tradeoff is the additional data access overhead required in
determining the location of each data item as it is retrieved.
To ensure optimal performance and scalability, it is important to split the data in a way that is appropriate
for the types of queries the application performs. In many cases, it is unlikely that the sharding scheme will
exactly match the requirements of every query. For example, in a multi-tenant system an application may
need to retrieve tenant data by using the tenant ID, but it may also need to look up this data based on
some other attribute such as the tenant’s name or location. To handle these situations, implement a
sharding strategy with a shard key that supports the most commonly performed queries.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 5-13
Using a single instance of the consumer service might cause that instance to become flooded with
requests or the messaging system may be overloaded by an influx of messages coming from the
application.
Solution: Asynchronous Messaging with Variable Quantities of Message Producers and Consumers
Rather than process each request synchronously, a common technique is for the application to
pass them through a messaging system to another service (a consumer service) that handles them
asynchronously. This strategy helps to ensure that the business logic in the application is not blocked
while the requests are being processed.
A message queue can be used to implement the communication channel between the application and the
instances of the consumer service. To handle fluctuating workloads, the system can run multiple instances
of the consumer service. The application posts requests in the form of messages to the queue, and the
consumer service instances receive messages from the queue and process them. This approach enables
the same pool of consumer service instances to handle messages from any instance of the application.
Cache-Aside Pattern
Problem: Cached Data Consistency
Applications use a cache to optimize repeated
access to information held in a data store.
However, it is usually impractical to expect that
cached data will always be completely consistent
with the data in the data store. Applications
developers should consider a strategy that helps
to ensure that the data in the cache is up to date
as far as possible, but can also detect and handle
situations that arise when the data in the cache
has become stale.
For caches that do not provide this functionality, it is the responsibility of the applications that use the
cache to maintain the data in the cache. An application can emulate the functionality of read-through
caching by implementing the cache-aside strategy. This strategy effectively loads data into the cache on
demand if it's not already available in the cache.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 5-15
Lesson 5
Caching Application Data
Azure provides two primary cache mechanisms that help you store consistent data that can be shared by
your application’s services. Although Redis Cache is now the preferred cache mechanism, it is important to
understand Azure Cache because it pertains to existing cloud applications.
This lesson describes the two cache offerings in Azure, Azure Cache and Redis Cache.
Lesson Objectives
After completing this lesson, you will be able to:
Redis Cache
There are two primary cache mechanisms
available in Azure, Azure Cache and Redis Cache.
Azure cache is deprecated and only exists to
support existing cloud applications. All new
applications should use the Redis Cache.
Redis Cache is an open-source NoSQL storage mechanism that is implemented in the key-value pair
pattern common among other NoSQL stores. Redis Cache is unique because it allows complex data
structures for its keys.
Azure Redis Cache is a managed service based on Redis Cache that provides you secure nodes as a
service. There are only two tiers for this service currently available:
Azure Redis Cache provides a high degree of compatibility with existing tools and applications that
already integrate with Redis Cache. You can use the Redis Cache documentation that already exists on the
open source community for Azure Redis Cache.
Review Questions
Question: Why would you want a periodic check or heartbeat of your Azure Website’s
availability across geographic regions?
Question: How could you implement the Valet Key pattern by using Azure services?
MCT USE ONLY. STUDENT USE PROHIBITED
6-1
Module 6
Storing Unstructured Data in Azure
Contents:
Module Overview 6-1
Lesson 1: Azure Storage Overview 6-2
Module Overview
Many new application workloads require new databases that offer scale and flexibility far beyond the
capabilities of a traditional relational database. In Azure, there is a wide variety of NoSQL database
services available for applications to store unstructured data in a flexible, schema-free and scalable
fashion. Lesson 1, “Azure Storage Overview,” introduces the Azure Storage service and details some of the
storage types available to applications using Azure Storage. Lesson 2, “Azure Storage Tables,” details the
Table key-value store available as a NoSQL database in Azure Storage. Lesson 3, “Azure Redis Cache,”
introduces the Redis Cache key-value based NoSQL store and details how it can be used as a cache
database. Lesson 4, “Azure Search,” describes the Azure Search service offering that indexes and provides
rich-search capabilities for documents stored in structured and unstructured storage. Lesson 5, “Azure
Cosmos DB,” explores the Azure Cosmos DB service as a flexible NoSQL database that supports a large
variety of APIs and models.
Objectives
After completing this module, you will be able to:
Lesson 1
Azure Storage Overview
Microsoft Azure Storage enables you to store unstructured data, files, and messages. You can use Storage
as a shared resource to your cloud applications and the various instances of each service.
Lesson Objectives
After completing this lesson, you will be able to:
Azure Storage
With cloud computing, flexible infrastructure
is now available for applications that were
designed with infrastructure, resilience and
scalability in mind. Cloud Services automatically
handle the load balancing and infrastructure
creation (spin-up) when you wish to scale your
application up or down. DocumentDB partitions
your data across multiple nodes automatically to
grow to handle the amount of data you wish to
store.
Types of Storage
The Storage service consists of four primary types
of storage. Each of these are available at unique
endpoints as listed below:
http://[account].blob.core.windows.net/[container]/[blob]
http://[account].queue.core.windows.net/[queue]
http://[account].file.core.windows.net/[file]
Blob
Storage blobs provide a way to store files so that they can be consumed by other components of your
application or client devices. These blobs represent files and can be protected such that tokens are
required to access the blob.
Table
The Table service is a NoSQL store that is based on the document paradigm. Each entity consists of a
partition key and a row key that together form a unique index. The entities then contain a collection of
key-value pairs for the document’s attributes.
File
File is a service that publishes a Server Message Block (SMB) 2.1 endpoint. This endpoint can be used by
virtual machines in Azure in the same way as a shared drive.
Queue
Storage queues are externally managed queues that can persist requests to be consumed by modules in
your application. The queue is implemented in a traditional first in, first out (FIFO) pattern. These queues
can be measured and requests can also be reviewed (peek) without removing them from the queue.
MCT USE ONLY. STUDENT USE PROHIBITED
6-4 Storing Unstructured Data in Azure
Note: Some regions only contain one datacenter. In such a scenario, ZRS replicates your
data to another datacenter in a different region. For example, in 2014 the Brazil region contained
a single datacenter. ZRS replicated data to a Texas, US datacenter. This provided an upgrade to
GRS replication without any increase in the cost. However, you need to be careful while using this
option because this can have compliance implications.
Although you can access storage data directly by using the URI, you can individually restrict access or
modification, by anonymous users, to the containers and blobs.
Sample application diagram using the Valet Key pattern with Azure Storage:
Lesson 2
Azure Storage Tables
The Table service provides a nonrelational database option for storage in Azure. It is tuned to scale to
large number of entities and even numerous operations per second. Simply put, the Table service is built
with scalability in mind.
This lesson introduces the Table service and describes why it is unique.
Lesson Objectives
After completing this lesson, you will be able to:
Storage Tables
The Table service provides a NoSQL data storage
mechanism to store loosely structured data in a
table that you can partition by using a unique
partition key. The ideal candidate for Table
storage is rarely-modified or immutable data that
needs to be stored at a very large scale and
accessed very quickly. With traditional relational
database management systems, massive data
storage is possible but queries are expensive. If
you want to access a single item in a table, then
you will need a query and this might end up
being exponentially more expensive as the size of
the table grows. If you use a document-based NoSQL system, such as the Table service, then the problem
is solved because it uses a variety of methods including an index and a hash to access a single record in a
table. This is how data can be stored at massive volumes while maintaining consistently fast access to
specific records.
In the context of the Table service, tables are sets of entities that are related but do not necessarily share
the same schema. Each table has a sharding implementation (called partitions) where data in the same
partition will be on the same server. This means that data in the same partition can be accessed very
quickly while the data across partitions typically is accessed much slower. The logical structure for Table
storage is as follows:
Storage Account
TableI
ParititonA
Entity1
Entity2
Entity3
MCT USE ONLY. STUDENT USE PROHIBITED
6-8 Storing Unstructured Data in Azure
PartitionB
Entity4
PartitionC
Entity5
Entity6
TableII
PartitionD
Entity7
Throughout this lesson, you will explore the structure of Table storage.
Please refer to Module 5, Designing Cloud Applications for Resiliency for more information about
sharding design and principles.
Note: To view the latest demo steps, visit the GitHub repository for the course.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 6-9
Before starting this demo, you must complete the lab in Module 2. For this demo in this module, you will
use the available host machine. Also, you must complete the following steps:
1. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
2. In Remote Desktop Connection, provide the name of your virtual machine in the Computer box by
using the following format:
Note: The name and port for your virtual machine might be saved in the Computer drop-
down list. If this is the case, use this value instead of typing it in manually. If you are unsure about
your virtual machine’s RDP port, use either of the Azure portals to find your virtual machine’s
endpoints. The endpoint with the name Remote Desktop is the correct port for
RDP. This port is randomized to protect your virtual machine from unauthorized access.
3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
o Password: AzurePa$$w0rd
Verify that you received the credentials to sign in to the Azure portal from your training provider. You will
use these credentials and the Azure account throughout the labs in this course.
Common Transactions
Although Azure Storage Tables is ideal for data
that is not often updated, a full range of CRUD
operations are available for Storage table
endpoints. You can use the existing client
libraries or the REST API endpoints using
standard HTTP methods. Querying a table
consists of using the HTTP GET method with
the OData syntax.
QUERY https://[account].table.core.windows.net/[table]()?$filter=[query
expression]
POST https://[account].table.core.windows.net/[table]
When updated, entities do not lose key-value pairs that are not specified as part of the object posted.
For example, you have an entity for a student. The students are partitioned by the school they attend and
the row key is their student ID. In this particular example, the student has only the first name and last
name data.
Age 11
Assume that you need to update this user in the table named students and in a storage account named
cornfielddistrict. You also need to update the Age to 12 and add a new key-value pair for Sport. In such a
scenario, the URL and JSON payload you would use is as follows:
PUT: https://cornfielddistrict.table.core.windows.net/students(orchardmiddle,237548902)
JSON Payload
{
“Age”: 12,
“Sport”: Tennis
}
Age 12
Sport Tennis
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 6-11
OData Queries
Azure Storage tables can be accessed by using
the OData protocol. The OData protocol
provides a uniform way to query items in an
HTTP endpoint. Traditionally in a RESTful service,
the GET endpoint can return a specific item or
can return all of the items. The OData query
parameters allow you to filter, paginate, or
project the result of your request to an HTTP
endpoint. The OData protocol can also do a lot
more such as typing and batching of requests.
There are client libraries available in various
programming languages.
With Storage tables, you can use OData as an easy way to search for particular entities in a table. The
$filter, $top and $select query options are currently supported. Results can be returned in either the
AtomPub or JSON format. This is specified by including an Accept header in your request. Typically, JSON
data provides up to a 70% reduction in bandwidth.
If you require a specific entity, the OData protocol provides a mechanism where you can retrieve a single
entity in a collection by using the following URL format:
https://[base url]/[resource]([index])
Storage tables deviate from the typical OData protocol by requiring you to specify both the row and
partition keys. These form a composite index for an item in Storage tables and are both required to get a
specific entity:
https://[account].table.core.windows.net/[table](PartitionKey=’[key]’,RowKey=‘[key]’)
When using an OData client library, you should be aware that they might not account for this small
deviation. The client libraries might also support additional OData query options such as $skip and
$expand that are currently not supported by Storage tables.
MCT USE ONLY. STUDENT USE PROHIBITED
6-12 Storing Unstructured Data in Azure
OData Endpoints
Standard OData Endpoints are available for all tables stored in Storage Tables. There is a small difference
from a traditional OData key lookup. In Table Service, keys are composite and you are required to pass in
both the partition key and row key.
• Base URL:
o https://[account].table.core.windows.net
o [GET] /[table]([PartitionKey],[RowKey])
• Query a table for entities that match an expression:
• Delete an entity:
o [DELETE] /[table]([PartitionKey],[RowKey])
o [PUT] /[table]([PartitionKey],[RowKey])
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 6-13
Lesson 3
Azure Redis Cache
Redis Cache is an implementation of the Redis Database engine that is offered as a service on Azure.
Using the Redis Cache service, one could create a cache instance quickly using the key-value based store.
This lesson introduces the Redis Cache service as an option for NoSQL caching in Azure.
Lesson Objectives
After completing this lesson, you will be able to:
Redis
Redis is an in-memory key-value based data
store that can be used in a wide variety of
scenarios. Redis performs at a very high-level
using simple strings as the value for its various
keys making it optimal as a cache solution. Redis
also allows more complex data types to be stored
as the value for each key including (but not
limited to):
Cache Model
At the simplest level, you can store simple string key-value pairs in Redis cache. A key used in Redis Cache
is typically a string:
GET setting
EXISTS setting
However, a key in Redis cache is binary-safe and it can be a binary file like a Word document if you
like. This may not be ideal as it would be difficult and bandwidth-intensive to query the key. It is
recommended that you use simple strings for your keys but you can always use delimiters to indicate how
keys are related:
GET setting
GET setting:subsetting
Lua in Redis
For advanced scenarios where you want to create complex scripts, Redis has Lua available as an
embedded scripting language. You can evaluate Lua scripts using the following two techniques:
You can start by writing simple Lua scripts and saving them to .lua files. A simple script that gets the value
of the messages:welcome setting would look like this:
Ideally, you would not hard-code a string value in the script, so you would pass in the key using a Key
parameter. First, you would update your script to look like this:
Then you would pass in the messages:welcome string as a Key argument to the redis-cli tool:
Alternatively, you can evaluate a script or logic directly in the console using the EVAL command. To
evaluate our script.lua file, we would simply invoke the EVAL command in the console like this:
You may have noticed that we needed to indicate to the EVAL command how many Key arguments to
expect. We would need to do something similar if we wished to skip the script file and invoke our
command directly:
Lesson 4
Azure Search
Azure Search is a search-as-a-service cloud solution that gives developers APIs and tools for adding a rich
search experience over your content in web, mobile, and enterprise applications.
This lesson introduces Azure Search as an option for adding search functionality to an existing application.
Lesson Objectives
After completing this lesson, you will be able to:
Azure Search
Azure Search is a managed search engine
offering in Azure that allows you to index data
from various data sources and then provide a
search engine over the indexed data. Azure
Search has many features including:
• Faceted search
• Pagination
• Geospatial search
• Ranking
• Hit Highlighting
Azure Search has its own built-in query syntax but it can also make use of the Lucene query syntax when
searching documents.
One of Azure Search's core differentiators is the ability to create custom linguistic analyzers. Using this
feature, you can create analyzers to support your full-text search queries across 50+ languages.
Indexing
Before you can perform your first search, you must first create an index in Azure Search. An index means a
couple of unique things within Azure Search:
• An index is the scope used for queries over documents within Azure Search.
• Documents are uploaded, updated and managed within the context of an index.
• Indexes informs the Azure Search engine about the properties (or fields) that are available in the
indexes' documents and the capabilities that are appropriate for each document property.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 6-17
In the simple examples throughout this course we will enable all features for all index fields. In your
custom applications, you may choose to tune an index by enabling only specific features over specific
fields. Features include:
• Retrievable: This means that the field can be retrieved as the result of a search query.
• Filterable: This means that the search query can filter using this field. For example, you can filter
products which are older than 3 years.
• Sortable: This means that the results of a search query can be sorted using this field. For example,
you can enable this feature to sort using the price of a product.
• Facetable: This means that the field can be used to create grouped metadata about the results. For
example, if you enable this for the color field on your products, you will receive results metadata
indicating how many results match for each unique value for the color field.
• Searchable: This means that a text search can be performed on this field.
Queries
Search Queries can be performed on an Azure Search index using the REST API.
https://[account].search.windows.net/indexes/[index]/docs
For example, if your account name is edxdemo and the index name is products, the base URL would be:
https://edxdemo.search.windows.net/indexes/products/docs
Authentication: A api-key header is required to use the REST API. This header can be an admin or query
key. These are found in the Azure portal.
Query string parameters are used to indicate options for the search. The parameters include (but are not
limited to):
• api-version: This parameter is the first required parameter and indicates the version of the API you
would like to use for your request.
• search: This parameter is the second of the only two required parameters. This parameter indicates
the actual text-based search query. To return all documents, you can use the * (wildcard) operator.
You can either use the built-in Simple query syntax or the newer Lucene query syntax with this
parameter.
• searchMode: This parameter indicates whether or not you want to match on all words in the query or
any word in the query. By default, searches match on any words.
• facet: This parameter indicates that you would like to return faceted metadata about specific fields in
your results set. For example, you may wish to see metadata about the price ranges for all prices in
every document in your results set.
• $count: This OData parameter indicates that you would like to return a number indicating the total
number of results. By default, Azure Search will not return all results so this number is useful when
figuring out if your user interface needs to show pagination elements.
• $skip** & **$top: These OData query parameters are used to return a slice of the result set. For
example, you may have 500 results that match your query but you wish to show only 50 results at a
time. To do this, you would start on page #1 by skipping 0 results and showing the top 50 results.
When the user wants to view page #2, you can skip 50 results and show the next top 50 results. These
two parameters are commonly used to implement pagination.
• $orderby: This OData parameter sorts the result set using the specified field[s].
MCT USE ONLY. STUDENT USE PROHIBITED
6-18 Storing Unstructured Data in Azure
• $select: This OData parameter allows you to select specific fields that are returned in the result set
instead of all available fields. This is useful in scenarios where you want to minimize the amount of
unused fields that are returned.
• $filter: This OData parameter implements an OData-style filter on the results of the query. For
example, you may wish to implement a filter that returns only products that are Yellow in color. This
can be done using the Color eq 'Black' filter. OData filters are performed together with the search
query and can be used to further refine a result set after the search query has been applied.
Lesson 5
Azure Cosmos DB
Azure Cosmos DB is an Azure-native database service that focuses on providing a high-performance
database regardless of your selected API or data model. Azure Cosmos DB offers multiple APIs and
models that can be used interchangeably for various application scenarios.
Lesson Objectives
After completing this lesson, you will be able to:
Azure Cosmos DB
Azure Cosmos DB was built from the ground
up with global distribution and horizontal
scale at its core. It offers turnkey global
distribution across any number of Azure regions
by transparently scaling and replicating your data
wherever your users are. Elastically scale
throughput and storage worldwide, and pay only
for what you need. Azure Cosmos DB provides
native support for NoSQL choices, offers multiple
well-defined consistency models, guarantees
single-digit-millisecond latencies at the 99th
percentile, and guarantees high availability with
multi-homing capabilities and low latencies anywhere in the world— all backed by industry-leading,
comprehensive service level agreements (SLAs).
APIs
Today, Azure Cosmos DB can be accessed using four different APIs. These APIs will be covered as separate
modules in this course and are listed below for your convenience:
MongoDB API
Partitioning
In Cosmos DB, databases are essentially
containers for collections. Collections are where
you place individual documents. Each collection
is assigned a performance level and that
performance level dictates throughput for that
collection and its corresponding documents.
If a particular collection is seeing spikes in throughput, you can manage its performance level in isolation
by increasing or decreasing the performance level. This change to the performance level of a particular
collection will not cause side effects for the other collections. This allows you to adjust to meet the
performance needs of any workload in isolation.
You can also scale workloads across collections, if you have a workload that needs to be partitioned, you
can scale that workload by distributing its associated documents across multiple collections. The SQL API
for Cosmos DB includes a client-side Partition Resolver that allows you to manage transactions and point
them in-code to the correct partition based on a partition key field.
SQL API
The SQL API in Azure Cosmos DB is a JavaScript
and JSON native API based on the DocumentDB
database engine. The SQL API also provides
query capabilities rooted in the familiar SQL
query language. Using SQL, you can query for
documents based on their identifiers or make
deeper queries based on properties of the
document, complex objects or even the existence
of specific properties. The SQL API supports the
execution of JavaScript logic within the database
in the form of stored procedures, triggers and
user-defined functions (UDFs). JavaScript logic
can be executed in a transactional manner directly within the database engine.
Resource Hierarchy
The JSON documents stored in Azure Cosmos DB are managed through a well-defined hierarchy of
database resources. These resources are automatically replicated to ensure that they are highly available
while still allowing you to address each resource using a unique URI.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 6-21
Objectives
After you complete this lab, you will be able to:
• Use the Azure DocumentDB SDK to create a Cosmos client using the SQL API.
Lab Setup
Estimated Time: 45 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Best Practice
You can effectively use configuration settings and Web.config transformations to point your application
to a different database depending upon the build definition or environment. This enables you to
automate your build and test processes with the least amount of code customizations for each
environment.
Review Question
Question: When implementing database sharding, why is the federation distribution key
important? How does this key help drive performance?
MCT USE ONLY. STUDENT USE PROHIBITED
7-1
Module 7
Storing and Consuming Files from Azure Storage
Contents:
Module Overview 7-1
Lesson 1: Azure Storage Blobs 7-2
Module Overview
When you want to scale to different cloud instances, storing files to a local disk becomes a difficult
process to maintain and eventually an unreliable method of storage. Azure provides a Blob storage
mechanism that not only offers high performance but also supports integration to Microsoft Azure
Content Delivery Network (CDN) for low latency downloads. Lesson 1, “Azure Storage Blobs,” describes
the Blob service and the types of blobs supported. Lesson 2, “Controlling Access to Storage Blobs and
Containers,” provides details on the ways that you can secure and grant temporary access to blobs or
containers. Lesson 3, “Configuring Azure Storage Accounts,” looks at some of the unique configuration
options available for Storage blobs. Lesson 4, “Azure Files,” briefly introduces the Azure Files service.
Objectives
After completing this module, you will be able to:
• Describe the Blob service in Microsoft Azure Storage.
• Identify the software development kit (SDK) libraries, namespaces, and classes that are available
for blobs.
MCT USE ONLY. STUDENT USE PROHIBITED
7-2 Storing and Consuming Files from Azure Storage
Lesson 1
Azure Storage Blobs
Blob storage provides a file and data storage mechanism in Azure. It is designed for speed and
convenience and also supports a CDN option.
This lesson introduces the Blob service and its basic concepts.
Lesson Objectives
After completing this lesson, you will be able to:
• Explain the structure of the containers and blobs in the Blob service.
Storage Blobs
Storage blobs are a unique component of the
Storage service that allows you to store various
files needed by your applications in a reliant and
scalable manner. All stored blobs are associated
with an HTTP URL which allows these blobs to be
accessed from any location, platform or device.
The blob service was designed to store large
amounts of unstructured data or files. These files
can be exposed publicly using URLs or protected
from anonymous access using SAS tokens.
Common Uses of Blob Storage Include:
• Storage account. Storage accounts are the highest-level units of encapsulation for objects in storage.
A storage account can contain blobs, queues, tables or file shares.
• Container. A container represents a group of blobs with shared security scope. Blobs must exist in a
single container. Containers cannot be nested.
• Blob. Blobs represent individual files in a container. There are two primary types of blobs, Page and
Block blobs.
• URL format. Blobs are accessible using the following URL format:
http[s]://<storage account>.blob.core.windows.net/<container>/<blob>
You can use the following example URL to address one of the blobs in the diagram above:
http://sally.blob.core.windows.net/movies/MOV1.AVI
Blob Types
The Storage containers can contain two types of
blobs: block and page blobs. When creating the
blob, the blob type must be specified. After the
blob is created, the blob type is permanent, and
you can only update the properties and content
of the blob. For example, you can write a block
or set of blocks to a block blob or write pages to
a page blob.
Block Blobs
Block blobs are optimized for uploading large
files in an efficient manner. Block blobs are
composed of sets of blocks that are uniquely
identified using a block ID. Block blobs are modified by writing a set of blocks. The set of blocks are then
committed using a commit operation and the block IDs. After you upload one or more blocks to your
block blob, they are associated with the blob but not committed. You must then commit the set of blocks
MCT USE ONLY. STUDENT USE PROHIBITED
7-4 Storing and Consuming Files from Azure Storage
to the block blob by again using their block IDs. Uncommitted blocks can also optionally be discarded.
Block blobs are typically used for most files and multimedia.
Page Blobs
Page blobs are blobs that are composed of individual pages that are optimized for random read-write
operations. These individual pages are 512 bytes. When creating a page blob, you must specify the
maximum size for the blob. If you need more space for your file, you must create a new page blob. To
update the page blob, you must write one or more 512-byte pages. When writing the pages, an offset is
required along with a range that within the 512-byte page boundary. When updating a page blob, you
can overwrite up to 4 megabytes (MB) of pages. Page blob write operations are immediately committed
and overwrite the in-place pages. A page blob is typically used for virtual hard disks and can be up to 1
terabyte (TB).
You can provide additional query string parameters for additional metadata and functionality such as:
• Restype. Can be used directly with the container to access the container metadata or enumerate
blobs in a container
In addition to the traditional Create, Read, Update, Delete (CRUD) functionality, the metadata and
properties of a blob can be accessed by using the REST API. Finally, access policies (ACL) can be managed
by using the same REST API.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 7-5
Lesson 2
Controlling Access to Storage Blobs and Containers
Sometimes files need to be secured so that they cannot be accessed by anonymous entities. Storage blobs
contain a mechanism for securing blobs and granting temporary access by using query string tokens.
This lesson introduces the concept of blob permissions and SAS tokens.
Lesson Objectives
After completing this lesson, you will be able to:
Container Permissions
Typically, only the owner of a storage account
can access resources within that account. If your
service or application needs to make these
resources available to other clients, you have
various options available. First, you can make
the public access key generally available. This is
not typically recommended as this key gives
individuals full access to your entire storage
account and its management operations.
Another, more common option is to manage
access for the entire container.
The Public Read Access property controls what data is available anonymously for your container. You can
select the following values for the Public Read Access setting:
• Container. Blobs in a container can be enumerated. The container metadata is also accessible.
Individual blobs within this container and their properties can also be accessed with this setting.
MCT USE ONLY. STUDENT USE PROHIBITED
7-6 Storing and Consuming Files from Azure Storage
• Blob. Only individual blobs and their properties in this container can be accessed. Blobs are not
allowed to be enumerated.
• Off. With this setting, enumeration of blobs is not allowed. Individual blobs and their properties are
also not accessible. You must use your access keys to access any data about this container or it’s
blobs.
When using a SAS token, you should always use HTTPS in your requests. The query parameters in
your URL contain data that can possibly be used in a malicious manner with your storage account. For
example, if a SAS token has an expiration time of 1 day, and your request is intercepted. The interceptor
can re-use the SAS token in their requests. If the token could possibly grant access to unintended blobs
that are in the same container.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 7-7
The following code example creates an access policy on a container, and then generates a shared access
signature for the container.
string sasToken =
container.GetSharedAccessSignature(new SharedAccessBlobPolicy(), "mypolicy");
You can use a SAS token by appending it to the end of the REST URL for this blob resource. The SAS token
is traditionally a simple query string value.
• Start time
• Expiry time
• Signature permissions
To use a stored access policy, you must first create the policy and associated it with your storage account.
The policy must contain a unique identifier which is a string with a maximum length of 64 characters.
After the policy is created, you specify the unique identifier of the policy when creating new signatures.
These signatures are now associated with the policy and will specify the policy in their query string
parameters. To update a policy or revoke the signatures for a policy, you simply replace the policy in the
list of policies for your storage account with a new policy using the same unique identifier.
By using the Valet Key pattern, the web service can receive a request from the user, validate the user,
and then return the credentials necessary for the user to access the resource directly. The web service
accomplishes this by using a stored access policy and generating a shared access signature. The signature
is then appended to the end of the blob URL and the entire URL along with the signature is returned to
the user. The user can then use the expanded URL to access the blob resource directly from Azure storage
in a controlled manner.
A provider web service returning the URI and token from Storage and allowing the client to download
data directly:
Lesson 3
Configuring Azure Storage Accounts
Azure storage accounts can have additional features enabled or configured to extend the base
functionality.
This lesson introduces the CDN and cross-origin resource sharing (CORS) features for a storage account.
Lesson Objectives
After completing this lesson, you will be able to:
The Azure CDN service replicates content in your Storage account across nodes in various regions. The
CDN service is billed separately from your storage account. To use the CDN service, you create a CDN
endpoint within your storage account. The storage account provides origin data and caches them to CDN
nodes across various regions. The CDN service is also compatible with Azure Cloud Services. Content in
the CDN remains there until it expires. This expiration is determined by using the configurable time-to-
live value. All publicly available content in your storage account or hosted service is cached to your CDN.
If any of the content is modified, the changes not be available in the CDN until either the CDN refreshes
its content through manual intervention or the cached CDN content's time-to-live period of time expires.
MCT USE ONLY. STUDENT USE PROHIBITED
7-10 Storing and Consuming Files from Azure Storage
By default, CORS is not enabled for your storage account. For each Storage service, Blob, Table, and
Queue, you must individually configure CORS rules either using an automation script or either of the
portals. When you configure CORS, you will specify a range of permitted origins, methods, and headers.
CORS Rule
<Cors>
<CorsRule>
<AllowedOrigins>http://www.contoso.com,
http://www.fabrikam.com</AllowedOrigins>
<AllowedMethods>PUT,GET</AllowedMethods>
<AllowedHeaders>x-ms-meta-data*,x-ms-meta-target*,x-ms-meta-
abc</AllowedHeaders>
<ExposedHeaders>x-ms-meta-*</ExposedHeaders>
<MaxAgeInSeconds>200</MaxAgeInSeconds>
</CorsRule>
<Cors>
The CORS rule is an XML document with specific expected elements. The most common elements are
described below:
• AllowedOrigins. This is a list of origin domains that are allowed to make a cross-origin request
against your storage service. The origin is determined by validating the Origin header from the
client request. A wildcard character can optionally be used here to indicate that all origins are
allowed. In the example above, by using CORS, the domains http://www.contoso.com and
http://www.fabrikam.com can make requests against the service.
• AllowedMethods. This is a list of HTTP methods that are allowed in your cross-origin requests.
Pre-flight requests using the OPTIONS method are implicitly allowed and do not need to be specified
in this document. In the example above, only PUT and GET requests are permitted.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 7-11
• MaxAgeInSeconds. This specifies how long a browser can cache the response to the pre-flight
OPTIONS request. This is useful in scenarios where you need to regularly update the CORS rules for
your storage account. In the example above, a browser must issue a new pre-flight request if the
cached OPTIONS response is older than 200 seconds.
MCT USE ONLY. STUDENT USE PROHIBITED
7-12 Storing and Consuming Files from Azure Storage
Lesson 4
Azure Files
File is a service that provides an SMB file share that can be used to share files among multiple virtual
machines.
This lesson describes the File service and the file share logical unit.
Lesson Objectives
After completing this lesson, you will be able to:
Applications running in Azure virtual machines or Cloud Services can mount the new file share using
the SMB 2.1 protocol. This is supported in both Linux and Windows operating systems that support the
protocol. The process to mount the share is the same as mounting any other SMB file share. Multiple
application components can mound the shares and use them to share data simultaneously.
Azure Files exposes a REST API in a manner similar to other Azure services. On premise applications can
use this REST API to access data in the share or to add data to the share. Using this API, applications can
operate in a hybrid manner with components hosted both in Azure and on premise.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 7-13
File Shares
Because a File storage share is a standard SMB
2.1 file share, applications running in Azure
can access data in the share through the file
system I/O APIs. Developers can therefore use
their existing code and skills to migrate the
applications. IT Professionals (IT pros) can use
Windows PowerShell cmdlets to create, mount,
and manage File storage shares as part of the
administration of Azure applications.
Objectives
After you complete this lab, you will be able to:
Lab Setup
Estimated Time: 60 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Review Question
Question: You have a web application that allows users to download a large blob that is
protected. Your server-side logic generates a SAS token to retrieve the protected blob.
Should your server download the blob and stream it to the web client or should your server
provide the blob URL with the appended SAS token to the web client?
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
8-1
Module 8
Designing a Communication Strategy by Using Queues and
Service Bus
Contents:
Module Overview 8-1
Lab: Using Queues and Service Bus to Manage Communication in Azure 8-24
Module Overview
With web applications presenting content and worker roles processing the logic, there needs to be a
mechanism that facilitates the communication between these different entities. Microsoft Azure provides
two queuing mechanisms that you can use for this purpose. Lesson 1, “Azure Storage Queues,” introduces
the queue mechanism that is available in Azure storage accounts. Lesson 2, “Azure Service Bus,”
introduces the Service Bus offering in Azure. Lesson 3, “Azure Service Bus Queues,” describes the queuing
mechanism that is available in Service Bus and how it differs from Azure Storage queues. Lesson 4, “Azure
Service Bus Relay,” describes the relay mechanism available to connect client devices to WCF services.
Lesson 5, “Azure Service Bus Notification Hubs,” introduces the Notification Hubs service and
infrastructure useful for pushing notifications to mobile devices.
Objectives
After completing this module, you will be able to:
• Describe Storage Queues service.
Lesson 1
Azure Storage Queues
Storage queues provide a consistent and reliable way to store messages that can be consumed by
multiple workers.
This lesson introduces the Queue service in Storage and describes some of its characteristics.
Lesson Objectives
After completing this lesson, you will be able to:
URL format: You can address queues by using the following URL format:
http://<storage account>.queue.core.windows.net/<queue>
http://myaccount.queue.core.windows.net/imagesToDownload
• Update Message
o Updates the content or visibility timeout of a specified message
• Delete Message
o After a message is processed, you can delete the message from the queue so that it won’t be
processed again.
Update Message
CloudQueueMessage message = queue.GetMessage();
message.SetMessageContent("Updated contents.");
queue.UpdateMessage(message,
TimeSpan.FromSeconds(0.0), // Make it visible immediately.
MessageUpdateFields.Content | MessageUpdateFields.Visibility);
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-5
Lesson 2
Azure Service Bus
Service Bus is a fully managed messaging platform in Azure. Components of your application can leverage
Service Bus to share messages in a disconnected manner.
This lesson describes the Service Bus service and its features.
Lesson Objectives
After completing this lesson, you will be able to:
Service Bus is a multitenant cloud service, which means that the service is shared by multiple users. Each
user, such as an application developer, creates a namespace, and then defines the communication
mechanisms he or she needs within that namespace.
Service Bus provides a multitenant service for connecting applications through the cloud.
• Relays. They are a bidirectional proxy for communication with a Windows Communication
Foundation (WCF) service. Client applications can bind directly to the relay endpoint and the relay
infrastructure handles routing messages to the appropriate WCF service endpoint.
• Notification Hubs. It is a managed, brokered system for distributing messages from server
applications to client devices across various platforms by using local notifications.
Namespaces
Namespaces serve as a basic logical grouping of
Service Bus service instances.
Lesson 3
Azure Service Bus Queues
Service Bus provides the queue functionality that you can use to marshal messages from reporting
applications to consuming applications. A Service Bus queue is different from a Storage queue.
This lesson describes Service Bus queues and the difference between Service Bus queues and Storage
queues.
Lesson Objectives
After completing this lesson, you will be able to:
• Describe the differences between Service Bus queues and Storage queues.
Service Bus queues do implement a familiar first in, first out (FIFO) message delivery strategy. Service Bus
queues can also guarantee that a message is received and processed both at least and at most once by
the message consumers.
MCT USE ONLY. STUDENT USE PROHIBITED
8-8 Designing a Communication Strategy by Using Queues and Service Bus
Service Bus queues are a general-purpose technology that you can use in a wide variety of scenarios:
• Communication between on-premises apps and Azure hosted apps in a hybrid solution
• If the message is successfully processed, the Complete method is used to instruct the queue to delete
the message immediately.
• If the message has failed at some point in processing but the application can handle this failure
without crashing, the Abandon method is used to indicate that the lock should be removed from the
message. The message will now be visible to other receivers that wish to process the message.
• If the configured time-to-live value for the queue message expires, the queue assumes that the
receiver is in a faulted state. The queue removes the lock from the message and makes it available
to other receivers.
After a receiver application component reads the message, it is the responsibility of the receiver to call the
Complete method after the message is successfully processed. If this does not occur, an infinite loop can
happen where the same message is processed infinitely because of the time-to-live period expiring for the
message. Service Bus Queue messages have a unique ID that your client application can use to determine
if a message is processed by more than one receiver.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-9
• MessageId. You can use this property to provide a unique identifier for the message.
The message object also includes a dictionary property named Properties. This IDictionary<string,
object> typed property can contain any custom properties that you want to define for your application.
These properties are included in the object in addition to the actual body of the message. The message
body is a Common Language Runtime (CLR) object that is serialized by using DataContractSerializer.
After you create a new BrokeredMessage instance, you can add the message body by using the
GetBody<T> method of the BrokeredMessage class. Because the body is serialized, this can be any
complex object that you want to transmit from your sender application to receiver applications.
Additional metadata about this message is typically stored in the Properties property of the
BrokeredMessage class.
MCT USE ONLY. STUDENT USE PROHIBITED
8-10 Designing a Communication Strategy by Using Queues and Service Bus
This example demonstrates how to send five test messages to a QueueClient instance.
New BrokeredMessage
BrokeredMessage message = new BrokeredMessage("Test message ");
message.Properties["TestProperty"] = "TestValue";
message.Properties["Message number"] = 12;
Client.Send(message);
Each message has two parts, a set of properties, representing a key/value pair, and a binary message
body. How they are used depends on what an application is trying to do. For example, an application
sending a message about a recent sale might include the properties Seller="Ava" and Amount=10000. The
message body might contain a scanned image of the sale's signed contract, or, if there isn't one,
the message body might be empty.
You can retrieve messages by using similar properties from the BrokeredMessage class.
This example demonstrates how messages can be received and processed by using the default PeekLock
mode.
Retrieving messages
while (true)
{
BrokeredMessage message = Client.Receive();
if (message != null)
{
try
{
Console.WriteLine("Body: " + message.GetBody<string>());
Console.WriteLine("Test Property: " + message.Properties["TestProperty"]);
message.Complete();
}
catch (Exception)
{
message.Abandon();
}
}
}
• Service Bus queues. They are part of a broader Azure messaging infrastructure that supports
queuing and publish/subscribe, web service remoting, and integration patterns.
Although both queuing technologies exist concurrently, Storage queues are introduced first, as a
dedicated queue storage mechanism built on top of Azure Storage services. Service Bus queues are
built on top of the broader brokered messaging infrastructure that is designed to integrate applications
or application components, which might span multiple communication protocols, data contracts, trust
domains, and network environments.
• Ordering guarantee. Service Bus queues guarantee that messages are processed in a FIFO order.
Storage queues do not guarantee this.
• Delivery guarantee. Service Bus and Storage queues guarantee that messages are delivered at least
once. Service Bus queues can also guarantee that a message is delivered only once.
• Lease granularity. Storage queues can set the lock/lease length to a different value for each
individual message. Service Bus queues can set this value only for all the messages in a queue
instance.
• Batches. Both Storage and Service Bus queues can receive messages in a batch. Only Service Bus
queues support batch creation of messages.
MCT USE ONLY. STUDENT USE PROHIBITED
8-12 Designing a Communication Strategy by Using Queues and Service Bus
Lesson 4
Azure Service Bus Relay
Service Bus relays provide a flexible way to connect WCF services and clients without having to redesign
the network architecture in your organization. When you connect the WCF service to a relay in an
outgoing manner, you clients will need to connect only to the Service Bus endpoint in Azure to
communicate with your WCF service.
This lesson describes the benefits and architecture of Service Bus relays.
Lesson Objectives
After completing this lesson, you will be able to:
• Although mobile applications are deployed and updated regularly, end users might not update their
applications as regularly as you want them to. If your WCF service needs to be migrated to a new
network or moved to a new IP address, this can cause a lapse of connectivity for your mobile
applications. Using Service Bus Relay, your mobile applications address a publicly accessible and
permanent uniform resource identifier (URI). You are then free to make changes and migrate your
WCF service within your organization's infrastructure. The new service instance or location simply
needs to connect to the relay for client devices to access it. This enables more mobility for services
that are connected to the applications that are already deployed.
Service Bus Relay also supports direct peer-to-peer communication. This is negotiated if the relay
determines that the connecting application can easily and directly address the WCF service.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-13
The Service Bus Relay service enables you to build hybrid applications that run in an Azure data center
and in your own on-premises enterprise environment.
When you use Service Bus Relay, you must use a set of WCF bindings that are similar to the bindings that
ship normally with WCF. These bindings include a relay prefix. They implement new binding elements that
create a channel to your Service Bus instance in Azure. Bindings are included for one-way messages,
request/response messages, and distributed event messages. The event messages are unique to Service
Bus Relay and are used to enable a publish/subscribe scenario where your client applications can send
a message and have that message distributed to multiple WCF service instances. For example, event
messaging can be used to distribute a message to a receiver WCF service for processing and auditing a
WCF service.
Because Service Bus Relay utilizes bindings that are very similar to the traditional WCF bindings, many
applications do not require large changes to use Service Bus Relay. The client applications typically require
a new binding configuration that specifies the relay binding. After the client communicates with the relay,
the relay service handles the targeting of messages to the appropriate WCF services. The client application
does not need to know anything about the service's address or actual location. The service applications do
not need to expose inbound ports on their firewall to receive these messages.
• WCF. Relay is used with WCF services. WCF is a mature, stable messaging framework that supports
both SOAP and REST messaging. WCF also has a mature ecosystem of custom bindings, behaviors,
and components. SOAP and REST is also already widely supported by many existing services or client
devices.
MCT USE ONLY. STUDENT USE PROHIBITED
8-14 Designing a Communication Strategy by Using Queues and Service Bus
Management Credentials
Applications can authenticate to Service Bus
by using Shared Access Signature (SAS)
authentication. Previously, Azure Active Directory
Access Control Service (ACS) was used to provide
an access key.
You can configure keys for SAS on a Service Bus namespace. The key applies to all messaging entities in
that namespace. You can also configure keys on Service Bus queues, topics, and notification hubs. Support
for Service Bus relays will be added in the near future.
To use SAS, you can configure a SharedAccessAuthorizationRule object on a namespace, queue, topic,
or notification hub that consists of the following:
• Rights that represent the collection of Listen, Send, or Manage rights granted
Authorization rules configured at the namespace level can grant access to all the entities in a
namespace for clients with tokens signed by using the corresponding key. You can configure up to 12
such authorization rules on a Service Bus namespace, queue, topic, or notification hub. By default, a
SharedAccessAuthorizationRule object with all rights is configured for every namespace when it is first
provisioned.
MCT USE ONLY. STUDENT USE PROHIBITED
8-16 Designing a Communication Strategy by Using Queues and Service Bus
Lesson 5
Azure Service Bus Notification Hubs
Notification Hubs provides a simple interface for a highly-scalable managed mobile push notification
platform. By using Notification Hubs, an application can send template or personalized notifications
across a variety of mobile platforms.
This lesson describes the Notification Hubs service and the methods of integrating with the service.
Lesson Objectives
After completing this lesson, you will be able to:
• Register a client device to a notification hub from either the client or service application.
• Sending wide-reaching news notifications to all devices with your mobile application installed.
• Sending a notification to a subset of your users that is determined based on a tag, label, or location.
• Sending specific notifications to a user for the activities that are related to their specific account.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-17
• Multiple platforms:
o Support for all major mobile platforms—Windows, Windows Phone, iOS, and Android.
• Works with any backend. Works with Cloud or on-premises applications that are written in .NET,
PHP, Java, or Node.
• Scale. Notification hubs scale to millions of devices without the need of rearchitecting or sharding.
• Rich set of delivery patterns. Associate devices with tags, representing logical users or interest
groups.
o Broadcast. Allows for near-simultaneous broadcast to millions of devices with a single Application
Programming Interface (API) call.
MCT USE ONLY. STUDENT USE PROHIBITED
8-18 Designing a Communication Strategy by Using Queues and Service Bus
o Unicast/Multicast. Push to tags representing individual users, including all their devices; or a
wider group. For example, a user could use the app on separate devices (tablet, phone, etc.)
and would require push notifications to either be pushed to all devices or a specific device.
o Segmentation. Push to a complex segment that is defined by tag expressions (For example,
devices in New York following the Yankees).
• Personalization. Each device can have one or more templates to achieve per-device localization and
personalization without affecting the backend code.
3. To send a push notification, the app backend contacts the PNS by using the handle to target an
instance of a specific client application.
4. The PNS forwards the notification to the device specified by the handle.
With Notification Hubs, you can rely on the service infrastructure to handle the most complex features
and have your application focus only on sending messages.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-19
Notification Hubs can be used in flexible ways to register devices and eventually send a message to the
devices. Devices can register themselves and receive notifications using the following method:
1. The client device reaches out to the PNS by using the Notification Hubs SDK. It registers a unique PNS
handle that is used by the service to send notifications to this device whether the application is
running or not.
2. The client device can alternatively send its PNS handle to the application backend to have the
application register the device.
3. When the application backend sends a message to the Notification Hubs service, the service handles
sending the message to the appropriate target clients by using their registered PNS handles. The
application backend simply requests the message is sent and the Notification Hubs service and the
PNS handle the actual distribution of messages to client devices.
Registrations
A registration is a subentity of a notification hub,
and associates a device PNS handle—For
example, ChannelURI, device token, or Google
Cloud Messaging (GCM) registrationId—with
tags and possibly a template. Tags are used to
route notifications to the correct set of device
handles. Templates are used to implement per-
registration transformation.
Client Registration
When managing registrations from client apps, the backend is responsible only for sending notifications.
Client apps keep the PNS handles up to date and register to tags. The mobile device first retrieves the PNS
handle from the PNS, and then registers with the notification hub directly. After the registration is
successful, the app backend can send a notification targeting that registration.
The drawback to client registration is that a client app can only update its tags when the app is active. For
example, if a user has two devices that register tags that are related to sport teams, when the first device
registers for an additional sports team, the second device will not receive the notifications about that
team until the app on the second device is run a second time. Generally, when tags are affected by
multiple devices, managing tags from the backend is a desirable option.
Registering directly from the client device:
Templates
Templates enable a client application to specify
the exact format of the notifications it wants to
receive. For example, the following two payloads
are used for Windows and Apple mobile devices.
This requirement forces the app backend to produce different payloads for each platform. This
becomes a problem when you consider graphical layouts and localization. The Notification Hubs template
feature enables a client app to create special registrations, called template registrations, which include a
template in addition to the set of tags. The template is then used to translate a message into the
appropriate format or structure for each device.
MCT USE ONLY. STUDENT USE PROHIBITED
8-22 Designing a Communication Strategy by Using Queues and Service Bus
A template is a set of instructions for the notification hub to format a platform-independent message to
the format that is appropriate for each device:
Tags
Tag expressions enable you to target specific sets of devices, or more specifically registrations, when you
send a push notification through Notification Hubs. A tag can be any string, up to 120 characters, that
contains alphanumeric characters. The only way to target specific registrations is to associate them with a
tag, and then target that tag.
The application backend can choose the registrations to target with a specific notification in the following
ways:
• Tag expression. All registrations whose set of tags match the specified expression receive the
notification.
Tags do not have to be pre-provisioned and can refer to multiple app-specific concepts. There are cases in
which a notification has to target a set of registrations that is identified not by a single tag, but by a
Boolean expression on tags. Tag expressions can contain all Boolean operators, such as AND (&&), OR (||),
and NOT (!). They can also contain parentheses. Tag expressions are limited to 20 tags if they contain only
ORs; otherwise they are limited to six tags.
You can use tag expressions to target many possible matching tags instead of a single tag.
Tag Expression
(follows_RedSox || follows_Cardinals) && location_Boston
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 8-23
The following example shows an application from which you can receive toast notifications about specific
music groups. In this scenario, a simple way to route notifications is to label registrations with tags that
represent the different bands:
Currently, your on-premises Contoso Events application uses a WCF service to list the hotels that are near
a location. You would like to continue to use the WCF service, but you cannot modify your company’s
firewall. You also would not like to expose the true network location of the WCF service. You have decided
to use Service Bus relays so that you have a common endpoint that you can provide to client applications.
You will start by using that endpoint in your Contoso Events web application.
Objectives
After you complete this lab, you will be able to:
• Modify the XML configuration of a WCF service to use the Service Bus relay bindings.
• Modify the C# configuration of a WCF client to use the Service Bus relay bindings.
Lab Setup
Estimated Time: 90 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Review Questions
Question: Which queuing mechanism is better suited for storing large messages?
Question: If you have an application that cannot afford to lose any messages, should you
use the PeekLock or ReceiveAndDelete mode in your consuming client? How do you check
to see if the message is a duplicate?
Question: You have a weather app and you are using Notification Hubs for messaging. You
would like to let people within a specific area code receive an emergency alert about a
hurricane. How should you architect your application to support this scenario?
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
9-1
Module 9
Automating Integration with Azure Resources
Contents:
Module Overview 9-1
Lesson 1: Creating Azure Scripts by Using Azure PowerShell 9-2
Module Overview
Although you can manage most of the Azure services by using both of the Azure portals or Microsoft
Visual Studio, you can use scripting to completely automate the management of the same resources.
This module will look at automating the lifecycle of the services by using client libraries, Windows
PowerShell, REST, and the Resource Manager. Lesson 1, “Creating Azure Scripts by Using Azure
PowerShell,” describes the modules that are available for managing Azure resources using Azure
PowerShell. Lesson 2, “Creating Azure Scripts by Using Azure CLI,” describes the cross-platform command-
line interface used to manage Azure resources. Lesson 3, “Azure Resource Manager,” discusses the
Resource Manager architecture in Azure and the concepts associated with this method of managing
resources and groups. Lesson 4, “Azure REST Interface,” introduces and describes the REST API used to
manage all resources in Azure. Lesson 5, “Azure Cloud Shell,” describes the Cloud Shell and how it is used
to execute scripts within the Azure Portal and context of an Azure subscription.
Objectives
After completing this module, you will be able to:
• Describe the Azure software development kits (SDKs) and client libraries.
• Describe the REST API and the steps to authenticate to the API.
Lesson 1
Creating Azure Scripts by Using Azure PowerShell
You can use Windows PowerShell to automate many of the administration tasks that IT Pros perform on a
daily basis. Developers can use Windows PowerShell to facilitate and automate many of their developer
operations responsibilities.
This lesson describes the two sets of cmdlets that are available in the Azure PowerShell module.
Lesson Objectives
After completing this lesson, you will be able to:
Azure PowerShell
Azure PowerShell is a collection of two Windows PowerShell modules that you can use to manage Azure
services. The first and most commonly used module is the REST module. This module allows you to
manage service instances in your Azure subscription. The Resource Manager module is also available and
will be discussed in depth in the Azure Resource Manager lesson in this module.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-3
A list of Windows PowerShell activities included in the Azure PowerShell modules is currently available on
MSDN:
One of the major advantages of using the Azure PowerShell modules for REST is the availability of new
features. Typically, new features are first introduced to the REST API and then are added to the Azure
PowerShell modules. Finally, these features are available in the portal.
This typically means that new features can be tested and used by using Azure PowerShell before they are
generally available in the portal. Also, you can use Windows PowerShell to create scripts to automate
multiple tasks together when you work with the Azure platform. These scripts can be used in developer
operations scenarios where configuration needs to be maintained, stored, and repeated.
Azure Automation
Azure Automation is a service that can be used to run Windows PowerShell workflows either on-demand
or based on a schedule. The Azure PowerShell activities are already imported into Azure PowerShell and
many different Windows PowerShell administration tasks can be directly imported from a local script
into Azure Automation. Azure Automation also includes a script center that includes many of the most
common administration tasks. These tasks are typically time-consuming, error prone, and complex. With
Azure Automation, these scripts can be run as one-off or scheduled jobs and can be run in the Azure
environment in an unattended manner.
Requirements
Azure PowerShell can be used to manage
existing subscriptions but cannot be used to
create a new subscription. A subscription is
required to use the Azure PowerShell module.
Azure PowerShell requires .NET Framework 4.5 to
be installed on your local machine. The installer
checks for a valid version of Windows PowerShell
and then the .NET Framework installs missing
dependencies on your machine.
MCT USE ONLY. STUDENT USE PROHIBITED
9-4 Automating Integration with Azure Resources
PublishSettings File
The Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFile activities are used to
download and import an XML file containing the certificates for your Azure subscriptions. This method
of authentication is commonly referred to as certificate authentication. When you use this method, the
subscription information is available as long as the subscription and the certificate are valid. However, it is
harder to manage access to a shared subscription by using this method. For example, in scenarios when
more than one person is authorized to access the account. Also, Azure Resource Manager API does not
support certificate authentication.
Azure AD
Azure AD is the recommended authentication method because it makes it easier to manage access
to a subscription. The Add-AzureAccount activity is used to authenticate in this method. When
authenticating by using this method, a dialog box displays and you can sign in by using a Microsoft
account or an organizational account in the same manner that you authenticate to the Azure portal.
Note: To view the latest demo steps, visit the GitHub repository for the course.
Before starting this demo, you must complete the lab in Module 2. For this demo in this module, you will
use the available host machine. Also, you must complete the following steps:
1. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
2. In Remote Desktop Connection, provide the name of your virtual machine in the Computer box by
using the following format:
Note: The name and port for your virtual machine might be saved in the Computer drop-
down list. If this is the case, use this value instead of typing it in manually. If you are unsure about
your virtual machine’s RDP port, use either of the Azure portals to find your virtual machine’s
endpoints. The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your virtual machine from unauthorized access.
3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-5
o Password: AzurePa$$w0rd
Verify that you received the credentials to sign in to the Azure portal from your training provider. You will
use these credentials and the Azure account throughout the labs in this course.
MCT USE ONLY. STUDENT USE PROHIBITED
9-6 Automating Integration with Azure Resources
Lesson 2
Creating Azure Scripts by Using Azure CLI
The Azure CLI 2.0 is Azure's new command-line experience for managing Azure resources. You can use it
in your browser with Azure Cloud Shell, or you can install it on macOS, Linux, and Windows and run it
from the command line.
Lesson Objectives
After completing this lesson, you will be able to:
az vm create
az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName
To search for commands, use az find. For example, to search for command names containing secret, use
the following command:
az find
az find -q secret
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-7
Windows
On Windows the Azure CLI binary is installed
via an MSI, which gives you access to the CLI
through the Windows Command Prompt (CMD)
or PowerShell. If you are running Windows
Subsystem for Linux (WSL), there are packages
available for your Linux distribution.
Linux
Before installing the Azure CLI on your Linux
distribution, you should first check to see which
package manager is used by your distribution.
Azure CLI packages are available for the apt, yum and zypper package managers. If you do not have a
package for the Azure CLI available on your distribution, you can always install the CLI manually by
running an installation script.
macOS
For the macOS platform, you can install the Azure CLI with homebrew package manager. Homebrew is
the easiest way to manage your CLI install. It provides convenient ways to install, update, and uninstall.
Docker
You can use Docker to run a standalone Linux container with the Azure CLI 2.0 pre-installed. Docker lets
you get started quickly with an environment where you can try out the CLI to decide if it's right for you, or
use our image as a base for your own deployment.
Lesson 3
Azure Resource Manager
With the new Azure Preview Portal (Ibiza), a new way of managing resources in Azure has emerged. With
resource groups and resource group templates, automating the creation and monitoring of multiple-
service workloads is made much easier.
Lesson Objectives
After completing this lesson, you will be able to:
• Use the Resource Manager to create multiple resources as a single managed unit.
Resource groups and resource group templates are ideal for developer operations scenarios where you
need to quickly build out development, test, quality assurance, or production environments that are
homogenous in nature and can be managed with a shared lifecycle. Developers can quickly delete their
environment and create a new environment by using the shared template. The resource groups can be
monitored to determine the billing rate or resource usage at a higher level than monitoring individual
service instances.
The Resource Manager functionality in Azure is new and is visible only in the Preview Portal. A set of
Windows PowerShell cmdlets are available to manage resource groups today. The functionality is limited
however and only a subset of the Azure services can be managed in resource groups by using Windows
PowerShell and the Azure portals. The following are some of the current limitations:
• All services are not available in resource groups. For example, API Management instances cannot be
added to a resource group.
• Resource group templates can only be used to manage some services and cannot be used with
Virtual Machines yet.
However, new Resource Manager functionality is being released on a weekly basis and these limitations
are likely to change quickly.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-9
Resource Groups
Whenever a resource is created in the Preview
Portal, it is always created within a resource
group. You can choose to create a new resource
group or use an existing resource group when
creating the service instance. You might also
notice that some resources that are created in
the Management Portal are also placed into
resource groups. These are only visible in the
Preview Portal.
Resource groups can be viewed either by using the Preview Portal or Azure PowerShell. By using the
Preview Portal, resource groups can be viewed and monitored as a group.
A resource group has a blade that provides you with all the information about a particular resource
group:
Resources can be added to a resource group at any time. The Preview Portal has an Add button that can
be used to add a new resource to a resource group. Resource groups also enable you to manage the
lifecycle of all the contained resources. Deleting a resource group will delete all the resources contained
within it.
The Resource Manager mode in Azure PowerShell will allow you to manage resource groups in your
Azure subscription. Resource groups are created by using the New-AzureResourceGroup cmdlet. You
can create a resource group with a name and a location, and then use the New-AzureResource cmdlet
to manually create resources and add them to the resource group. You can also use a resource group
template to create a resource group from an existing definition.
The template consists of a variety of sections including those listed in the following table.
$schema A schema file must be specified indicating the version of the template language
that should be used.
parameters Parameters can be specified in a template so that the same template can be
used for multiple resource groups. For example, a resource group template can
create a hosting plan and website. By using parameters, the same template can
be used to create either a Standard tier hosting plan or a Free tier hosting plan.
variables Variables are reusable data that can be used for resources in the template. This
can cut down on the amount of repeated content in the template and honors
the DRY (don’t repeat yourself) principles of software development.
resources The resources section is a JSON array of the individual resources that are
defined in your template. This section is hierarchical and can be defined in a
manner such that certain resources are created first because of dependencies.
For example, a website resource in a template can have a web hosting plan
resource nested in its definition. This will ensure that the web hosting plan is
created before the website instance is created.
The resource group template JSON schema (language) also allows you to specify output values when the
resource group is created and the functions that can be used throughout your template.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-11
Azure hosts a gallery of resource group templates and you can create your own templates, either from
scratch or by editing a gallery template. Existing resource group templates can be downloaded by using
Azure PowerShell. The Save-AzureResourceGroupGalleryTemplate cmdlet downloads a template from
the gallery to a JSON file.
The Save-AzureResourceGroupGalleryTemplate cmdlet allows you to view existing gallery resource
group templates.
Save-AzureResourceGroupGalleryTemplate
Save-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSiteSQLDatabase.0.2.2-
preview -Path D:\Azure\Templates
Note: To view the latest demo steps, visit the GitHub repository for the course.
Before starting this demo, you must complete the lab in Module 2. For this demo in this module, you will
use the available host machine. Also, you must complete the following steps:
1. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
2. In Remote Desktop Connection, provide the name of your virtual machine in the Computer box by
using the following format:
Note: The name and port for your virtual machine might be saved in the Computer drop-
down list. If this is the case, use this value instead of typing it in manually. If you are unsure about
your virtual machine’s RDP port, use either of the Azure portals to find your virtual machine’s
endpoints. The endpoint with the name Remote Desktop is the correct port for
RDP. This port is randomized to protect your virtual machine from unauthorized access.
3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
o Password: AzurePa$$w0rd
Verify that you received the credentials to sign in to the Azure portal from your training provider. You will
use these credentials and the Azure account throughout the labs in this course.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-13
Lesson 4
Azure REST Interface
Many modern services and applications provide REST APIs. HTTP is a universal standard and can be used
across a variety of platforms and languages. Azure provides a REST API that can be used to manage
services regardless of your current platform.
This lesson describes the Azure REST API and how to authenticate against the API.
Lesson Objectives
After completing this lesson, you will be able to:
• List the two options that are used for authenticating to the API.
Management Certificate
Secure requests to the management service
can be authenticated by using management
certificates over SSL. To use a management
certificate, it must be uploaded to Azure. After
MCT USE ONLY. STUDENT USE PROHIBITED
9-14 Automating Integration with Azure Resources
you add a management certificate to the subscription, you can sign the requests to the service by using
the same certificate. The REST API does not verify if a certificate is still valid and therefore it can be used
with an expired or invalid certificate. Also, role-based authentication is not supported for certificate-based
authentication.
The Azure AD Authentication Library for .NET enables client application developers to easily authenticate
users to a cloud or on-premises Active Directory, and then obtain access tokens for securing API calls.
Active Directory Authentication Library for .NET has many features that make authentication easier for
developers. Some examples are asynchronous support, a configurable token cache that stores access
and refresh tokens, and automatic token refresh when an access token expires and a refresh token is
available. By managing these complex tasks, your application can focus on the relevant code and not on
authenticating with the API.
After you create a native client application in Azure AD, you need to assign delegated permissions to
access the REST API, and then use the clientId and tenantId parameters in your custom application.
Azure SDKs
Language-specific tools and client libraries are
available for a variety of platforms. You can use
these tools and libraries when you integrate your
custom applications with Azure.
Microsoft Platform
To manage Azure services, extensions are
available for Visual Studio 2012 and later that
enhance the functionality of the Server Explorer
and adds new project templates. Visual Studio
allows you to manage Azure services and display
their status using the Server Explorer. In Visual
Studio, you can also create new services and
manage current services either using the Server Explorer or the project templates. For more complex
integration with your custom applications, .NET libraries are available to manage Azure services. Many of
these custom packages are available directly on NuGet.
For the most complex administration scenarios, Windows PowerShell activities are available to automate
your activities with Windows PowerShell scripts. You can install these Windows PowerShell activities
directly in your development environment by using the Azure PowerShell modules. Alternatively, the
Azure PowerShell modules are available in the Azure Automation service.
Third-Party Platforms
Similar Azure REST libraries are available for popular platforms and languages including:
• Java
• Node.js
• PHP
• Python
• Ruby
This list is expanding on a fast cadence. For the majority of these languages or frameworks, installers are
available for multiple popular operating systems (Windows, Mac OS, and Linux). Developer portals are
also available on the official Azure website with links to tutorials and advanced documentation.
A set of open-source commands are available in a collection referred to as the Azure Cross-Platform
Command-Line Interface (xplat-cli). Xplat-cli provides a common interface for managing Azure services
regardless of the operating system or management environment. Xplat-cli is written in Node.js and
requires a local installation of Node.
Mobile Platforms
Microsoft Azure Mobile Services is a platform that enables you to quickly build a back-end service for
mobile applications. With a dynamic schema, this mobile back-end service can be created with little or
no custom code and can be refined over time. Mobile Services and its dynamic schema feature allows
developers to bring mobile applications and ideas to market quickly without many of the traditional
delays and infrastructure setup. Mobile Services also scales with the application and can handle growth
in usage for the application over time.
MCT USE ONLY. STUDENT USE PROHIBITED
9-16 Automating Integration with Azure Resources
Mobile Services can integrate with a variety of mobile platforms with native libraries including:
• iOS
• Android
• Windows Phone 8
Mobile Services also exposes a RESTful HTTP endpoint and supports cross-origin resource sharing (CORS).
This ensures that Mobile Services can be used for a wide variety of scenarios where a native library is not
immediately available.
Media Services
Microsoft Azure Media Services is an all-encompassing media solution that includes the encoding,
storage, protection, and delivery of media assets to client devices. Libraries are available for multiple
media platforms such as Silverlight or Flash, development platforms such as .NET or Java, and platforms
such as Windows 8, Windows Phone, Android and iOS.
Lesson 5
Azure Cloud Shell
Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. It provides the
flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash
experience, while Windows users can opt for PowerShell.
Lesson Objectives
After completing this lesson, you will be able to:
Cloud Shell
Cloud Shell enables access to a browser-based
command-line experience built with Azure
management tasks in mind. Leverage Cloud Shell
to work untethered from a local machine in a
way only the cloud can provide.
Objectives
After you complete this lab, you will be able to:
Lab Setup
Estimated Time: 45 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Exercise 1: Use Azure CLI to Create and Manage an Azure Web App
Exercise 2: Use PowerShell to Create and Manage an Azure Storage
Account
Question: When automating your Azure accounts and resource management, should you
use the Resource Manager cmdlets or the standard cmdlets?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 9-19
Which Azure cmdlet can be used to verify that a resource group has been deleted?
Remove-AzureRmResourceGroup
Get-AzureRmResourceStatus
Get-AzureRmResourceGroup
Delete-AzureRmResourceGroup
Get-AzureRmResourceGroupTemplate
MCT USE ONLY. STUDENT USE PROHIBITED
9-20 Automating Integration with Azure Resources
Best Practice
Moving forward, the Azure Resource Manager is the preferred method of managing resources in Azure.
Resource should be grouped into logical units by using resource groups and templates should be created
for resources that might need to be created multiple times.
Review Question
Question: How can you create your own resource group template?
MCT USE ONLY. STUDENT USE PROHIBITED
10-1
Module 10
DevOps in Azure
Contents:
Module Overview 10-1
Lesson 1: Continuous Integration 10-2
Module Overview
Although you can deploy your cloud applications manually, it is in your best interest to begin automating
cloud-based deployments. Automation creates many benefits including the ability to trace past actions,
easier repetition of deployment tasks and reduced possibility of human error. Lesson 1, “Continuous
Integration,” discusses strategies for integrating source control repositories with running cloud service
instances for automatic deployment scenarios. Lesson 2, “Azure DevTest Labs,” introduces the DevTest
service which is useful for automating the creation of machine-specific environments and lab scenarios.
Lesson 3, “Azure Resource Manager Templates,” discusses the capability to deploy entire workloads in
Azure from a JSON template. Lesson 4, “Managed Solution Hosting,” introduces Service Fabric, Azure
Container Service and Azure Container Instances as methods used to host solutions using a fully managed
service.
Objectives
After completing this module, students will be able to:
Lesson 1
Continuous Integration
The process of Continuous Integration (CI) encourages developers to frequently integrate their code. It
also provides the benefits of using automated build and testing processes.
This lesson introduces Continuous Integration conceptually as a context for later lessons in this module.
Lesson Objectives
After completing this lesson, you will be able to:
Continuous Deployment
Continuous integration and continuous delivery
(CI/CD) are a key requirement for achieving
success with the cloud. Without a good CI/CD
process, you will not achieve the agility that the
cloud promises.
• Continuous deployment means that code changes that pass the CI/CD process are automatically
deployed into production.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 10-3
Lesson 2
Azure DevTest Labs
Developers and testers are looking to solve the delays in creating and managing their environments by
going to the cloud. Azure solves the problem of environment delays and allows self-service within a new
cost-efficient structure. However, developers and testers still need to spend considerable time configuring
their self-served environments.
This lesson proposes the Azure DevTest Labs service as a solution to managing the creation of multiple
environments for the validation of applications.
Lesson Objectives
After completing this lesson, you will be able to:
DevTest Labs
In today’s world developers have the need to
setup their solution environments in the quickest
way possible and without any delay. Microsoft
Azure is a great solution for this use case.
Developers can create the needed environments
with all the big advantages that a Cloud solution
provides. Nevertheless, this is a task that need
special skills that in some companies are
reserve for IT Pros and when they are done by
developers these tasks usually take some time.
Time that the development team is moving
from the current project to the creation of the
environment, so, instead of being focus on the project they are creating the solution environments.
The Microsoft Azure DevTest Labs comes to rescue helping developers to quick create the needed
environments in a very short period, minimizing the time the development team is not focus of the
current project. Azure DevTest Labs can create Windows and Linux Virtual Machines based in reusable
templates. With the use of their templates, developers can create and remove environments wherever
they need to test a new feature, a new solution, etc. These deployments can also be integrated in the
DevOps pipeline in order to create environments for the Test teams, for automatically tests, etc.
Azure DevTest can also be used to create Training and demonstration environments of the solution being
developed. This also solves issues of the teams that need to create these environments due to
the flexibility of the service.
Key Concepts
Lab. Group of resource that consist or lab can be several virtual machines.
Claimable VM. A claimable VM is unassigned and can be claimed by any lab user with permissions. The
lab administrator can mark the virtual machines as claimable in the advanced settings blade, then they will
show up under the claimable virtual machines list in the overview blade.
MCT USE ONLY. STUDENT USE PROHIBITED
10-4 DevOps in Azure
Base Image. You can create a custom base image, creating in this way an already pre-configured virtual
machine with all the software and configuration needed for a specific deployment. This way is faster to
setup a lab.
Artifacts. Based on JSON files providing common tools to be installed in an Azure DevTest Virtual
Machines. You can find tools like, Atom, Google Chrome, 7-Zip, git, Node JS, Notepad++, … You can
also use artifacts to setup your firewall rules, create an Active Directory domain or even to clone a specific
repo.
Formulas. DevTest Lab template to fully setup a virtual machine with a based image and all the needed
software installed via selection of the appropriate artifacts.
You start to select a base image of your virtual machine, then you can setup the all Virtual machine
configurations like: name, User Name, virtual machine size and all the artifacts that this formula will have.
Using formulas, you can easily create a developer environment with all the software that your developers
need on the machine without the need to have then install and configure the machine.
Policies. In Azure DevTest Labs policies can be used to control the cost of a lab. You can create a specific
Policy specifying limits and quotas. For example, you can configure a schedule to shut down your virtual
machines, limit the number of virtual machines per user and per lab or set an expiration date on your
virtual machine.
Lesson 3
Azure Resource Manager Templates
With Resource Manager, you can create a template (in JSON format) that defines the infrastructure
and configuration of your Azure solution. By using a template, you can repeatedly deploy your solution
throughout its lifecycle and have confidence your resources are deployed in a consistent state.
This lesson introduces ARM templates and describes how to author and deploy the templates.
Lesson Objectives
After completing this lesson, you will be able to:
$schema A schema file must be specified indicating the version of the template language
that should be used.
parameters Parameters can be specified in a template so that the same template can be used
for multiple resource groups. For example, a resource group template can create a
hosting plan and website. By using parameters, the same template can be used to
create either a Standard tier hosting plan or a Free tier hosting plan.
variables Variables are reusable data that can be used for resources in the template. This can
cut down on the amount of repeated content in the template and honors the DRY
(don’t repeat yourself) principles of software development.
resources The resources section is a JSON array of the individual resources that are defined in
your template. This section is hierarchical and can be defined in a manner such that
certain resources are created first because of dependencies. For example, a website
resource in a template can have a web hosting plan resource nested in its
definition. This will ensure that the web hosting plan is created before the website
instance is created.
The resource group template JSON schema (language) also allows you to specify output values when the
resource group is created and the functions that can be used throughout your template.
Template Advantages
Templates are generally preferred to manually deploying resources for quite a few reasons:
• A template can ensure idempotency. If you deploy an identical template to multiple resource groups,
they would functionally be the same.
• A template can simplify orchestration as you only need to deploy the template to deploy all of your
resources. Normally this would take multiple operations.
• A template allows you to configure multiple resources simultaneously and use variables/parameters
/functions to create dependencies between resources. For example, you can require that a VM is
created before a Web App because you need the VM's public IP address for one of the Web App's
settings. Another example is to require a Storage account is created before a VM so that you can
place the VHDs in that storage account.
• A template is a JSON file so it can be compared, managed using a source control provider and used
as part of any continuous integration process.
• Templates can parameterize input and output values so they can be reused across many different
scenarios. Templates can also be nested so you can reuse smaller templates as part of a larger
orchestration.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 10-7
Templates make it easier to repeat and reuse configurations throughout your solutions:
A template can include parameters that enable you to customize the deployment. For example, you can
provide values that are tailored for a particular environment (such as dev, test, and production). The
Resource Manager template you deploy can either be a local file on your machine, or an external file that
is located in a repository like GitHub.
MCT USE ONLY. STUDENT USE PROHIBITED
10-8 DevOps in Azure
Lesson 4
Managed Solution Hosting
Many application solutions require some type of hosting that has the advantage of minimal maintenance
(similar to App Services) but also has the flexibility and power to host complex solutions that have
requirements that don’t “cleanly” fit into the App Services sandbox.
This lesson will show how you can host applications on Service Fabric, Container Service and Container
Instances.
Lesson Objectives
After completing this lesson, you will be able to:
• Describe the differences between Service Fabric, Azure Container Service and Azure Container
Instances.
• Create a CI/CD pipeline using Azure Container Service, VSTS and GitHub.
Service Fabric
Azure Service Fabric is a distributed systems
platform that makes it easy to package, deploy,
and manage scalable and reliable microservices
and containers. Service Fabric also addresses
the significant challenges in developing and
managing cloud native applications. Developers
and administrators can avoid complex
infrastructure problems and focus on
implementing mission-critical, demanding
workloads that are scalable, reliable, and
manageable. Service Fabric represents the next-
generation platform for building and managing
these enterprise-class, tier-1, cloud-scale applications running in containers.
Container Orchestration
Azure Service Fabric is an orchestrator of services across a cluster of machines, with years of usage and
optimization in massive scale services at Microsoft. Services can be developed in many ways, from using
the Service Fabric programming models to deploying guest executables. By default, Service Fabric deploys
and activates these services as processes. Processes provide the fastest activation and highest density
usage of the resources in a cluster. Service Fabric can also deploy services in container images.
Importantly, you can mix services in processes and services in containers in the same application.
Containers are encapsulated, individually deployable components that run as isolated instances on the
same kernel to take advantage of virtualization that an operating system provides. Thus, each application
and its runtime, dependencies, and system libraries run inside a container with full, private access to the
container's own isolated view of operating system constructs. Along with portability, this degree of
security and resource isolation is the main benefit for using containers with Service Fabric, which
otherwise runs services in processes.
Service Fabric supports containers on both Linux and Windows, and also supports Hyper-V isolation mode
on the latter.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 10-9
Traditional ASP.NET (up to MVC 5) is tightly coupled to IIS through System.Web.dll. ASP.NET Core
provides a separation between the web server and your web application. This allows web applications to
be portable between different web servers and also allows web servers to be self-hosted, which means
you can start a web server in your own process, as opposed to a process that is owned by dedicated web
server software such as IIS.
In order to combine a Service Fabric service and ASP.NET, either as a guest executable or in a Reliable
Service, you must be able to start ASP.NET inside your service host process. ASP.NET Core self-hosting
allows you to do this.
Typically, self-hosted ASP.NET Core applications create a WebHost in an application's entry point, such as
the static void Main() method in Program.cs. In this case, the lifecycle of the WebHost is bound to the
lifecycle of the process.
However, the application entry point is not the right place to create a WebHost in a Reliable Service,
because the application entry point is only used to register a service type with the Service Fabric runtime,
so that it may create instances of that service type. The WebHost should be created in a Reliable Service
itself. Within the service host process, service instances and/or replicas can go through multiple lifecycles.
A Reliable Service instance is represented by your service class deriving from StatelessService or
StatefulService. The communication stack for a service is contained in an ICommunicationListener
implementation in your service class. The Microsoft.ServiceFabric.Services.AspNetCore.* NuGet packages
contain implementations of ICommunicationListener that start and manage the ASP.NET Core WebHost
for either Kestrel or HttpSys in a Reliable Service.
Kubernetes
Azure Container Service for Kubernetes makes
it simple to create, configure, and manage a
cluster of virtual machines that are preconfigured
to run containerized applications. This enables
you to use your existing skills, or draw upon a
large and growing body of community expertise,
to deploy and manage container-based
applications on Microsoft Azure.
By using Azure Container Service, you can take advantage of the enterprise-grade features of Azure, while
still maintaining application portability through Kubernetes and the Docker image format.
By using these standard endpoints, you can leverage any software that is capable of talking to a
Kubernetes cluster. For example, you might choose kubectl, helm, or draft.
MCT USE ONLY. STUDENT USE PROHIBITED
10-10 DevOps in Azure
Azure Container Service leverages the Docker container format to ensure that your application containers
are fully portable. It also supports your choice of Marathon and DC/OS, Docker Swarm, or Kubernetes so
that you can scale these applications to thousands of containers, or even tens of thousands.
Using Azure Container Service, you can implement a full continuous integration and deployment (CI/CD)
pipeline using Azure Container Service with Docker Swarm, Azure Container Registry, and Visual Studio
Team Services build and release management.
Container Groups
A container group is a collection of containers that get scheduled on the same host machine. The
containers in a container group share a lifecycle, local network, and storage volumes. It is similar to
the concept of a pod in Kubernetes and DC/OS.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 10-11
The following diagram shows an example of a container group that includes multiple containers:
Objectives
After you complete this lab, you will be able to:
Lab Setup
Estimated Time: 60 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Module 11
Securing Azure Web Applications
Contents:
Module Overview 11-1
Lesson 1: Azure Active Directory 11-2
Lab: Integrating Azure Active Directory with the Events Administration Portal 11-16
Module Overview
Just like on-premises applications, applications in the cloud need streamlined security mechanisms
that are flexible. Azure Active Directory is an identity provider that can provide identity and access
functionality for your custom applications or SaaS applications. Lesson 1, “Azure Active Directory,”
introduces the Azure AD service. Lesson 2, “Azure AD Directories,” details how to create a directory in
Azure AD. Lesson 3, “Azure AD Offerings,” describes the various offerings available in Azure AD such as
B2B, B2C, and multi-factor authentication. Lesson 4, “Azure Key Vault,” introduces the Azure Key Vault
service designed to manage secrets for workloads and applications.
Objectives
After completing this module, you will be able to:
• Explain the features that are available for the directories in Azure AD.
Lesson 1
Azure Active Directory
Azure AD provides a suite of services that you can integrate with custom applications, on-premises
machines, existing domains, and third-party services.
This lesson describes the Azure AD service and its features and benefits.
Lesson Objectives
After completing this lesson, you will be able to:
With identity sync, your existing corporate credentials can be used to authenticate to new or existing
applications that are hosted in Azure. These credentials can also be used with third-party SaaS
applications such as Dropbox, Intuit, or Skype. Azure AD also offers a self-service portal where your users
can optionally manage their own passwords or groups. By using the password write-back feature, the
updated password hash is then duplicated back to your on-premises Active Directory instance.
Application developers can use Azure AD as an identity provider in their custom applications to provide a
true SSO experience to users. An existing application can be updated to use a specific Azure AD tenant for
identity. Your SaaS applications can also be modified to support Azure AD as an identity provider.
Azure AD is already in use by many cloud services today, such as Microsoft Intune and Office 365. These
services rely on the identity management capabilities provided by Azure AD. These capabilities include a
cloud-based store for directory data and a core set of identity services including user logon processes and
authentication and federation services.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-3
Local or cloud applications use a similar methodology to access identity data stored in a directory:
Azure AD Services
Azure AD is composed of multiple features. This
module focuses on two of these features,
directories and Multi-Factor Authentication.
Directory Services
Azure AD provides conceptual directories where
you can store related user accounts. Directories
can store identities synced from on premises
systems, identities created in Azure, and third-
party identities. These identities can then be
configured for use with SaaS applications.
Multi-Factor Authentication
Multi-Factor Authentication offers a second layer of authentication for your applications that is
completely managed. Your administrators simply need to configure Multi-Factor Authentication and
your applications can take advantage of the feature by using Azure AD as the authentication (identity)
provider. Multi-Factor Authentication supports authentication from mobile apps, text messages, or phone
calls.
MCT USE ONLY. STUDENT USE PROHIBITED
11-4 Securing Azure Web Applications
Note: ACS is a deprecated service. You might inherit applications that use this service
because the service is still operational.
Access Control service (ACS) is a service in Azure that federates multiple identity providers to a single set
of standardized claims. Normally you would need to write code for each identity provider and handle
their claims in a custom manner. ACS allows you to add identity providers that implement OAuth 2.0 and
map their claims to a new set of claims. For example, you can use ACS to map the claims from Microsoft,
Google, Yahoo, and Facebook to a single set of claims that your application can easily expect. This greatly
simplifies the amount of code that is necessary to support multiple identity providers. ACS also supports
identity providers that use WS-Trust or WS-Federation as their protocols. ACS can also optionally host a
logon page for your application.
ASP.NET identity provides similar functionality and is largely used in scenarios that were previously
appropriate for ACS.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-5
Lesson 2
Azure AD Directories
Azure AD directories provide a logical way to group your users and applications.
This lesson introduces directories and details the different components and integrations available for
Azure AD.
Lesson Objectives
After completing this lesson, you will be able to:
Managing Directories
Directories provide a simple and logical way to
group related identities. A directory can consist
of the following three types of identities:
• Users synced from existing Active Directory
installations (on-premise identities)
• Users added manually to the directory
(cloud-only identities)
The various management experiences for Azure AD can all be used together:
Windows PowerShell
You can use the Microsoft Azure Active Directory Module for Windows PowerShell cmdlets to accomplish
many Azure AD tenant-wide administrative tasks. Administrative tasks, such as user management and
domain management, and configuring SSO can be automated by using Windows PowerShell scripts or by
using a service such as Azure Automation.
• Syncing identity and password hash from Active Directory to Azure AD.
• Syncing identity and password hash from Active Directory to Azure AD and enabling password
writeback.
Writeback is a feature that allows your existing Active Directory identity to be updated when a change
occurs in Azure AD. When you sync identity and password hash, it is important to remember that you are
creating two identities. Managing these identities and their sync relationship is a key part of designing
authentication schemes for cloud applications.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-7
Directory Users
You can directly create accounts in a
directory for every user who accesses
your services. You also can manage the
accounts or delete them when they are
no longer needed. By default, users do
not have administrator permissions, but
you can optionally assign permissions
to them. There are three types of users
that you can create by using the
Management Portal:
You can create new users in the portal by providing the following details about the user:
• First Name
• Last Name
• Display Name
• Alias
• Role
After you create a new user, a temporary password is generated. You can then email this password to the
user. On the first login, the user will be prompted to change the temporary password.
External Users
To an Azure AD directory, you can add users from another Azure AD directory or users with Microsoft
accounts. This enables the external users to collaborate with users who already exist in your directory. This
is useful for collaborating in an environment with users who need to manage directory resources, such as
applications, without requiring those users to have an account and credentials in your directory.
When you add a user from one directory into a new directory, that user is an external user in the new
directory. Initially, the display name and user name are copied from the user's home directory and
stamped onto the external user in the other directory. From then on, the profile properties of the external
user object are entirely independent. If you make a change to the user in the home directory, such as
changing the user's name, adding a job title, and so on, those changes are not propagated to the external
user account in the other directory.
MCT USE ONLY. STUDENT USE PROHIBITED
11-8 Securing Azure Web Applications
Applications in Azure AD
Enterprise developers and SaaS providers can
develop commercial cloud services or LOB
applications that can be integrated with Azure
AD to provide secure sign-in and authorization
for their services. Azure AD also includes an
access panel for users where they can discover
what applications they can access. From this
panel, they can access their applications by using
SSO. To integrate an application or a service with
Azure AD, a developer must first register the
details about the application with Azure AD by
using the Management Portal. These steps are
similar to the steps for adding an SSO third-party application to your Azure AD instance.
Single Sign-On
Configuring SSO enables the users in your organization to be automatically signed in to any third-party
SaaS application using their Azure AD credentials. This functionality provides users with the convenience
of remembering a single password and it also increases the organization’s security by providing users with
access to only their applications. Azure AD can federate its identity to your custom application, store the
custom application’s credentials, or integrate with a third-party SSO provider.
User Provisioning
User provisioning enables automated user provisioning and deprovisioning of accounts in third-party
SaaS applications from within the Management Portal by using your Windows Server Active Directory or
Azure AD identity information. When a user is given permissions in Azure AD for one of these
applications, an account can be automatically created (provisioned) in the target SaaS application. When a
user is deleted or his or her information changes in Azure AD, these changes are also reflected in the SaaS
application. User Provisioning allows your application to automate identity lifecycle management and
enables administrators to control and provide automated provisioning and de-provisioning of user
accounts from SaaS applications.
Access Panel
The access panel in Azure AD offers a single dashboard for your organization. Users can access one or
more applications that you manage from within the Azure AD instance using a single sign-on experience
directly from this panel. Users do not require an Azure or Office 365 subscription to connect to the access
panel.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-9
Azure AD Graph
The Graph API provides programmatic access to
Azure AD through REST API endpoints. This API
can be used to store and retrieve metadata about
your users that is not part of the typical user
profile in Active Directory.
Directory Extensions
Many applications require metadata and properties for each user that is not typically stored in a standard
Active Directory user profile. The Graph API allows you to register and then use extended properties. For
example, if you need to store and then retrieve the Xbox Live ID for each user in a gaming social
application, you must first register the new property in the directory. You can then use this property in
subsequent operations because it is not available for every user object in the directory.
MCT USE ONLY. STUDENT USE PROHIBITED
11-10 Securing Azure Web Applications
Lesson 3
Azure AD Offerings
Multi-Factor Authentication is a feature in Azure AD that you can use to provide an additional layer of
authorization to your existing directory accounts. This authorization could be a phone call, mobile code
or custom application. Azure AD B2B and B2C are services in Azure AD that can extend the reach of your
directory to include partner businesses and customers.
This lesson will introduce and dive into various offerings in Azure AD.
Lesson Objectives
After completing this lesson, you will be able to:
• List the multi-factor authentication providers that are available for Azure AD.
Azure AD B2B
Azure AD business-to-business (B2B)
collaboration capabilities enable any
organization using Azure AD to work safely and
securely with users from any other organization,
small or large. Those organizations can be with
Azure AD or without, or even with an IT
organization or without.
Azure AD B2C
Azure AD B2C is a cloud identity management
solution for your web and mobile applications.
It is a highly available global service that scales
to hundreds of millions of identities. Built on an
enterprise-grade secure platform, Azure AD B2C
keeps your applications, your business, and your
customers protected.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-11
Policies
The extensible policy framework of Azure Active Directory (Azure AD) B2C is the core strength of the
service. Policies fully describe consumer identity experiences such as sign-up, sign-in, or profile editing.
For instance, a sign-up policy allows you to control behaviors by configuring the following settings:
• Account types (social accounts such as Facebook or local accounts such as email addresses) that
consumers can use to sign up for the application
• Attributes (for example, first name, postal code, and shoe size) to be collected from the consumer
during sign-up
• Information (which manifests as claims in a token) that the application receives when the policy run
finishes
You can create multiple policies of different types in your tenant and use them in your applications as
needed. Policies can be reused across applications. This flexibility enables developers to define and modify
consumer identity experiences with minimal or no changes to their code.
Policies are available for use via a simple developer interface. Your application triggers a policy by using a
standard HTTP authentication request (passing a policy parameter in the request) and receives a
customized token as response.
Multi-Factor Authentication
Multi-factor authentication is an additional layer
of security that can protect applications from
unauthorized access if a user's credentials are
compromised. To the end user, they simply
provide additional means of authentication that
can include things such as a phone, RSA key, or
custom device. Multi-factor authentication is
usually defined by having the user provide two
things:
Multi-factor authentication's strength is in its multiple layer approach. If a user's credentials are
compromised, a malicious user would still require a trusted device that is assigned to the same user to
compromise the application or its data. Typically, if a user loses a trusted device, they report it
immediately and the device can be de-authorized.
MCT USE ONLY. STUDENT USE PROHIBITED
11-12 Securing Azure Web Applications
Out of the box, Azure AD uses passwords as the default credential for user access. Multi-Factor
Authentication is a service in Azure AD that implements the previously mentioned multi-factor
authentication pattern. You can use multi-factor authentication with either Azure AD or an on-premises
directory. The second form of authentication can be a smartphone, a phone number that supports calls
or text messages, or a custom application. When using the Multi-Factor Authentication service with
Azure AD, administrators can enable multi-factor authentication specifically for each individual user. The
Multi-Factor Authentication service supports up to three phone numbers that are authorized for use as a
second form of authentication. The user can also opt to use the multi-factor authentication mobile apps
that support both push notifications and one-time pass codes as authentication options.
A software development kit (SDK) is available to integrate your custom applications with Azure AD Multi-
Factor Authentication. The SDK allows you to use the Multi-Factor Authentication phone call or text
message verification options as part of your custom application's sign-in process. This is useful if you are
building a custom application that does not redirect to Azure AD’s sign-in page and instead has a built-in
logon form.
Lesson 4
Azure Key Vault
Azure Key Vault helps safeguard cryptographic keys and secrets used by cloud applications and services.
By using Key Vault, you can encrypt keys and secrets (such as authentication keys, storage account keys,
data encryption keys, .PFX files, and passwords) using keys protected by hardware security modules
(HSMs).
This lesson introduces the Azure Key Vault service and describes how to store secrets in the service.
Lesson Objectives
After completing this lesson, you will be able to:
• Application secrets
• Authentication keys
The Azure Key vault service provides a state of the art service to secure your secrets but also achieve this
with High-performance. Microsoft has an SLA of 99.9 % with a secret processing time of 5 second
transactions.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure Solutions 11-15
Utilization
Using the Azure Key vault service, your
development team can use cryptographic keys,
certificates, passwords, and other applications
secrets without the need to access them. The Key
Vault service allows a client application or service
to access data using a URI without storing the
data locally on their side. This will improve
security of your application. The general steps
will be:
Note: Using Azure Key Vault your developer team will never have access to the keys but
will be able to access the resources they need.
MCT USE ONLY. STUDENT USE PROHIBITED
11-16 Securing Azure Web Applications
Objectives
After you complete this lab, you will be able to:
Lab Setup
Estimated Time: 60 minutes
The lab steps for this course change frequently due to updates to Microsoft Azure. Microsoft Learning
updates the lab steps frequently, so they are not available in this manual. Your instructor will provide you
with the lab documentation.
Note: The ASP.NET Identity framework is a newer way of securing web applications, and it
has certain advantages over Membership and Forms Authentication.
Review Question
Question: When you use Azure AD ACS, why should you remap the claims from each
identity provider?
MCT USE ONLY. STUDENT USE PROHIBITED
11-18 Securing Azure Web Applications
Course Evaluation
Your evaluation of this course will help Microsoft understand the quality of your learning experience.
Please work with your training provider to access the course evaluation form.
Microsoft will keep your answers to this survey private and confidential and will use your responses to
improve your future learning experience. Your open and honest feedback is valuable and appreciated.