Vous êtes sur la page 1sur 336

MCT USE ONLY.

STUDENT USE PROHIBITED


O F F I C I A L M I C R O S O F T L E A R N I N G P R O D U C T

20532A
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.

© 2014 Microsoft Corporation. All rights reserved.


Microsoft and the trademarks listed at
http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of
the Microsoft group of companies. All other trademarks are property of their respective owners.

Product Number: 20532A

Part Number (if applicable): X19-76909

Released: 09/2014
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.

a. If you are a Microsoft IT Academy Program Member:


i. Each license acquired on behalf of yourself may only be used to review one (1) copy of the Microsoft
Instructor-Led Courseware in the form provided to you. If the Microsoft Instructor-Led Courseware is
in digital format, you may install one (1) copy on up to three (3) Personal Devices. You may not
install the Microsoft Instructor-Led Courseware on a device you do not own or control.
ii. For each license you acquire on behalf of an End User or Trainer, you may either:
1. distribute one (1) hard copy version of the Microsoft Instructor-Led Courseware to one (1) End
User who is enrolled in the Authorized Training Session, and only immediately prior to the
commencement of the Authorized Training Session that is the subject matter of the Microsoft
Instructor-Led Courseware being provided, or
2. provide one (1) End User with the unique redemption code and instructions on how they can
access one (1) digital version of the Microsoft Instructor-Led Courseware, or
3. provide one (1) Trainer with the unique redemption code and instructions on how they can
access one (1) Trainer Content,
provided you comply with the following:
iii. you will only provide access to the Licensed Content to those individuals who have acquired a valid
license to the Licensed Content,
iv. you will ensure each End User attending an Authorized Training Session has their own valid licensed
copy of the Microsoft Instructor-Led Courseware that is the subject of the Authorized Training
Session,
v. you will ensure that each End User provided with the hard-copy version of the Microsoft Instructor-
Led Courseware will be presented with a copy of this agreement and each End User will agree that
their use of the Microsoft Instructor-Led Courseware will be subject to the terms in this agreement
prior to providing them with the Microsoft Instructor-Led Courseware. Each individual will be required
to denote their acceptance of this agreement in a manner that is enforceable under local law prior to
their accessing the Microsoft Instructor-Led Courseware,
vi. you will ensure that each Trainer teaching an Authorized Training Session has their own valid
licensed copy of the Trainer Content that is the subject of the Authorized Training Session,
MCT USE ONLY. STUDENT USE PROHIBITED
vii. you will only use qualified Trainers who have in-depth knowledge of and experience with the
Microsoft technology that is the subject of the Microsoft Instructor-Led Courseware being taught for
all your Authorized Training Sessions,
viii. you will only deliver a maximum of 15 hours of training per week for each Authorized Training
Session that uses a MOC title, and
ix. you acknowledge that Trainers that are not MCTs will not have access to all of the trainer resources
for the Microsoft Instructor-Led Courseware.

b. If you are a Microsoft Learning Competency Member:


i. Each license acquired on behalf of yourself may only be used to review one (1) copy of the Microsoft
Instructor-Led Courseware in the form provided to you. If the Microsoft Instructor-Led Courseware is
in digital format, you may install one (1) copy on up to three (3) Personal Devices. You may not
install the Microsoft Instructor-Led Courseware on a device you do not own or control.
ii. For each license you acquire on behalf of an End User or Trainer, you may either:
1. distribute one (1) hard copy version of the Microsoft Instructor-Led Courseware to one (1) End
User attending the Authorized Training Session and only immediately prior to the
commencement of the Authorized Training Session that is the subject matter of the Microsoft
Instructor-Led Courseware provided, or
2. provide one (1) End User attending the Authorized Training Session with the unique redemption
code and instructions on how they can access one (1) digital version of the Microsoft Instructor-
Led Courseware, or
3. you will provide one (1) Trainer with the unique redemption code and instructions on how they
can access one (1) Trainer Content,
provided you comply with the following:
iii. you will only provide access to the Licensed Content to those individuals who have acquired a valid
license to the Licensed Content,
iv. you will ensure that each End User attending an Authorized Training Session has their own valid
licensed copy of the Microsoft Instructor-Led Courseware that is the subject of the Authorized
Training Session,
v. you will ensure that each End User provided with a hard-copy version of the Microsoft Instructor-Led
Courseware will be presented with a copy of this agreement and each End User will agree that their
use of the Microsoft Instructor-Led Courseware will be subject to the terms in this agreement prior to
providing them with the Microsoft Instructor-Led Courseware. Each individual will be required to
denote their acceptance of this agreement in a manner that is enforceable under local law prior to
their accessing the Microsoft Instructor-Led Courseware,
vi. you will ensure that each Trainer teaching an Authorized Training Session has their own valid
licensed copy of the Trainer Content that is the subject of the Authorized Training Session,
vii. you will only use qualified Trainers who hold the applicable Microsoft Certification credential that is
the subject of the Microsoft Instructor-Led Courseware being taught for your Authorized Training
Sessions,
viii. you will only use qualified MCTs who also hold the applicable Microsoft Certification credential that is
the subject of the MOC title being taught for all your Authorized Training Sessions using MOC,
ix. you will only provide access to the Microsoft Instructor-Led Courseware to End Users, and
x. you will only provide access to the Trainer Content to Trainers.
MCT USE ONLY. STUDENT USE PROHIBITED
c. If you are a MPN Member:
i. Each license acquired on behalf of yourself may only be used to review one (1) copy of the Microsoft
Instructor-Led Courseware in the form provided to you. If the Microsoft Instructor-Led Courseware is
in digital format, you may install one (1) copy on up to three (3) Personal Devices. You may not
install the Microsoft Instructor-Led Courseware on a device you do not own or control.
ii. For each license you acquire on behalf of an End User or Trainer, you may either:
1. distribute one (1) hard copy version of the Microsoft Instructor-Led Courseware to one (1) End
User attending the Private Training Session, and only immediately prior to the commencement
of the Private Training Session that is the subject matter of the Microsoft Instructor-Led
Courseware being provided, or
2. provide one (1) End User who is attending the Private Training Session with the unique
redemption code and instructions on how they can access one (1) digital version of the
Microsoft Instructor-Led Courseware, or
3. you will provide one (1) Trainer who is teaching the Private Training Session with the unique
redemption code and instructions on how they can access one (1) Trainer Content,
provided you comply with the following:
iii. you will only provide access to the Licensed Content to those individuals who have acquired a valid
license to the Licensed Content,
iv. you will ensure that each End User attending an Private Training Session has their own valid licensed
copy of the Microsoft Instructor-Led Courseware that is the subject of the Private Training Session,
v. you will ensure that each End User provided with a hard copy version of the Microsoft Instructor-Led
Courseware will be presented with a copy of this agreement and each End User will agree that their
use of the Microsoft Instructor-Led Courseware will be subject to the terms in this agreement prior to
providing them with the Microsoft Instructor-Led Courseware. Each individual will be required to
denote their acceptance of this agreement in a manner that is enforceable under local law prior to
their accessing the Microsoft Instructor-Led Courseware,
vi. you will ensure that each Trainer teaching an Private Training Session has their own valid licensed
copy of the Trainer Content that is the subject of the Private Training Session,
vii. you will only use qualified Trainers who hold the applicable Microsoft Certification credential that is
the subject of the Microsoft Instructor-Led Courseware being taught for all your Private Training
Sessions,
viii. you will only use qualified MCTs who hold the applicable Microsoft Certification credential that is the
subject of the MOC title being taught for all your Private Training Sessions using MOC,
ix. you will only provide access to the Microsoft Instructor-Led Courseware to End Users, and
x. you will only provide access to the Trainer Content to Trainers.

d. If you are an End User:


For each license you acquire, you may use the Microsoft Instructor-Led Courseware solely for your
personal training use. If the Microsoft Instructor-Led Courseware is in digital format, you may access the
Microsoft Instructor-Led Courseware online using the unique redemption code provided to you by the
training provider and install and use one (1) copy of the Microsoft Instructor-Led Courseware on up to
three (3) Personal Devices. You may also print one (1) copy of the Microsoft Instructor-Led Courseware.
You may not install the Microsoft Instructor-Led Courseware on a device you do not own or control.

e. If you are a Trainer.


i. For each license you acquire, you may install and use one (1) copy of the Trainer Content in the
form provided to you on one (1) Personal Device solely to prepare and deliver an Authorized
Training Session or Private Training Session, and install one (1) additional copy on another Personal
Device as a backup copy, which may be used only to reinstall the Trainer Content. You may not
install or use a copy of the Trainer Content on a device you do not own or control. You may also
print one (1) copy of the Trainer Content solely to prepare for and deliver an Authorized Training
Session or Private Training Session.
MCT USE ONLY. STUDENT USE PROHIBITED
ii. You may customize the written portions of the Trainer Content that are logically associated with
instruction of a training session in accordance with the most recent version of the MCT agreement.
If you elect to exercise the foregoing rights, you agree to comply with the following: (i)
customizations may only be used for teaching Authorized Training Sessions and Private Training
Sessions, and (ii) all customizations will comply with this agreement. For clarity, any use of
“customize” refers only to changing the order of slides and content, and/or not using all the slides or
content, it does not mean changing or modifying any slide or content.

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.

3. LICENSED CONTENT BASED ON PRE-RELEASE TECHNOLOGY. If the Licensed Content’s subject


matter is based on a pre-release version of Microsoft technology (“Pre-release”), then in addition to the
other provisions in this agreement, these terms also apply:

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.

11. APPLICABLE LAW.


a. United States. If you acquired the Licensed Content in the United States, Washington state law governs
the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws
principles. The laws of the state where you live govern all other claims, including claims under state
consumer protection laws, unfair competition laws, and in tort.
MCT USE ONLY. STUDENT USE PROHIBITED
b. Outside the United States. If you acquired the Licensed Content in any other country, the laws of that
country apply.

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.

This limitation applies to


o anything related to the Licensed Content, services, content (including code) on third party Internet
sites or third-party programs; and
o claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence,
or other tort to the extent permitted by applicable law.

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.

LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES


DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages
directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres
dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
Cette limitation concerne:
• tout ce qui est relié au le contenu sous licence, aux services ou au contenu (y compris le code)
figurant sur des sites Internet tiers ou dans des programmes tiers; et.
• les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité
stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.
MCT USE ONLY. STUDENT USE PROHIBITED
Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si
votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires
ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre
égard.

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.

Revised July 2013


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions xi
MCT USE ONLY. STUDENT USE PROHIBITED
xii Developing Microsoft Azure™ Solutions

Acknowledgments
Microsoft Learning wants to acknowledge and thank the following for their contribution toward
developing this title. Their effort at various stages in the development has ensured that you have a good
classroom experience.

Sidney Andrews – Lead Content Developer


Sidney Andrews is an Azure™ consultant and XAML subject matter expert with SeeSharpRun.NET. As a
Microsoft Certified Trainer, Sidney has offered training in various developer courses and delivered exam
prep sessions at Microsoft conferences. As a consultant, Sidney has designed and implemented multiple
complex web solutions based on the ASP.NET stack and the Azure™ service offerings.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions xiii

Contents
Module 1: Overview of the Microsoft Azure Platform
Lesson 1: Azure Services 1-2
Lesson 2: Management Portals 1-5

Module 2: Establishing a Development Environment using Azure Virtual Machines


Lesson 1: Constructing Azure Virtual Machines 2-2
Lesson 2: Azure Virtual Machine Workloads 2-4
Lesson 3: Migrating Azure Virtual Machine Instances 2-5
Lab: Creating an Azure Virtual Machine for Development & Testing 2-7

Module 3: Managing Infrastructure in Azure


Lesson 1: Azure Virtual Networks 3-2
Lesson 2: Highly Available Azure Virtual Machines 3-3
Lesson 3: Virtual Machine Configuration Management 3-4
Lesson 4: Customizing Azure Virtual Machine Networking 3-6
Lab: Managing Multiple Virtual Machines in a Virtual Network 3-8

Module 4: Web Infrastructure in the Azure Platform


Lesson 1: Azure Web Sites 4-2
Lesson 2: Hosting Web Applications in Azure 4-4
Lesson 3: Configuring an Azure Web Site 4-6
Lesson 4: Publishing an Azure Web Site 4-8
Lesson 5: Monitoring an Azure Web Site 4-10
Lab: Creating an ASP.NET Web Site Using Azure Web Sites 4-13

Module 5: Designing Cloud Applications for Resiliency


Lesson 1: Application Design Practices for Highly Available Applications 5-2
Lesson 2: Building High Performance Applications using ASP.NET 5-4
Lesson 3: Common Cloud Application Patterns 5-6
Lesson 4: Application Analysis 5-8
Lesson 5: Caching Application Data 5-10

Module 6: Processing Background Logic using Azure


Lesson 1: Understanding Cloud Services 6-3
Lesson 2: Cloud Service Web Roles 6-5
Lesson 3: Customizing Cloud Service Configurations 6-7
Lesson 4: Updating and Managing Azure Cloud Service Deployments 6-9
Lesson 5: Cloud Service Worker Roles 6-11
Lesson 6: Cloud Service Worker Role Processing 6-13
Lesson 7: Caching Data using Roles 6-15
Lesson 8: Analyzing Applications in Cloud Service Role Instances 6-17
Lab: Creating a Background Process Using Azure Worker Roles 6-19
MCT USE ONLY. STUDENT USE PROHIBITED
xiv Developing Microsoft Azure™ Solutions

Module 7: Storing Tabular Data in Azure


Lesson 1: Azure SQL Databases Overview 7-3
Lesson 2: Managing SQL Databases in Azure 7-5
Lesson 3: Using Azure SQL Databases with SQL Server Data Tools 7-7
Lesson 4: Migrating Data to Azure SQL Databases 7-9
Lesson 5: Replication and Recovery of Azure SQL Database Instances 7-11
Lab A: Storing Event Data in Azure SQL Databases 7-13
Lesson 6: Azure Storage Overview 7-17
Lesson 7: Azure Storage Tables Overview 7-19
Lesson 8: Table Entity Transactions 7-21
Lab B: Storing Event Registration Data in Azure Storage Tables 7-25

Module 8: Storing Files and Media in Azure


Lesson 1: Azure Storage Blobs 8-2
Lesson 2: Controlling Access to Storage Blobs & Containers 8-4
Lesson 3: Monitoring Storage Blobs 8-6
Lesson 4: Configuring Azure Storage Accounts 8-8
Lesson 5: Azure Files 8-9
Lesson 6: Uploading and Migrating Storage Data 8-10
Lab: Storing Generated Documents in Azure Storage Blobs 8-12

Module 9: Storing Data in Queues using Azure


Lesson 1: Queue Mechanisms in Azure 9-2
Lesson 2: Azure Storage Queues Overview 9-3
Lesson 3: Handling Storage Queue Messages 9-5
Lesson 4: Azure Service Bus 9-6
Lesson 5: Azure Service Bus Queues 9-8
Lesson 6: Azure Service Bus Relay 9-10
Lesson 7: Azure Service Bus Notification Hubs 9-12
Lab: Using Queues and Service Bus to Manage Communication in Azure 9-14

Module 10: Automating Integration with Azure Resources


Lesson 1: Azure SDK Client Libraries 10-2
Lesson 2: Scripting Azure Service Management using PowerShell 10-3
Lesson 3: Azure REST Interface 10-6
Lesson 4: Azure Resource Manager 10-7
Lab: Automating the Creation of a Test Environment using PowerShell 10-10

Module 11: Implementing Security in Web Applications using Azure


Lesson 1: Azure Active Directory 11-2
Lesson 2: Azure AD Directories 11-4
Lesson 3: Azure AD Access Control Service 11-6
Lesson 4: Azure AD Multi-Factor Authentication 11-7
Lab: Integrating Azure Active Directory with the Events Administration Portal 11-8
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions xv

Module 12: Deploying Web Applications to Azure


Lesson 1: Deployment Strategies for Web Applications 12-2
Lesson 2: Deploying Azure Web Sites 12-4
Lesson 3: Deploying Azure Cloud Services 12-6
Lesson 4: Continuous Integration 12-8
Lesson 5: Monitoring Cloud Applications 12-9
Lab: Deploying the Events Web Application to Azure 12-11

Lab Answer Keys


Module 2 Lab: Creating an Azure Virtual Machine for Development & Testing L2-1
Module 3 Lab: Managing Multiple Virtual Machines in a Virtual Network L3-1
Module 4 Lab: Creating an ASP.NET Web Site Using Azure Web Sites L4-1
Module 6 Lab: Creating a Background Process Using Azure Worker Roles L6-1
Module 7 Lab A: Storing Event Data in Azure SQL Databases L7-1
Module 7 Lab B: Storing Event Registration Data in Azure Storage Tables L7-7
Module 8 Lab: Storing Generated Documents in Azure Storage Blobs L8-1
Module 9 Lab: Using Queues and Service Bus to Manage Communication in Azure L9-1
Module 10 Lab: Automating the Creation of a Test Environment using PowerShell L10-1
Module 11 Lab: Integrating Azure Active Directory with the Events Administration Portal L11-1
Module 12 Lab: Deploying the Events Web Application to Azure L12-1
MCT USE ONLY. STUDENT USE PROHIBITED
xvi Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course xvii

About This Course


This section provides a brief description of the course, audience, suggested prerequisites, and course
objectives.

Course Description

Note: This first release (‘A’) MOC version of course 20532A has been developed on pre-release
software. Microsoft Learning will release a ‘B’ version of this course with enhanced PowerPoint
slides, copy-edited content, and Course Companion content on Microsoft Learning site.

This course is intended for students who have experience building vertically scaled applications. Students
will also have experience with the Microsoft Azure platform and a basic understanding of the services
offered.
This course offers students the opportunity to take an existing ASP.NET MVC application and expand its
functionality as part of moving it to Azure. This course focuses on the considerations 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
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.

Student Prerequisites
In addition to their professional experience, students must have experience working with the Azure
platform. They will also have a general understanding of ASP.NET and C# concepts for the lab scenario.
Candidates experience can include:
• Compare services available in the Azure platform

• Configure and deploy ASP.NET web applications

• Creating Azure WebSites from the gallery


• Deploying and monitoring Azure WebSites

• Creating and configuring Azure Virtual Machines

• Describe the relationship between Cloud Services and Virtual Machines


• Deploy existing Cloud Service packages

• Create and manage a Storage account

• Manage blobs and containers in a Storage account


• Create, configure and connect to a SQL Databases instance

• Identify the implications of importing a SQL Standalone database

• Manage users, groups and subscriptions in an Azure Active Directory instance

• Create a virtual network


MCT USE ONLY. STUDENT USE PROHIBITED
xviii About This Course

• Implement a point to site network

Course Objectives
After completing this course, students will be able to:

• Compare the services available in the Azure platform.

• Configure and deploy ASP.NET web applications.

• Creating Azure WebSites from the gallery.

• Deploying and monitoring Azure WebSites.

• Creating and configuring Azure Virtual Machines.

• Describe the relationship between Cloud Services and Virtual Machines.

• Deploy existing Cloud Service packages.

• Create and manage a Storage account.

• Manage blobs and containers in a Storage account.

• Create, configure and connect to a SQL Databases instance.

• Identify the implications of importing a SQL Standalone database.

• Manage users, groups and subscriptions in an Azure Active Directory instance.


• Create a virtual network.

• Implement a point to site network.

Course Outline
The course outline is as follows:
Module 1, "Overview of the Microsoft Azure Platform"

Module 2, "Establishing a Development Environment using Azure Virtual Machines"

Module 3, "Managing Infrastructure in Azure"


Module 4, "Web Infrastructure in the Azure Platform"

Module 5, "Designing Cloud Applications for Resiliency"

Module 6, "Processing Background Logic using Azure"

Module 7, "Storing Tabular Data in Azure"


Module 8, "Storing Files and Media in Azure"

Module 9, "Storing Data in Queues using Azure"

Module 10, "Automating Integration with Azure Resources"

Module 11, "Implementing Security in Web Applications using Azure"

Module 12, "Deploying Web Applications to Azure"

Course Materials
The following materials are included with your kit:
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course xix

• Course Handbook: 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.

• Lessons: guide you through the learning objectives and provide the key points that are critical to
the success of the in-class learning experience.

• Labs: provide a real-world, hands-on platform for you to apply the knowledge and skills learned
in the module.

• Module Reviews and Takeaways: provide on-the-job reference material to boost knowledge
and skills retention.

• Lab Answer Keys: provide step-by-step lab solution guidance.


Course Companion Content: searchable, easy-to-browse digital content with integrated premium
online resources that supplement the Course Handbook.

• Modules: include companion content, such as questions and answers, detailed demo steps and
additional reading links, for each lesson. Additionally, they 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
most current premium content on TechNet, MSDN®, or Microsoft® Press®.

Note: For this version of the Courseware on Prerelease Software, Companion Content is not
available. However, the Companion Content will be published when the next (B) version of this
course is released, and students who have taken this course will be able to download the
Companion Content at that time from the
http://www.microsoft.com/learning/companionmoc site. Please check with your instructor
when the ‘B’ version of this course is scheduled to release to learn when you can access
Companion Content for this course.

Student Course files: includes the Allfiles.exe, a self-extracting executable file that contains all
required files for the labs and demonstrations.
Note: The Student Allfiles for this version of course is available on
http://www.microsoft.com/learning/companionmoc/ site

• 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.

• To provide additional comments or feedback on the course, send an email to


support@mscourseware.com. To inquire about the Microsoft Certification Program, send an
email to mcphelp@microsoft.com.
MCT USE ONLY. STUDENT USE PROHIBITED
xx About This Course

Virtual Machine Environment


This section provides the information for setting up the classroom environment to support the business
scenario of the course.

Virtual Machine Configuration


This course is not shipped with virtual machine. Lab steps will be performed directly on Azure. Students
will require Azure accounts to be able to complete the Labs.

Course Files
The files associated with the labs in this course are available on
http://www.microsoft.com/learning/companionmoc/ site

Classroom Setup
This course requires a classroom with a minimum of one computer for the instructor and one for each
student. This course requires that the instructor and student computers have internet access. Students will
require Azure accounts to be able to complete the Labs.

Course Hardware Level


To ensure a satisfactory student experience, Microsoft Learning requires a minimum equipment
configuration for trainer and student computers in all Microsoft Certified Partner for Learning Solutions
(CPLS) classrooms in which Official Microsoft Learning Product courseware is taught.

Hardware Level 6
• Processor: 64 bit Intel Virtualization Technology (Intel VT) or AMD Virtualization (AMD-V) processor
(2.8 Ghz dual core or better recommended)
• Hard Disk: Dual 120 GB hard disks 7200 RPM SATA or better (striped)
• RAM: 4 GB RAM expandable to 8GB or higher
• DVD/CD: DVD; dual layer recommended.
• Network Adapter
• Sound Card with amplified speakers
• Monitor: Super VGA monitor (17 inch/43 cm)
In addition, the instructor computer must be connected to a projection display device that supports SVGA
1024 x 768 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

Lesson 2: Management Portals 1-5


Module Review and Takeaways 1-8

Module Overview
Microsoft Azure provides a collection of services that can be used as building blocks for your cloud
applications. Lesson 1, “Azure Services”, provides a recap of services you may have worked with when
using the Azure platform in the past. Lesson 2, “Management Portals”, describes the two current portals
available for managing Azure subscriptions and services. Lesson 3, “Lab Overview”, provides a
walkthrough of the lab application that you will be working on throughout the course.

Objectives
After completing this module, you will be able to:

• Describe some of the common Azure services


• Describe the differences between the current and Ibiza management portals.
MCT USE ONLY. STUDENT USE PROHIBITED
1-2 Overview of the Microsoft Azure™ Platform

Lesson 1
Azure Services
This lesson describes some of the common services and features that are available in Azure and used by
many entry-level Azure developers and IT pros.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the following common Azure services


o Web Sites

o Virtual Machines

o Cloud Services
o Storage

o SQL Databases

o Virtual Networks

Services Overview

Web Sites
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 1-3

Virtual Machines

Cloud Services

Storage
MCT USE ONLY. STUDENT USE PROHIBITED
1-4 Overview of the Microsoft Azure™ Platform

SQL Databases

Virtual Networks

App Services
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 1-5

Lesson 2
Management Portals
As the Azure platform has grown, there have been many iterations of the services available and web
applications used to manage the services.

This lesson will describe the three latest iterations of the Management Portal used for configuring
instances of Azure services. This lesson will also provide a walkthrough of how to switch between the two
Azure Management Portals when you require functionality that is not available in the Preview Portal.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the current Azure Management Portal.


• Describe the Azure Preview Portal (Ibiza).

• Switch between the different portals.

History of Azure Management Portals

Azure Management Portal


MCT USE ONLY. STUDENT USE PROHIBITED
1-6 Overview of the Microsoft Azure™ Platform

Azure Preview Portal (Ibiza)

Demonstration: Using the Azure Preview Portal


For this demo, you will use the available host machine. Before you begin this lab, you must complete the
following steps:
1. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Open the Azure Preview Portal (https://portal.azure.com).
2. View the Customization mode for the Startboard.

3. Close the Customization mode for the Startboard.


4. Open the New panel and click the Everything link.
5. In the Gallery blade, select the Virtual Machines group, and the Create option for Ubuntu Server to
begin a new Journey.

6. In the Create VM (Ubuntu Server) journey, view the journey part for creating an associated Virtual
Network.

7. Close the Create VM blade to view the warning dialog for losing changes in a journey or part.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 1-7

Portal URLs

Demonstration: Switching Between the Portals


For this demo, you will use the available host machine. Before you begin this lab, you must complete the
following steps:
• Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Open the Azure Management Portal (https://manage.windowsazure.com).
2. Login using your Microsoft Account credentials associated with your Azure account.

3. Create a Web Site instance using the Quick Create options and these details:
o Url: Pick a unique name for the website
o Web Hosting Plan: Create new hosting plan

o Region: Pick the region closest to you


4. Switch to the new Preview Portal.

5. View the details for the Website created in the previous steps.

6. Browse to your new Website.


Note: The placeholder page shows a message indicating that your website has been successfully
created. This placeholder page will appear until you upload a web application to your new website.
MCT USE ONLY. STUDENT USE PROHIBITED
1-8 Overview of the Microsoft Azure™ Platform

Module Review and Takeaways


In this module you have learned about Azure as a platform and its capabilities. You also got to preview
the tools and features that we use to manage an Azure subscription.

Best Practice: Many of the services covered in this module are pre-requisites for the
course. If there are any services mentioned that you have never worked with, 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(s)
Question: You are building an iOS and Android application. Your application will need a
back-end web service and you have 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
Establishing a Development Environment using Azure™
Virtual Machines
Contents:
Module Overview 2-1

Lesson 1: Constructing Azure Virtual Machines 2-2


Lesson 2: Azure Virtual Machine Workloads 2-4

Lesson 3: Migrating Azure Virtual Machine Instances 2-5


Lab: Creating an Azure Virtual Machine for Development & Testing 2-7
Module Review and Takeaways 2-11

Module Overview
While many of the Azure services use virtualized machines, sometimes your application has a unique
enough need that you would like a Virtual Machine (VM) that is completely unmanaged. As part of its
Infrastructure as a Service (IaaS) offerings, Azure provides networking, backup and virtualization services.
Lesson 1, “Azure Virtual Machines”, introduces the Virtual Machines service and described the options for
creating a virtual machine. Lesson 2, “Azure Virtual Machine Workloads”, details the types of workloads
that can be deployed to a Virtual Machine. Lesson 3, “Migrating Azure Virtual Machine Instances”,
discusses the options for migrating VMs to and from Azure.

Objectives
After completing this module, you will be able to:
• Describe the Virtual Machines service in Azure.

• Deploy a Linux or Microsoft workload to a Virtual Machine.

• Ingress VHDs to Azure.


• Monitor Virtual Machine endpoints.
MCT USE ONLY. STUDENT USE PROHIBITED
2-2 Establishing a Development Environment using Azure™ Virtual Machines

Lesson 1
Constructing Azure Virtual Machines
Virtual Machines in Azure provides quick compute that can be scaled out and completely customized.
With a large collection of templates provided in the Management Portal, it is very easy to get started with
a popular server OS.

This lesson will describe the Virtual Machine service in Azure and detail some of its unique features.

Lesson Objectives
After completing this lesson, you will be able to:
• Describe the Azure Virtual Machines service.

• Describe the pre-built and custom image options.

Virtual Machines Overview

Using Images to Construct Virtual Machines


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 2-3

Capturing a VM Image

VM Depot

Demonstration: Create a Virtual Machine in Azure


Demonstration Steps
1. Log into the Azure Preview Portal (https://portal.azure.com).

2. Click Get Started.

3. View the list of Virtual Machines for your subscription.


4. Create a Virtual Machine with the following details:

o Host Name: vm20532[Your Name Here]

o User Name: testuser


o Password: TestPa$$w0rd

o Pricing Tier: A2 Standard

5. Connect to the newly created Virtual Machine using Remote Desktop.


MCT USE ONLY. STUDENT USE PROHIBITED
2-4 Establishing a Development Environment using Azure™ Virtual Machines

Lesson 2
Azure Virtual Machine Workloads
Your existing application workloads can be deployed to Azure Virtual Machines whether they run on
Windows or Linux.

This lesson will describe some of the considerations for deploying application workloads to Virtual
Machines in Azure.

Lesson Objectives
After completing this lesson, you will be able to describe the considerations when deploying Windows or
Linux workloads to Azure.

Windows Workloads

Linux Workloads
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 2-5

Lesson 3
Migrating Azure Virtual Machine Instances
Azure provides infrastructure options that makes it easy to either extend your existing data center or
create a new environment in the cloud. With Networking, Backup, Recovery and Virtual Machines; Azure
has the services necessary to deploy your existing complex production applications.

This lesson describes the various methods of migrating your Virtual Machines to Azure.

Lesson Objectives
After completing this lesson, you will be able to:
• Migrate VMs to Azure.

• Describe the Azure Backup service.

• Describe the Hyper-V Recovery Manager service.

Migrating Virtual Machines to Azure

Migrating Linux VMs to Azure


MCT USE ONLY. STUDENT USE PROHIBITED
2-6 Establishing a Development Environment using Azure™ Virtual Machines

Backup & Recovery Manager


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 2-7

Lab: Creating an Azure Virtual Machine for Development


& Testing
Scenario
Before you begin the process

Objectives
After you complete this lab, you will be able to:

• Create an Affinity Group in your Azure subscription

• Create a Virtual Network


• Create a Storage instance

• Create a Virtual Machine


• Manage the Virtual Machine drives
• Install development software on a Virtual Machine

Estimated Time: 90 minutes


For this demo, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

1. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create a Logical Network using Azure


Scenario
You need to create a Virtual Network to use for your new Virtual Machine.

The main tasks for this exercise are as follows:


1. Login to the Azure Preview Portal

2. Create a Virtual Network

 Task 1: Login to the Azure Preview Portal


1. Log into the Azure Preview Portal (https://portal.azure.com).
2. Click Get Started.

 Task 2: Create a Virtual Network


1. View the list of Virtual Networks for your subscription.

2. Use the Azure Management Portal (https://manage.windowsazure.com) to create your Virtual


Network.
Note: Creating Virtual Networks is not available in the Preview Portal yet.

3. Create a Virtual Network with the following details:

o Name: Net20532A

o Location: Select the region that is closest to your location

o Address Space: 10.---.---.---


MCT USE ONLY. STUDENT USE PROHIBITED
2-8 Establishing a Development Environment using Azure™ Virtual Machines

o Maximum VM Count: 4096 [CIDR: /20]

o DNS Server: None

4. Return to the Azure Preview Portal.

Results: After completing this exercise, you will have a new Virtual Network in Azure.

Exercise 2: Create a Development Virtual Machine using Azure


Scenario
You need a new storage account that you will use when creating your Virtual Machine.

The main tasks for this exercise are as follows:


1. Create a Storage Account

2. Create a Virtual Machine

 Task 1: Create a Storage Account


1. View the list of Storage instances for your subscription.
2. Create a Storage instance with the following details:

o Name: stor20532[Your Name Here]

o Location: Select the region that is closest to your location


3. Pricing Tier (Replication): Locally Redundant (L1 LRS)

 Task 2: Create a Virtual Machine


1. View the list of Virtual Machines for your subscription.

2. Create a Virtual Machine with the following details:


o Host Name: vm20532a[Your Name Here]

o User Name: testuser

o Password: TestPa$$w0rd
o Pricing Tier: A3 Standard

o Virtual Network: Net20532A

o Storage Account: stor20532[Your Name Here]


3. Add a second disk to the Virtual Machine with the following settings:

o Disk File Name: vm20532a-AllFiles.vhd

o Size (GB): 6
o Storage Account: stor20532[Your Name Here]

o Storage Container: vhds

4. Connect to the newly created Virtual Machine using Remote Desktop.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 2-9

Results: After completing this exercise, you will have a new Virtual Machine stored in a new Storage
account.

Exercise 3: Configure the Virtual Machine for Development


Scenario
Now that you have a new Virtual Machine, you have decided to install Visual Studio 2013 Ultimate with
Update 3 applied and the Azure SDK for .NET 2.4.

The main tasks for this exercise are as follows:


1. Create an AllFiles drive

2. Install Visual Studio 2013 Ultimate Update 3

3. Install Azure SDK for .NET 2.4

 Task 1: Create an AllFiles drive


1. If Server Manager is not already open, open Server Manager.

2. Disable the Internet Explorer Enhanced Security Configuration.


3. Format the new empty drive partition using these settings:

o Drive Letter: F

o Volume Label: AllFiles


o Partition Style: MBR (Master Boot Record)

4. Download the 20532A AllFiles compressed folder from the Companion MOC website
(http://www.microsoft.com/learning/companionmoc).
5. Extract the AllFiles content to the F: drive
6. Extract target: Allfiles (F):\

 Task 2: Install Visual Studio 2013 Ultimate Update 3


1. Download and run the Visual Studio 2013 Ultimate installation executable.

o Url: http://go.microsoft.com/fwlink/?LinkID=510170
2. Install the Visual Studio 2013 Ultimate Trial.
3. Reconnect to the Virtual Machine.
4. Launch Visual Studio 2013 Ultimate for the first time.
5. Close Visual Studio 2013 Ultimate.

 Task 3: Install Azure SDK for .NET 2.4


1. Download and run the Azure SDK for .NET 2.4 launcher for Web Platform Installer.

o Url: http://go.microsoft.com/fwlink/?LinkID=510171
2. In Web Platform Installer, install the Windows Azure SDK for .NET (VS 2013) – 2.4 package.

3. Open Visual Studio 2013.

4. Open the Azure node of the Server Explorer pane.


5. Import your Azure subscription.
MCT USE ONLY. STUDENT USE PROHIBITED
2-10 Establishing a Development Environment using Azure™ Virtual Machines

Results: After completing this exercise, your development Virtual Machine will have Visual Studio and the
Azure SDK installed.

Exercise 4: Create an Image from the Virtual Machine


Scenario
You now need to create a generalized image from your development Virtual Machine so that you can
create new duplicate VMs easily in the future.

The main tasks for this exercise are as follows:

1. Use the System Preperation Tool with the Azure Virtual Machine

2. Capture a Virtual Machine Image

 Task 1: Use the System Preperation Tool with the Azure Virtual Machine
1. Open a Command Prompt window as an administrator.

2. Change the directory to %windir%\system32\sysprep.


3. Run the System Preperation Tool (sysprep.exe) and select the following options:

o System Cleanup Action: Enter System Out-of-Box Experience (OOBE)

o Generalize: Yes
o Shutdown Options: Shutdown

Note: You will be disconnected from the Virtual Machine once SysPrep is completed. The VM
will shutdown and this will close your RDP connection.

 Task 2: Capture a Virtual Machine Image


1. Log into the Azure Management Portal (https://manage.windowsazure.com).
2. View the list of Virtual Machines for your subscription.

3. Capture an image from your running Virtual Machine using the following options:
o Image Name: vm20532Template

o Image Description: Template for 20532 VM

4. I have run Sysprep on the virtual machine: Yes

Results: After completing this exercise, you will have a custom image in Azure that can be used to create
new Virtual Machines.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 2-11

Module Review and Takeaways


In this module, you were introduced to the Infrastructure as a Service (IaaS) offerings in Azure. With
Virtual Networks, Virtual Machines, Backup and Recovery, there are a lot of building blocks that can be
used when designing a network of VMs or extending an existing data center.
MCT USE ONLY. STUDENT USE PROHIBITED
2-12 Establishing a Development Environment using Azure™ Virtual Machines
MCT USE ONLY. STUDENT USE PROHIBITED
3-1

Module 3
Managing Infrastructure in Azure™
Contents:
Module Overview 3-1

Lesson 1: Azure Virtual Networks 3-2

Lesson 2: Highly Available Azure Virtual Machines 3-3


Lesson 3: Virtual Machine Configuration Management 3-4

Lesson 4: Customizing Azure Virtual Machine Networking 3-6


Lab: Managing Multiple Virtual Machines in a Virtual Network 3-8
Lesson 5: Using Remote Desktop Protocol (RDP) to Connect to a Virtual Machine3-14

Module Review and Takeaways 3-15

Module Overview
Creating Virtual Machines is simply the beginning of the options and functionality you will use with
Azure’s infrastructure services. For developer operations (DevOps) tasks, you will need to be able to
deploy VMs, manage configurations and networks along with customizing both your infrastructure
compute instances and their network connectivity to meet your outbound connection requirements.
Lesson 1, “Azure Virtual Networks”, reviews the VNET offering available in Azure. Lesson 2, “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 3, “Virtual Machine
Configuration Management”, showcases common methods of reliably managing and duplicating
configuration for VMs. Lesson 4, “Customizing Azure Virtual Machine Networking”, reviews the options
for managing inbound/outbound connection rules for your VM.

Objectives
After completing this module, you will be able to:

• Create a Virtual Network

• Describe options for allowing anonymous and private access to a VM and its port
• Customize the networking rules for a VM
MCT USE ONLY. STUDENT USE PROHIBITED
3-2 Managing Infrastructure in Azure™

Lesson 1
Azure Virtual Networks
Virtual Networks in Azure provides a method of logically grouping related service instances such as Cloud
Services and Virtual Machines. These services can then communicate privately without the need to create
an anonymous, publically accessible endpoint.

This lesson will describe the Virtual Network offering in Azure.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Virtual Network service

• Add a service instance to a Virtual Network

Customizing Virtual Network Configuration using XML

Deploying Services to a Virtual Network


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-3

Lesson 2
Highly Available Azure Virtual Machines
Horizontal or vertical scaling can be used with Virtual Machines and load balancing for a High Availability
scenario. Availability Sets also affect the availability of your VMs during faults or upgrades.

This lesson will describe the considerations for designing your Virtual Machine collections for high
availability scenarios.

Lesson Objectives
After completing this lesson, you will be able to:

• Scale Virtual Machine instances horizontally or vertically.

• Describe how fault and upgrade domains affect VM availability.

Scaling Virtual Machines

Availability Sets
MCT USE ONLY. STUDENT USE PROHIBITED
3-4 Managing Infrastructure in Azure™

Lesson 3
Virtual Machine Configuration Management
Although each Virtual Machine can be configured manually, automating the configuration of a VM can
lead to repeatable, efficient, and testable deployment scenarios. Automating configuration can also
ensure that newly scaled instances of a VM match the other instances.

This lesson will discuss some of the most common methods of configuration management.

Lesson Objectives
After completing this lesson, you will be able to:

• Explain how PowerShell Desired State Configuration can be used for Virtual Machine configuration
management.
• Describe the VM Agent service in Azure Virtual Machines.

• Describe the Configuration Management tools.

PowerShell Desired State Configuration

VM Agent
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-5

Configuration Management Tools


MCT USE ONLY. STUDENT USE PROHIBITED
3-6 Managing Infrastructure in Azure™

Lesson 4
Customizing Azure Virtual Machine Networking
While Azure Virtual Machines can be useful right away after their creation, additional configuration may
need to be performed before interfacing these instances with external resources or other VMs.

This lesson will describe the methods used for customizing the network connectivity of an Azure Virtual
Machine.

Lesson Objectives
After completing this lesson, you will be able to:

• Use Custom Endpoints to expose public ports for a Virtual Machine.

• Customize the Access Control List for a Virtual Machine/Cloud Service.

• Modify Windows Firewall in a Virtual Machine.


• View the Public VIP for a Virtual Machine.

Custom Endpoints

Access Control List


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-7

Firewall Rules

Public VIP
MCT USE ONLY. STUDENT USE PROHIBITED
3-8 Managing Infrastructure in Azure™

Lab: Managing Multiple Virtual Machines in a Virtual


Network
Scenario
To best replicate your existing production systems, you have decided to create a Virtual Network and host
another Virtual Machine in the Virtual Network. This new Virtual Machine will contain a SQL database
that you will use for your test application.

Objectives
After you complete this lab, you will be able to:

• Create a Virtual Network

• Create a Virtual Machine using a custom image

• Create a Virtual Machine using a standard image


• Add a new Virtual Machine to a Virtual Network

• Create an endpoint for a Virtual Machine

Estimated Time: 45 minutes


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:
1. Prior to starting this lab, you must have completed the lab in Module 2.

2. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create the Database Virtual Machine


Scenario
For your test application, you need a new Virtual Machine with SQL Server 2014 installed. You also need
to configure this Virtual Machine so that it can be accessed by other Virtual Machines on the same
network.
The main tasks for this exercise are as follows:
1. Login to the Azure Preview Portal

2. Create the SQL Server 2014 Standard Virtual Machine

3. Add a Rule to the Windows Firewall for SQL Server


4. Enable Mixed Mode Authentication for SQL Server

 Task 1: Login to the Azure Preview Portal


1. Log into the Azure Preview Portal (https://portal.azure.com).

2. Click Get Started.

 Task 2: Create the SQL Server 2014 Standard Virtual Machine


1. Create a SQL Server 2014 Standard Virtual Machine with the following details:

o Host Name: db20532a[Your Name Here]

o User Name: testuser


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-9

o Password: TestPa$$w0rd

o Pricing Tier: A2 Standard

o Virtual Network: Net20532A

o Storage Account: stor20532[Your Name Here]


2. Record the Internal IP address of the SQL Server Virtual Machine.

3. Connect to the newly created Virtual Machine using Remote Desktop.

 Task 3: Add a Rule to the Windows Firewall for SQL Server


1. Open the Windows Firewall with Advanced Security application.
2. Create a new Inbound Rule with the following details:

o Rule Type: Port

o Port Type: TCP


o Local Ports: 1433

o Action: Allow the connection


o Apply for Domain: Yes

o Apply for Private: Yes

3. Apply for Public: Yes

 Task 4: Enable Mixed Mode Authentication for SQL Server


1. Open the SQL Server 2014 Management Studio application.
2. Connect to your local SQL Server instance using the following details:

o Server type: Database Engine


o Server name: .
o Authentication: Windows Authentication

3. Enable SQL Server and Windows Authentication Mode in the SQL Server Settings menu.

4. Restart the SQL Server instance.


5. Add a new Login to the SQL Server instance with the following details:

o Login name: dbuser

o Login type: SQL Server authentication


o Password: TestPa$$word

o Enforce password policy: No

o Enforce password expiration: No


o User must change password at next login: No

o Server Roles: public, sysadmin


6. Create a new database with the name Contoso.Test.

7. Close the Remote Desktop application.


MCT USE ONLY. STUDENT USE PROHIBITED
3-10 Managing Infrastructure in Azure™

Results: After completing this exercise, your will have a new Virtual Machine with SQL installed that can
use Mixed Mode authentication when accessed by an external Virtual Machine.

Exercise 2: Create the Application Virtual Machines


Scenario
You will re-create your development environment by using the image created in Module 2.

The main tasks for this exercise are as follows:


1. Switch to the Azure Management Portal

2. Create the Application Virtual Machine from an Existing Image

 Task 1: Switch to the Azure Management Portal


1. Switch back to the Internet Explorer application and the Azure Preview Portal.
2. Open the Azure Management Portal (https://manage.windowsazure.com).

 Task 2: Create the Application Virtual Machine from an Existing Image


1. Create a new Virtual Machine with the following details:

o Image: vm20532Template
o Host Name: vm20532a[Your Name Here]

o User Name: testuser

o Password: TestPa$$w0rd
o Pricing Tier: A2 Standard

2. Virtual Network: Net20532A

Results: After completing this exercise, you will have a new Virtual Machine created from your
development image.

Exercise 3: Connect the Test Application to the SQL Server Virtual Machine
Scenario
You have a test ASP.NET application that can verify whether or not you can access a SQL Server instance.
You will debug this application in your development Virtual Machine to verify that you can access your
SQL Server instance on the private network.

The main tasks for this exercise are as follows:

1. Login to the Azure Preview Portal

2. Retrieve your SQL Server Virtual Machine’s Internal IP Address

3. Connect to the Application Virtual Machine

4. Repair the Azure SDK for .NET Storage Emulator Installation

5. Debug the Contoso.Events Database Test Web Application

 Task 1: Login to the Azure Preview Portal


1. Switch back to the Azure Preview Portal tab in the Internet Explorer window.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-11

 Task 2: Retrieve your SQL Server Virtual Machine’s Internal IP Address


1. View the list of Virtual Machine instances for your subscription

2. View the blade for your db20532a[Your Name Here] Virtual Machine.

3. Log the Internal IP Address for your Virtual Machine instance.

 Task 3: Connect to the Application Virtual Machine


1. Use Remote Desktop to connect to your vm20532a[Your Name Here] Virtual Machine instance.

 Task 4: Repair the Azure SDK for .NET Storage Emulator Installation

Note: When using SysPrep with your original application VM, the user that installed the
Storage Emulator is removed. When you create a new VM from the template, you create a new
user and this user does not have access to some of the files and applications that the old user
could access. Because of this, you must repair the Storage Emulator Installation.

1. Download and run the WindowsAzureStorageEmulator.msi installer.

o Url: http://go.microsoft.com/fwlink/?LinkID=510171

2. During the installation wizard, select the Repair option.

 Task 5: Debug the Contoso.Events Database Test Web Application


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod03\Labfiles\Starter\Contoso.Events

Note: Since this is your first time starting Visual Studio with this sysprep image, you will
have to walk through the setup steps for Visual Studio again. Visual Studio detects that you are a
“new user” using the product for the first time.

2. Debug the web application and provide the SQL Server VM’s Internal IP Address to the IP Address
dialog on the home page to test that you can connect to the VM successfully in your Virtual Network.

Note: Even though you can successfully connect to your VM in the VNET, this does not necessarily
mean that the VM is accessible through the same ports to the outside world.

3. Close Internet Explorer.

Results: After completing this exercise, you will have used the Internal IP address of the Database Virtual
Machine in your Virtual Network to connect to SQL Server 2014.

Exercise 4: Modify the Application Virtual Machine into a Web Server


Scenario
You will now turn your development Virtual Machine into a web server by installing IIS and creating a
custom Endpoint.

The main tasks for this exercise are as follows:

1. Install the Web Server Role and ASP.NET Hosting Functionality


MCT USE ONLY. STUDENT USE PROHIBITED
3-12 Managing Infrastructure in Azure™

2. Publish the Web Application to the Local IIS Instance

3. Login to the Azure Preview Portal

4. Create a HTTP Port 80 Endpoint for the Virtual Machine

5. Connect to the Publically Hosted Web Application

 Task 1: Install the Web Server Role and ASP.NET Hosting Functionality
1. Open the Server Manager application.

2. Open the Add Roles and Features wizard.


3. Add the following Roles and Role Services:

o Roles

• Web Server (IIS)


o Role Services

• ASP.NET 4.5

4. Install the new Roles and Role Services immediately.


5. Close the Server Manager application.

 Task 2: Publish the Web Application to the Local IIS Instance


1. Switch to the Visual Studio application that is still running.

2. Publish the Contoso.Events.Web project using the following details:


o Profile name: localhost

o Server: localhost

o Site name: Default Web Site


o Destination URL: http://localhost/

3. Verify that the http://localhost/ web application works the same as it did in the previous exercise by
using the Internal IP Address for the SQL Server VM.

4. Close the Remote Desktop application.

 Task 3: Login to the Azure Preview Portal


5. Switch back to the Azure Preview Portal.

 Task 4: Create a HTTP Port 80 Endpoint for the Virtual Machine


1. View the list of Virtual Machine instances for your subscription

2. View the blade for your vm20532a[Your Name Here] Virtual Machine.
3. Add a new Endpoint to the VM with the following details:

o Endpoint: HTTP
o Protocol: TCP

o Public Port: 80

o Private Port: 80
o Floating IP: Disabled
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-13

Note: You can observe the Endpoints blade or the Notifications blade to determine when
your Endpoint creation task is complete.

 Task 5: Connect to the Publically Hosted Web Application


1. View the blade for your vm20532a[Your Name Here] Virtual Machine.

2. In Internet Explorer navigate to the Domain Name of your Virtual Machine instance.
3. Verify that the http://vm20532a[Your Name Here].cloudapp.net/ web application works the same
as it did in the previous exercise by using the Internal IP Address for the SQL Server VM.

4. Close the Internet Explorer application.

Results: After completing this exercise, you will have enabled IIS and the ASP.NET features on your
Windows Server 2012 R2 Virtual Machine and created a custom HTTP Endpoint for port 80 to view your
web server from any public browser.

Verify the correctness of the statement by placing a mark in the column to the right.

Statement Answer

You can use SQL Server Management Studio to connect to your SQL Server
VM with its current configuration from any machine?
MCT USE ONLY. STUDENT USE PROHIBITED
3-14 Managing Infrastructure in Azure™

Lesson 5
Using Remote Desktop Protocol (RDP) to Connect to a
Virtual Machine
In future labs, you will need to use Remote Desktop Protocol (RDP) to connect to your Development
Environment.

This lesson demonstrates how to use the RDP protocol to remotely connect to your Azure Virtual Machine
so that you can complete future labs in this course.

Lesson Objectives
After completing this lesson, you will be able to:

• Use an RDP file to connect to a Virtual Machine.


• Use the domain name and custom Remote Desktop endpoint to connect to a Virtual Machine.

Demonstration: Connecting to a Virtual Machine using an Existing


Endpoint
For this demo, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Log into the Azure Preview Portal (https://portal.azure.com).
2. View the blade for your Virtual Machine created in the previous lab.

o vm20532a[Your Name Here]

3. Record the Domain Name for your Virtual Machine

4. Record the Public Port value of the Remote Desktop standalone endpoint for your Virtual Machine.

5. Use the Remote Desktop Connection application to connect to your VM by manually entering the
address in this format:
o [Domain Name]:[Public Port]

6. Close the Remote Desktop Connection application.

7. Return to the Microsoft Azure tab in your Internet Explorer window.

8. Download the RDP file for your Virtual Machine and save the file in any directory.
9. Use File Explorer to Double-click the RDP file you have just downloaded.

10. Close the Remote Desktop Connection application.

11. Return to the Microsoft Azure tab in your Internet Explorer window.
12. Connect to your VM by using the Connect button in the Virtual Machine’s blade.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 3-15

Module Review and Takeaways


In this module, you observed how Virtual Machines can be connected to a Virtual Network and how the
networking options can be customized for each Virtual Machine. Options for scaling and configuration
management were also discussed for Virtual Machines in auto-scale and high availability scenarios.

Review Question(s)
Question: You are working with a small organization that does not have any on-site
hardware. However, they would like their software developers to be able to VPN to their
Azure Virtual Network when testing software features. Should you establish a point-to-site
or site-to-site network connection?
MCT USE ONLY. STUDENT USE PROHIBITED
3-16 Managing Infrastructure in Azure™
MCT USE ONLY. STUDENT USE PROHIBITED
4-1

Module 4
Web Infrastructure in the Azure™ Platform
Contents:
Module Overview 4-1

Lesson 1: Azure Web Sites 4-2

Lesson 2: Hosting Web Applications in Azure 4-4


Lesson 3: Configuring an Azure Web Site 4-6

Lesson 4: Publishing an Azure Web Site 4-8


Lesson 5: Monitoring an Azure Web Site 4-10
Lab Overview 4-12

Lab: Creating an ASP.NET Web Site Using Azure Web Sites 4-13

Module Review and Takeaways 4-17

Module Overview
This module provides an overview of the Azure Web Sites service offering. Lesson 1, “Azure Web Sites”,
describes the Web Sites service in Azure. Lesson 2, “Hosting Web Applications in Azure“, describes the
behavior and lifecycle of an Azure Web Site. Lesson 3, “Configuring an Azure Web Site”, discusses the
various configuration options available. Lesson 4, “Publishing an Azure Web Site”, goes into the publish
process. Lesson 5, “Monitoring an Azure Web Site”, lists the available options for metrics, monitoring and
diagnostics.

Objectives
After completing this module, you will be able to:

• Create an Azure Web Sites instance.


• Publish a simple ASP.NET web application to Azure Web Sites.

• Monitor an Azure Web Site.


MCT USE ONLY. STUDENT USE PROHIBITED
4-2 Web Infrastructure in the Azure™ Platform

Lesson 1
Azure Web Sites
In many scenarios, a quick and easy way to deploy web applications to the Cloud is preferred over
reengineering web applications as cloud projects. Azure Web Sites provides an offering that allows for
rapid iteration and creation of a web application.

This lesson describes the Azure Web Sites service offering.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Web Sites service

• List the different tiers for a Web Site.

What are Web Sites in Azure?

Pre-built Web Site Templates


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-3

Free, Shared and Standard Web Sites

Advantages of Web Sites

Demonstration: Create a Web Site using the Preview Portal


Demonstration Steps
1. Log into the Azure Preview Portal (https://portal.azure.com)

2. Create a new Website + SQL instance (resource group) using a unique name and these details:

o Resource Group: rg20532a


o Url: Pick a unique name for the website

o Database Name: rg20532adb

o Server Name: Pick a unique name for the logical server


o Server Admin Login: testuser

o Password: TestPa$$w0rd

3. View the Blade for the newly created Website.


4. Browse to the new Website.
MCT USE ONLY. STUDENT USE PROHIBITED
4-4 Web Infrastructure in the Azure™ Platform

Lesson 2
Hosting Web Applications in Azure
One of the advantages of deploying a web application in Azure Web Sites is the familiar hosting model.
Azure Web Sites make use of IIS and WebDeploy packages to host applications the same way as they are
hosted on premise.

This lesson will describe the lifecycle of Azure Web Sites instances and how they are hosted.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the relationship between IIS and Azure Web Sites.

• Describe the lifecycle of a Web Site service instance.

• Describe the differences between Standard tier Web Site instances and other tiers.

IIS and Azure Web Sites

Web Site Configuration


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-5

Web Hosting Plans


MCT USE ONLY. STUDENT USE PROHIBITED
4-6 Web Infrastructure in the Azure™ Platform

Lesson 3
Configuring an Azure Web Site
Azure Web Sites provide a lot of extra features that can be leveraged to expand your web application’s
capabilities. By using the management portal, different Web Site features can be enabled and custom
settings for the website can be modified without redeploying the web application.

This lesson lists the different configuration options available for an Azure Web Site.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Always On feature.

• Describe how to use a custom domain with a Web Site.

• Describe the Autoscale options for a Web Site.

Always On

Linked Resources
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-7

Domain Names

Multi-site Hosting in a Standard Web Site

Autoscaling a Web Site


MCT USE ONLY. STUDENT USE PROHIBITED
4-8 Web Infrastructure in the Azure™ Platform

Lesson 4
Publishing an Azure Web Site
After developing a web application, WebDeploy can be leveraged to publish that web application to
Azure. The Visual Studio publish wizard also allows for customization to be performed on the
configuration settings and connection strings immediately prior to the actual publish action.

This lesson describes the publish process available through the Visual Studio 2013 publish wizard.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe how to publish using the Publish Wizard in Visual Studio 2013.

• Describe how to transform configuration settings.

• Describe the difference between the standard Release and Debug builds.

Right-click Publish using WebDeploy

Web.config Transformations
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-9

Release vs. Debug Builds


MCT USE ONLY. STUDENT USE PROHIBITED
4-10 Web Infrastructure in the Azure™ Platform

Lesson 5
Monitoring an Azure Web Site
After deploying a web application to a cloud platform, tracing and metrics become more critical than
ever. Without the ability to remotely connect to a hosting virtual machine, logs become an important
part of the forensic analysis process when there are issues with a web application.

This lesson describes the different options available for monitoring an Azure Web Site.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the metrics available in the Management Portal.

• Describe the Remote Debugging feature in Visual Studio 2013.

• Discuss the storage options for diagnostics logs.

Web Site Metrics in the Management Portal

Remote Debugging
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-11

Diagnostics
MCT USE ONLY. STUDENT USE PROHIBITED
4-12 Web Infrastructure in the Azure™ Platform

Lesson 6
Lab Overview
Before working with the Contoso Events web applications, this lesson will introduce the application from a
high-level. You will see the Administration web application and the Public-facing Web front-end for the
Contoso Events web application.

Lesson Objectives
After completing this lesson, you will have an understanding of how the Contoso.Events web solution
works.

Demonstration: Contoso Events Walkthrough


Demonstration Steps
1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod04\Democode\Contoso.Events


2. Locate the Contoso.Events.Data.Generation project.

3. Debug the Contoso.Events.Data.Generation project to generate the SQL and Azure Storage Tables
data.
4. Close Microsoft Visual Studio 2013.

5. Re-launch Microsoft Visual Studio 2013 as an Administrator.

6. Open the Contoso.Events solution:

o File location: Allfiles (E):\Mod04\ Democode\Contoso.Events


7. Start the Contoso.Events solution.

8. Debug the solution with the following startup projects:


o Contoso.Events.Cloud: Start

o Contoso.Events.Management: Start without debugging

9. After the Contoso Events (Contoso.Events.Cloud) website is open, use IIS Express to open the
Contoso.Events.Administration website.
10. Select any Sales Conference event on the Contoso Events web site and register for that event using
the following details:

o Region: Western
o AnnualSales: 45000

o FirstName: Corrine
o LastName: Horn

11. Locate the same event in the Events List on the Contoso Events Administration web site.

12. Generate a sign-in sheet for the event.

Download the sign-in sheet after it has been generated.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-13

Lab: Creating an ASP.NET Web Site Using Azure Web Sites


Scenario
You have an events administration application that is used by a small set of users and does not have any
true scalability needs. You have chosen to deploy the application to Azure Web Sites.

In this lab, you will create an Azure Web Site, deploy your existing application and then configure the web
site after deployment.

Objectives
After you complete this lab, you will be able to:

• Create an Azure Web Site


• Create a linked resource for a Azure Web Site

• Publish an ASP.NET web application to a Azure Web Site


• Modify the configuration of the Azure Web Site in the Management Portal

Estimated Time: 60 minutes

For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

1. Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

2. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
3. In Remote Desktop Connection, provide the name of your virtual machine in the Computer dialog
box using this format: vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

4. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
5. If necessary, sign in using the following credentials:

o User name: testuser


o Password: TestPa$$w0rd

6. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create an Azure Web Site


Scenario
In this exercise you will:

• Create an Azure Web Site instance in the Management Portal.

• Browse to the url for the new Web Site.


The main tasks for this exercise are as follows:
MCT USE ONLY. STUDENT USE PROHIBITED
4-14 Web Infrastructure in the Azure™ Platform

1. Create a Web Site Instance Using the Management Portal

2. Browse to the Newly Created Web Site's Placeholder Page

 Task 1: Create a Web Site Instance Using the Management Portal


1. Log into the Azure Management Portal (https://manage.windowsazure.com).

2. Create a new Custom Web Site instance using a unique name and these details:

Note: Be sure to record your SQL admin username and password. It will be very difficult
and time consuming to recover this information if lost.

o Url: Pick a unique name for the website

o Database: “Free 20 MB SQL Database”

o Region: Select the region that is closest to your location

o DB Connection String Name: EventsContextConnectionString


o Database Name: EventsContextDB

o Database Server: New SQL database server

 Task 2: Browse to the Newly Created Web Site's Placeholder Page


1. View the Dashboard for your Web Site.
2. Browse to your new Web Site.

Results: After completing this exercise, you will be able to use the Management Portal to create Azure
Web Site instances and browse to the instance.

Exercise 2: Deploy an ASP.NET Web Application to an Azure Web Site


Scenario
In this exercise, you will:

• Download the publish profile for an existing Azure Web Site.

• Publish a web application using the Visual Studio 2013 Publish Wizard.
The main tasks for this exercise are as follows:

1. Open an Existing ASP.NET Web Application Project with Visual Studio 2013

2. Download the Publish Profile for the Azure Web Site


3. Publish the ASP.NET Web Application to the Azure Web Site

4. Verify the Web Application has been Successfully Published

 Task 1: Open an Existing ASP.NET Web Application Project with Visual Studio 2013
1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod04\Labfiles\Starter\Contoso.Events

2. Debug the web application to verify that it works.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-15

 Task 2: Download the Publish Profile for the Azure Web Site
1. Log into the Azure Management Portal (https://manage.windowsazure.com).
2. Browse to your previously created Web Site’s dashboard.

3. Download the publish profile for your Web Site


4. Save location: Allfiles (E):\Mod04\Labfiles

 Task 3: Publish the ASP.NET Web Application to the Azure Web Site
1. Publish the ASP.NET web application using the publish profile.

 Task 4: Verify the Web Application has been Successfully Published


1. Verify that the web site is working correctly in Azure.

Results: After completing this exercise, you will be able to use a publish profile to publish web
applications directly an Azure Web Site.

Exercise 3: Configure an Azure Web Site


Scenario
In this exercise, you will:
• Use the ConfigurationManager class to read custom appSettings from a web configuration file.

• Modify custom appSettings using the Management Portal.

The main tasks for this exercise are as follows:


1. Implement Logic to Read a Configuration Setting from App Settings

2. Publish Web Application to the Azure Web Site

3. Modify the App Settings in the Management Portal


4. Verify the App Settings have been Successfully Updated

 Task 1: Implement Logic to Read a Configuration Setting from App Settings


1. View the EventsListViewModel class in the Contoso.Events.ViewModels project.

2. Update the EventsListViewModel class to use an AppSetting to set the EventCount property in its
constructor:

o App Setting Key: EventsListViewModel.EventCount

3. Add an AppSetting to the root Web.config for Contoso.Events.Management


o App Setting Key: EventsListViewModel.EventCount

o App Setting Value: 5

4. Verify that the local web application is now using the AppSetting.

 Task 2: Publish Web Application to the Azure Web Site


1. Publish the ASP.NET web application using the most recent publish profile.
2. Verify that the cloud web application is now using the AppSetting.
MCT USE ONLY. STUDENT USE PROHIBITED
4-16 Web Infrastructure in the Azure™ Platform

 Task 3: Modify the App Settings in the Management Portal


1. Log into the Azure Management Portal (https://manage.windowsazure.com).
2. Browse to your previously created Web Site’s Configure tab.

3. Add an App Settings entry to the Web Site configuration to override the web.config AppSetting
o App Setting Key: EventsListViewModel.EventCount

o App Setting Value: 2

 Task 4: Verify the App Settings have been Successfully Updated


4. Verify that the cloud web application is now using the updated App Settings entry

Results: After completing this exercise, you will be able to leverage custom appSettings using a
web.config or the Azure Management Portal.

Lab Review
Verify the correctness of the statement by placing a mark in the column to the right.

Statement Answer

WebDeploy is the only mechanism for deploying web applications to Azure


Web Sites.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 4-17

Module Review and Takeaways


In this module, you were introduced to Azure Web Sites and learnt how easy it is to go from an ASP.NET
Web Application project to the cloud. You also became familiar with the unique configuration options
and features that make Web Sites a really powerful way of hosting cloud web applications. Finally, you
were introduced to monitoring tools that are available “out of the box” with Azure Web Sites that makes
debugging and tracing these sites as simple in production as it is on premise.

Best Practice: Even though we discussed WebDeploy publishing in Azure, the same
process can be followed for deploying applications on premise. WebDeploy can be used to
decouple developers from the release process and provide a single package that can be used by
an administrator to deploy the application in production.

Review Question(s)
Question: What are some of the business scenarios where it makes sense to Scale your
website on a schedule?
Question: Why would you want to store logs in a central location for multiple Web Site
instances?

Question: Why would you consider leaving log files on the file system for a Web Site
instance?
MCT USE ONLY. STUDENT USE PROHIBITED
4-18 Web Infrastructure in the Azure™ Platform
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

Lesson 2: Building High Performance Applications using ASP.NET 5-4


Lesson 3: Common Cloud Application Patterns 5-6

Lesson 4: Application Analytics 5-8


Lesson 5: Caching Application Data 5-10
Module Review and Takeaways 5-11

Module Overview
As a developer, some considerations must be taken when designing applications for the cloud. While
there are many platform improvements available in the ASP.NET ecosystem, scalability and reliability
metrics for cloud applications dictate that you rethink how you design your applications and the patterns
used. Lesson 1, “Application Design Practices for Highly Available Applications”, discusses some of the
considerations that need to be taken when designing applications that are hosted in the cloud so that
they have minimal downtime. Lesson 2, “Building High Performance Applications using ASP.NET”,
describes the changes to the ASP.NET stack in .NET 4.5 that improve the frameworks performance in web
applications. Lesson 3, “Common Cloud Application Patterns”, introduces a small set of example patterns
from the MSDN cloud patterns reference. Lesson 4, “Application Analytics”, demonstrates the Application
Insights service. Lesson 5, “Caching Application Data”, compares and contrasts the Azure and Redis Cache
services.
MCT USE ONLY. STUDENT USE PROHIBITED
5-2 Designing Cloud Applications for Resiliency

Lesson 1
Application Design Practices for Highly Available
Applications
This lesson describes some of the common considerations for designing highly available applications.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe how you can split your application into units of work.
• Describe queue and load balancing strategies for applications.

• Describe the Transient Fault Handling pattern.

Modular Units of Work

Load Balancing
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 5-3

Transient Fault Handling

Queues
MCT USE ONLY. STUDENT USE PROHIBITED
5-4 Designing Cloud Applications for Resiliency

Lesson 2
Building High Performance Applications 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:

• Describe the Asynchronous HTTP Modules and Handlers.


• Use the async/await keywords in an ASP.NET application.

• Compare the options for state management in ASP.NET.

Web Hosting Performance Improvements

Asynchronous HTTP Modules and Handlers


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 5-5

Async Keyword

State Management
MCT USE ONLY. STUDENT USE PROHIBITED
5-6 Designing Cloud Applications for Resiliency

Lesson 3
Common Cloud Application Patterns
While 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 will describe in detail three examples of the curated cloud application patterns.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Retry pattern

• Use the Valet-Key pattern to access resources

• Use the Sharding pattern to scale a constrained data storage mechanism

Cloud Application Patterns

Retry Pattern
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 5-7

Valet-Key Pattern

Sharding Pattern
MCT USE ONLY. STUDENT USE PROHIBITED
5-8 Designing Cloud Applications for Resiliency

Lesson 4
Application Analytics
Analytic software allows developers and operations the ability to explore both the usage and behavior of
their web application. With cloud application, using analytics becomes more important since you have to
make scaling and design decisions per iteration.

This lesson will describe the Azure Application Analytics service.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Application Analytics service

• Integrate the Application Analytics scripts and assemblies with an ASP.NET project

Application Insights

Demonstration: Monitoring Web Application Requests using Application


Insights
Demonstration Steps
1. Open the Visual Studio 2013 application.

2. Create a new ASP.NET Web Application project with the following details:
o Name: Contoso.Help

o Location: Allfiles (E):\Mod05\Democode

o Add Application Insights to Project: Yes


o Send telemetry to: New Application Insights resource

o Template: MVC

o Authentication: No Authentication
o (Azure) Host in the cloud: Website
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 5-9

3. Open the HomeController.cs file in the Contoso.Help project.

4. Update the About action to return a HTTP Status code of 500.

5. Update the Contact action to use Thread.Sleep for a duration of 5 seconds.

6. Publish the ASP.NET Web application.


7. View the published web application in Internet Explorer.

8. Log into the Azure Preview Portal (https://portal.azure.com).


9. View the Application Insights dashboard for the Azure Web Site instance.

10. Create a web test verifying that the home page is available in another country.
MCT USE ONLY. STUDENT USE PROHIBITED
5-10 Designing Cloud Applications for Resiliency

Lesson 5
Caching Application Data
Azure provides two primary Cache mechanisms that can be used to 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 as it pertains to existing cloud applications.

This lesson will describe the two cache offerings in Azure, Azure Cache and Redis Cache.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Cache

• Describe the Redis Cache

Azure Cache

Redis Cache
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 5-11

Module Review and Takeaways


In this module, some of the patterns and guidance for creating cloud applications were reviewed. Likely,
this may not be the first time you have seen these patterns or practices. When developing disconnected
modular web applications running on external hardware (i.e. Azure), the effort to gain ratio of many
patterns change significantly. Many patterns and tools that may be “overkill” on premise are now critical
with distributed cloud applications.

Review Question(s)
Question: Why would you want a periodic check (heartbeat) of your Azure Web Site’s
availability across geographic regions?

Question: How could you implement the Valet-Key Pattern using Azure Storage services?
MCT USE ONLY. STUDENT USE PROHIBITED
5-12 Designing Cloud Applications for Resiliency
MCT USE ONLY. STUDENT USE PROHIBITED
6-1

Module 6
Processing Background Logic using Azure
Contents:
Module Overview 6-1

Lesson 1: Overview of Cloud Services 6-3

Lesson 2: Cloud Service Web Roles 6-5


Lesson 3: Customizing Cloud Service Configurations 6-7

Lesson 4: Updating and Managing Cloud Service Deployments 6-9


Lesson 5: Cloud Service Worker Roles 6-11
Lesson 6: Cloud Service Worker Role Processing 6-13

Lesson 7: Caching Data using Roles 6-15

Lesson 8: Analyzing Applications in Cloud Service Role Instances 6-17


Lab: Creating a Background Process Using Azure Worker Roles 6-19

Module Review and Takeaways 6-23

Module Overview
As your application scales out, you will find that some of your business logic will become a bottleneck. IO
intensive operations may start using a third-party service which can take a variable amount of time.
Third-party APIs can have long running logic. In order to facilitate this Cloud Services can container
Worker roles who can execute long-running background logic asynchronously from your web front-end
roles. Lesson 1, “Cloud Service Worker Roles”, introduces Worker Roles and describes the small
differences between them and Web Roles. Lesson 2, “Creating a Worker Role”, shows how you can create
a Worker Role from a C# Library project. Lesson 3, “Configuring a Worker Role”, describes the small
differences when configuring a Worker Role. Lesson 4, “Caching Data using Roles”, details the cache
capability available for roles in a Cloud Service.

Objectives
After completing this module, you will be able to:
• Describe the Azure Cloud Service offering.

• Explain the complexity of Cloud Service deployments as compared to Virtual Machines and Web Sites.

• Describe the differences between Web Roles and Worker Roles.


• Describe Cloud Service In-Role Caching.

• Leverage the Azure Compute Emulator.


• Create a Cloud Service Worker Role.

• Implement the methods for the RoleEntryPoint base class.


MCT USE ONLY. STUDENT USE PROHIBITED
6-2 Processing Background Logic using Azure

• Configure a Worker Role.

• Co-locate cache with a Cloud Service role.

• Convert a Worker Role to a dedicated cache role.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-3

Lesson 1
Overview of Cloud Services
When developing web applications and coming up with a production environment, sometimes our
worries go well beyond the actual logic of the application.

With hardware failures, updates, patches, networking and backup concerns, developing a web application
becomes an exercise in Infrastructure management.
This lesson describes the Cloud Services available in Azure and how they can be used for your applications
without you having to worry about infrastructure.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Cloud Service offering.


• Understand the architecture of a Cloud Service.

Architecture of a Cloud Service

Cloud Service Features


MCT USE ONLY. STUDENT USE PROHIBITED
6-4 Processing Background Logic using Azure

Cloud Service Roles


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-5

Lesson 2
Cloud Service Web Roles
Web Roles provide a pre-built web server that can be used to host front-end web applications.

This lesson introduces Web Roles and their relationship with Cloud Services.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the features available in a Web Role.


• Explain the behavior of Web Roles.

• Decide which endpoints to create for a new Web Role.

Hosting a Web Application

Web Endpoints
MCT USE ONLY. STUDENT USE PROHIBITED
6-6 Processing Background Logic using Azure

Behavior of a Cloud Service Role

Role Recycling
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-7

Lesson 3
Customizing Cloud Service Configurations
Cloud Service Roles provide a much deeper level of customization than Web Sites. Roles can co-locate
cache, have custom endpoints or even cloud-managed settings.

This lesson describes the customization options available for Web and Worker Roles.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the various VM sizes.


• Explain how to modify the configuration settings for a Web Role.

• Understand how to access local storage and its potential drawbacks.

Scalability and Virtual Machine Size

Configuration Settings in Visual Studio


MCT USE ONLY. STUDENT USE PROHIBITED
6-8 Processing Background Logic using Azure

Local Storage
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-9

Lesson 4
Updating and Managing Cloud Service Deployments
Cloud Services have a unique deployment process. Understanding the relationship between a Cloud
Service package and its configuration files, you can customize what you want to deploy and the affect it
has on a running Cloud Service (i.e. in-place update).

This lesson reviews the considerations and processes for deploying a Cloud Service package or
configuration changes to either a new service instance or a running instance.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the contents of a Cloud Service package


• Update in-place a running Cloud Service

• Modify configuration settings for a Cloud Service at runtime

Cloud Service Packages

In-Place Updating
MCT USE ONLY. STUDENT USE PROHIBITED
6-10 Processing Background Logic using Azure

Runtime Configuration
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-11

Lesson 5
Cloud Service Worker Roles
Worker Roles provide a scalable set of worker processes that can consume messages from a storage mechanism
and process them separately from your client and web front-end projects. This provides you with the flexibility to
scale either your background workers or your front-end projects based on your actual usage.

This lesson introduces Worker Roles and the unique capabilities they provide.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the difference between a Web and Worker Role.


• Explain options for communicating with a Worker Role.

• Describe the typical Worker Role algorithm.

Why Cloud Service Worker Roles?

Differences between Web and


Worker Roles
MCT USE ONLY. STUDENT USE PROHIBITED
6-12 Processing Background Logic using Azure

Communicating with a Worker Role

Processing Data in a Worker Role


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-13

Lesson 6
Cloud Service Worker Role Processing
The Microsoft.WindowsAzure.ServiceRuntime namespace contains a RoleEntryPoint class that is used
as the base class for both Web and Worker Roles. By overriding the OnStart and Run methods, you can
provide a loop for the background worker to execute.

This lesson describes the RoleEntryPoint base class and the methods that need to be overridden to
implement a Worker Role.

Lesson Objectives
After completing this lesson, you will be able to:

• Inherit from the RoleEntryPoint class.


• Override the OnStart and Run methods.

• Create an infinite loop for your worker role to use when checking for new messages.

Using the ServiceRuntime

Inheriting from the RoleEntryPoint Class


MCT USE ONLY. STUDENT USE PROHIBITED
6-14 Processing Background Logic using Azure

Implementing the OnStart Method

Implementing the Run Method

Handling Messages
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-15

Lesson 7
Caching Data using Roles
When scaling a cloud application out to many instances, it becomes very important to move any stateful
resources (SessionState, Cache, etc.) to a shared resource. Azure provides a cache service that can be used
in conjunction with Cloud Service roles.

This lesson will introduce the Azure Cache service and describe how you can use it with Cloud Service
roles.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Cache service.


• Explain the difference between a dedicated and co-located cache role.

• Describe the Named Caches feature.

Azure Cache

Dedicated Cache Worker Roles


MCT USE ONLY. STUDENT USE PROHIBITED
6-16 Processing Background Logic using Azure

Co-locating Cache in a Web or Worker Role

Named Caches
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-17

Lesson 8
Analyzing Applications in Cloud Service Role Instances
The Azure Compute Emulator provides an environment where you can test both your web front-end
application and its diagnostic processes. The emulator allows you to see how a very close approximation
of your application will behave after the Cloud Service is deployed.

This lesson will describe the monitoring options available for Cloud Services and will introduce the Azure
Compute Emulator.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Compute Emulator


• Debug a running Cloud Service

Diagnostics

Azure Compute Emulator


MCT USE ONLY. STUDENT USE PROHIBITED
6-18 Processing Background Logic using Azure

Compute Emulator Compatibility with Azure

Debugging Live Cloud Services Remotely using Visual Studio 2013


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-19

Lab: Creating a Background Process Using Azure Worker


Roles
Scenario
The Contoso Events application currently allows an administrator to generate a sign-in sheet Word
document. Unfortunately when scaling the application, this becomes a bottleneck. You have decided to
redesign your solution so that the web front-end application will send a request to generate a sign-in
sheet. You will also create a Worker Role that will check these requests and generate the sign-in sheets.

In this lab, you will create a C# Class Library project, add the appropriate references and add the project
as a Worker Role to your Cloud Service. Then you will use the Azure Compute Emulator to test the Web
and Worker Roles.

Objectives
After you complete this lab, you will be able to:

• Create a Worker Role from a C# Class Library project.


• Implement the RoleEntryPoint class methods.

• Debug a Worker Role using the Azure Compute Emulator.

Estimated Time: 60 minutes


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

1. Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

2. On the host computer, click Start, type Remote, and then click Remote Desktop Connection.
3. In Remote Desktop Connection, provide the name of your virtual machine in the Computer dialog
box using this format:

o vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

4. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

5. If necessary, sign in using the following credentials:

o User name: testuser

o Password: TestPa$$w0rd

6. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create a C# Class Library


Scenario
In this exercise you will:
MCT USE ONLY. STUDENT USE PROHIBITED
6-20 Processing Background Logic using Azure

• Create a C# Class Library project.

• Add references to the ServiceRuntime DLLs.

• Create a class inheriting from the RoleEntryPoint base class.

• Implement the OnStart and Run methods.


The main tasks for this exercise are as follows:

1. Create a C# Class Library project


2. Add a Reference to the Azure SDK Libraries and Solution Projects

3. Create a Class Inheriting from RoleEntryPoint

4. Implement the Run Logic to Get Requests from the SQL Database

 Task 1: Create a C# Class Library project


1. Open Visual Studio 2013 as an Administrator.
2. Open the Contoso.Events starter solution for Module 6:

o File location: Allfiles (E):\Mod06\Labfiles\Starter\Contoso.Events

3. Create a new Visual C# Class Library project in the Contoso.Events solution with the following
name:

o Contoso.Events.Worker

 Task 2: Add a Reference to the Azure SDK Libraries and Solution Projects
1. Add a reference to the Microsoft.WindowsAzure.ServiceRuntime library in the
Contoso.Events.Worker project.

2. Add a reference to the following projects in the Contoso.Events solution:

o Contoso.Events.Models
o Contoso.Events.Data

o Contoso.Events.Documents

3. Using the Package Manager Console, execute the following command targeting the
Contoso.Events.Worker project:

o Install-Package EntityFramework -Version 6.0.2

4. Build the Contoso.Events.Worker project.

 Task 3: Create a Class Inheriting from RoleEntryPoint


1. Add a new class to the project with the name WorkerRole.

2. Open the WorkerRole class.

3. Change the accessor of the WorkerRole class to public.


4. Redefine the class to inherit from the RoleEntryPoint base class in the
Microsoft.WindowsAzure.ServiceRuntime namespace.

5. Implement the OnStart method with a call to the RoleEntryPoint base OnStart() method. The
OnStart method should also set the ServicePointManager.DefaultConnectionLimit value to 12
before calling the base OnStart() method.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-21

6. Implement the Run method with a simple infinite while loop. The method should write to Trace
using the Trace.WriteLine method when first ran. Within the method’s while loop, a call to
Thread.Sleep should be made for a duration of 10,000 milliseconds and then a call to
Trace.WriteLine should be made to indicate an iteration of the queue.

public override void Run()


{
Trace.WriteLine("Queue Run Start");
while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Queue Run Iteration");
}
}

 Task 4: Implement the Run Logic to Get Requests from the SQL Database
1. Add the WorkerRole.cs file to the Contoso.Events.Worker project:
o File location: Allfiles (E):\Mod06\Labfiles\Starter\WorkerRole.cs

2. Open the App.config configuration file.

3. Replace the entire contents of the App.config configuration file with the below xml:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="EventsContextConnectionString" connectionString="Data
Source=(localdb)\v11.0;Initial Catalog=EventsContextDB;Integrated Security=True
providerName="System.Data.SqlClient" />
</connectionStrings>

</configuration>

Results: After completing this exercise, you will be able to create a Worker Role class library and
implement the appropriate pattern for a background worker.

Exercise 2: Add the Class Library to a Cloud Service Project


Scenario
In this exercise you will:

• Add a Class Library project as a Worker Role in a Cloud Service project.


The main tasks for this exercise are as follows:

1. Add Class Library as a Worker Role to the Cloud Service project

 Task 1: Add Class Library as a Worker Role to the Cloud Service project
1. Unload the Contoso.Events.Worker project from the Contoso.Events solution.
2. Edit the Contoso.Events.Worker.csproj file to have the following element as a child of the
PropertyGroup XML element:

o <RoleType>Worker</RoleType>
3. Reload the Contoso.Events.Worker project.
MCT USE ONLY. STUDENT USE PROHIBITED
6-22 Processing Background Logic using Azure

4. Associate the Contoso.Events.Worker Class Library project with the Contoso.Events.Cloud Cloud
Service project as a Worker Role.

Results: After completing this exercise, you will be able to take an existing Class Library project and turn it
into a Worker Role in an existing Cloud Service project.

Exercise 3: Debug Worker Roles in a Cloud Service Project


Scenario
In this exercise you will:

• Add a breakpoint to a Worker Role.


• Debug the Worker Role and a Web Role using the Azure Compute Emulator.

The main tasks for this exercise are as follows:

1. Debug the Worker Role

 Task 1: Debug the Worker Role


1. DEBUG the Contoso.Events.Cloud project.
2. Generate a sign-in sheet by clicking the Generate Sign-In Sheet button on an event page.

3. Wait for the sign-in sheet to be generated then download the sign-in sheet.
4. View the sign-in sheet (.docx file) in WordPad.

Results: After completing this exercise, you will be able to debug a Worker Role.

Lab Review
Instance count when debugging Web Roles
When debugging a Cloud Service, make sure to minimize the amount of instances for your Web and
Worker Roles. The instance count can always be increased prior to publishing the Cloud Service. You can
of course test scalability by slowly increasing instance count but remember that the Azure Compute
Emulator has a maximum role instance count of 50.
Question: What types of C# Class Library projects would be easiest to migrate into Worker
Roles?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 6-23

Module Review and Takeaways


In this module, you were introduced to an alternative method for hosting web front-end applications in
Azure. With Cloud Services, your web application can focus on its code and let the Azure hypervisor and
fabric controller handle infrastructure and scalability. With the Azure Compute Emulator, you were
introduced to a new tool that allows you to test Cloud Services locally to ensure that your roles work as
intended.

Worker Roles afford you another level of flexibility when designing and building your cloud applications.
By migrating long-running or IO bound logic to Worker Roles, you can scale the Web front-end of your
application and background workers in isolation and to more closely meet the real usage needs of your
application.

Review Question(s)
Question: What are some examples of data that needs to be cached but could logically be
stored in different named caches?

Question: What are some reasons that you may have the RoleEntryPoint.Run method’s
implementation end the current “infinite” loop and recycle the role?

Question: What are some of the things that you may have to consider changing about your
existing web applications before migrating them to a Web Role?

Verify the correctness of the statement by placing a mark in the column to the right.

Statement Answer

Web.config settings for Web Roles cannot be changed once you publish the
Cloud Service to Azure.

Question: What is an example of a web role that exposes an internal endpoint?


MCT USE ONLY. STUDENT USE PROHIBITED
6-24 Processing Background Logic using Azure
MCT USE ONLY. STUDENT USE PROHIBITED
7-1

Module 7
Storing Tabular Data in Azure
Contents:
Module Overview 7-1

Lesson 1: Azure SQL Databases Overview 7-3

Lesson 2: Managing SQL Databases in Azure 7-5


Lesson 3: Using Azure SQL Databases with SQL Server Data Tools 7-7

Lesson 4: Migrating Data to Azure SQL Databases 7-9


Lesson 5: Replication and Recovery of Azure SQL Database Instances 7-11
Lab A: Storing Event Data in Azure SQL Databases 7-13

Lesson 6: Azure Storage Overview 7-17

Lesson 7: Azure Storage Tables Overview 7-19


Lesson 8: Table Entity Transactions 7-21

Lab B: Storing Event Registration Data in Azure Storage Tables 7-25

Module Review and Takeaways 7-30

Module Overview
Dynamic web applications have always had a need to store the data that is being managed and
manipulated by end users. For as long as ASP.NET has been around, technologies like ADO.NET and
Entity Framework have provided a way for accessing data in SQL Server. In the cloud, the Azure platform
provides a SQL as a Service offering that allows developers to use SQL in much the same manner as they
would on premise. Lesson 1, “What is Azure SQL Databases”, defines the Azure SQL Databases service and
reasons you would consider using it. Lesson 2, “Managing SQL Databases in Azure”, describes the familiar
and new management tools available for use with a SQL database hosted in Azure. Lesson 3, “Using
Azure SQL Databases with SQL Server Data Tools”, deeply describes the SSDT templates, panes and
projects available in Visual Studio 2013. Lesson 4, “Migrating Data to Azure SQL Databases”, describes a
couple of simple methods for migrating an existing schema and data from on premise to the cloud.
Lesson 5, “Using Azure SQL Databases with Entity Framework”, details some of the ways you can leverage
Entity Framework Code First to your advantage when working with a database hosted in the cloud.

Objectives
After completing this module, you will be able to:

• Describe the difference between Azure SQL Database Editions

• Explain some of the advantages and disadvantages of hosting databases in Azure SQL Databases.
• Explain some of the advantages and disadvantages of hosting databases in a SQL Server installation
on an Azure Virtual Machine.
MCT USE ONLY. STUDENT USE PROHIBITED
7-2 Storing Tabular Data in Azure

• Describe the tools that can be used to manage Azure SQL Databases.

• Describe the Visual Studio 2013 features that can be used to manage Azure SQL Databases.

• Describe the options for migrating data from on premise to the cloud.

• Describe strategies for using Entity Framework with Azure SQL Databases.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-3

Lesson 1
Azure SQL Databases Overview
Azure SQL Databases provides a database-as-a-service offering that allows you to take advantage of
many of the constructs that are already familiar to developers and administrators who have worked with
SQL Server in the past.

This lesson will describe the Azure SQL Databases service, some of the advantages of using this service
and some of the considerations for selecting between the Azure SQL Database service and SQL Server on
an Azure VM.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure SQL Databases service.


• Explain the advantages of using Azure SQL Databases.

• Explain the advantages of using SQL Server in an Azure Virtual Machine.


• Describe the Azure SQL Databases editions.

Azure SQL Databases

Azure SQL Databases Editions


MCT USE ONLY. STUDENT USE PROHIBITED
7-4 Storing Tabular Data in Azure

Advantages of Hosting SQL Databases in the Cloud

Sharding

Databases as a Service vs. SQL Server in a Virtual Machine


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-5

Lesson 2
Managing SQL Databases in Azure
The Azure Management Portal provides convenient ways to create and manage databases. There is also a
unique portal that allows you to manage the various tables, views and other objects for your SQL
database.

This lesson lists the various online management tools available for interacting with Azure SQL Databases.

Lesson Objectives
After completing this lesson, you will be able to:

• Use the Management Portal to create a server and database.

• Use the Azure SQL Databases Management Portal to manage the tables and views.

Creating a Server using the Management Portal

Creating a Database using the Management Portal


MCT USE ONLY. STUDENT USE PROHIBITED
7-6 Storing Tabular Data in Azure

Managing the Database using the Azure SQL Databases Management


Portal
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-7

Lesson 3
Using Azure SQL Databases with SQL Server Data Tools
One of the advantages of Azure SQL Databases is the ability to use many of the same monitoring tools
that you use for on premise databases.

This lesson describes the existing management tools and how they can be used to manage Azure SQL
Databases.

Lesson Objectives
After completing this lesson, you will be able to:

• Use SQL Server Management Studio to manage your Azure SQL Databases instances.

• Use Visual Studio’s tools to manage your Azure SQL Databases instances.

SQL Server Management Studio

Visual Studio Server Explorer


MCT USE ONLY. STUDENT USE PROHIBITED
7-8 Storing Tabular Data in Azure

Visual Studio SQL Server Object Explorer

Visual Studio Database Projects


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-9

Lesson 4
Migrating Data to Azure SQL Databases
You may choose to migrate your existing database objects from an on premise database to Azure SQL
Databases. There are many options available for migrating data that align directly with the options
considered for migrating data on premise.

This lesson will describe the various options for migrating data from on premise to the cloud.

Lesson Objectives
After completing this lesson, you will be able to:

• Generate a migration script in SQL Server Management Studio.

• Export and Import a data-tier application.

• Explain how to use SQL Server Integration Services for migration.

Generating a Migration Script

Data-tier Application Export and Import


MCT USE ONLY. STUDENT USE PROHIBITED
7-10 Storing Tabular Data in Azure

SQL Server Integration Services


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-11

Lesson 5
Replication and Recovery of Azure SQL Database Instances
Both SQL Server standalone and Azure SQL Databases offers a comprehensive set of replication and
disaster recovery (DR) options.

This lesson will describe the High Availability related features for both SQL standalone and SQL as a
Service in Azure.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Geo-replication options for Azure SQL Databases

• Describe the High Availability functionality for SQL Server

High Availability for SQL Server Standalone

High Availability for Azure SQL Databases


MCT USE ONLY. STUDENT USE PROHIBITED
7-12 Storing Tabular Data in Azure

Azure SQL Databases Geo-Replication


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-13

Lab A: Storing Event Data in Azure SQL Databases


Scenario
Now that the web application is ready for publishing, you can begin migrating the web application to
Azure by first creating a database in Azure. You have decided to use a database initializer and Entity
Framework Code First to automate the creation of your database in SQL Azure Databases.

Objectives
After you complete this lab, you will be able to:

• Create an Azure SQL Databases server and database instance using the Management Portal.
• Use Entity Framework Code First to initialize and seed a database in the cloud.

• Use the SQL Azure Databases Management Portal to view live data in the cloud.

Estimated Time: 45 minutes


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:


o User name: testuser

o Password: TestPa$$w0rd

5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Creating an Azure SQL Databases Instance


Scenario
In this exercise you will:

• Create a SQL Server instance in Azure.

• Create a database in Azure.

The main tasks for this exercise are as follows:

1. Login to the Azure Preview Portal


MCT USE ONLY. STUDENT USE PROHIBITED
7-14 Storing Tabular Data in Azure

2. Create an Azure SQL Database using the Preview Portal

 Task 1: Login to the Azure Preview Portal


1. Log into the Azure Preview Portal (https://portal.azure.com).

 Task 2: Create an Azure SQL Database using the Preview Portal


1. View the list of SQL Databases for your subscription.

2. Create a SQL Database with the following details:


o Name: db20532a[Your Name Here]

o Edition: Web

o Server Name: sv20532a[Your Name Here]


o Server Admin Login: testuser

o Server Admin Password: TestPa$$w0rd


o Location: Select the region that is closest to your location
3. Record the name of the newly created SQL Database instance.

Results: After completing this exercise, you will be able to create both servers and databases in the Azure
SQL Databases service.

Exercise 2: Using Entity Framework with Azure SQL Databases


Scenario
In this exercise you will:

• Configure an Entity Framework Code First DatabaseInitializer.


• Implement a Seed method for the initializer.

• Publish a Cloud Services application.

• View tables and data using the Azure SQL Databases Management Portal.
The main tasks for this exercise are as follows:

1. Run the ASP.NET Web Application to View Events from LocalDb

2. Configure the DbContext with a New DatabaseInitializer


3. Implement Seed Data with the DbContext

4. Publish the Cloud Application with the Updated DbContext to Azure

5. Verify that the Azure Cloud Service Website is using the New Data
6. Login to the Azure Management Portal

7. View the Migrated Data in the Azure SQL Management Portal

 Task 1: Run the ASP.NET Web Application to View Events from LocalDb
1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod07\Labfiles\Starter\SQL\Contoso.Events


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-15

2. Debug the Contoso.Events.DataGeneration console project.

Note: This Data Generation console application simply creates some sample data in your
local SQL database (LocalDb) so that you can test the site.

3. Debug the Contoso.Events.Cloud cloud project.

 Task 2: Configure the DbContext with a New DatabaseInitializer


1. Create a new EventsContextInitializer class in the Contoso.Events.Data project.

2. Update the EventsContextInitializer class with the public accessor.


3. Update the EventsContextInitializer class to inherit from the
DropCreateDatabaseAlways<EventsContext> class.

4. Add a using statement for the Contoso.Events.Models namespace.


5. Update the EventsContext static constructor with the following lines of code:

Database.SetInitializer<EventsContext>(
new EventsContextInitializer()
);

 Task 3: Implement Seed Data with the DbContext


1. Override the Seed method of the DropCreateDatabaseAlways<> class.
2. Add a using statement for the Contoso.Events.Models namespace.

3. At the end of the Seed method, create an instance of the EventItem class with the following values:
o EventKey: "FY17SepGeneralConference"
o StartTime: DateTime.Today

o EndTime: DateTime.Today.AddDays(3d)
o Title: "FY17 September Technical Conference"
o Description: "Sed in euismod mi."

o RegistrationCount: 1
4. At the end of the Seed method, add the newly created EventItem to the context.Events collection.

5. At the end of the Seed method, create an instanced of the Registration class with the following
values:

o EventKey: "FY17SepGeneralConference"

o FirstName: "Aisha"

o LastName: "Witt"

6. At the end of the Seed method, add the newly created Registration to the context.Registrations
collection.

7. At the end of the Seed method, invoke the context.SaveChanges() method.

8. Build the Contoso.Events.Data project.


MCT USE ONLY. STUDENT USE PROHIBITED
7-16 Storing Tabular Data in Azure

 Task 4: Publish the Cloud Application with the Updated DbContext to Azure
1. Update the Web.Release.config file in the Contoso.Events.Web project to use a connection string
to your Azure SQL Database.

2. Publish the Contoso.Events.Cloud project to a new Cloud Service project with the following details:
o Name: cs20532a[Your Name Here]

o Region: Select the region that is closest to your location

o Environment: Production
o Build configuration: Release

3. Service configuration: Cloud

 Task 5: Verify that the Azure Cloud Service Website is using the New Data
1. View the website for your published Cloud Service.

 Task 6: Login to the Azure Management Portal


1. Log into the Azure Management Portal (https://manage.windowsazure.com).

 Task 7: View the Migrated Data in the Azure SQL Management Portal
1. View the list of SQL Databases for your subscription.

2. View the dashboard for your previously created SQL Database:


o Name: db20532a[Your Name]

3. Log in to the Management Portal for your SQL Database with these values:

o Username: testuser
o Password: TestPa$$w0rd

4. View the data in the dbo.Events table.

Results: After completing this exercise, you will be able to configure Entity Framework to initialize a new
database with seed data.

Question: What are some scenarios where it is appropriate to use Seed data from a ORM
framework in your Azure SQL Database?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-17

Lesson 6
Azure Storage Overview
Azure Storage allows you to store unstructured data, files and messages. Azure Storage can be used as a
shared resource to your cloud applications and the various instances of each service.

This lesson will provide a brief overview of Azure Storage.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Storage service.


• Detail the types of Storage available.

• Describe geo-replication of Azure Storage data.

Azure Storage

Types of Storage
MCT USE ONLY. STUDENT USE PROHIBITED
7-18 Storing Tabular Data in Azure

Azure Storage vs. Azure SQL Databases

Geo-Replication in Azure Storage

Accessing Storage Data


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-19

Lesson 7
Azure Storage Tables Overview
Table Storage provides a non-relational database option for storage in Azure. It has been tuned to scale
to very large quantities of entities and even operations per second. Simply, Table Storage was built with
scalability in mind.

This lesson will introduce the Table Storage service and describe why it is unique.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Storage Tables service.

• Explain the structure of data and partitions in Table Storage.

• Describe the relationship between OData and Table Storage.

Storage Tables

NoSQL Data in Storage Tables


MCT USE ONLY. STUDENT USE PROHIBITED
7-20 Storing Tabular Data in Azure

Web Endpoints for Storage Tables


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-21

Lesson 8
Table Entity Transactions
Storage Tables offers a set of transactional functionality that mirrors the traditional
Create/Read/Update/Delete (CRUD) methods. Storage Tables also leverages the OData protocol for
queries.

This lesson will describe both common transactions and entity ingress considerations for Storage Tables
and their entities.

Lesson Objectives
After completing this lesson, you will be able to:

• Use OData to query a Storage Table


• Use the common CRUD transactions with a Storage Table’s entity

Common Transactions

OData Queries
MCT USE ONLY. STUDENT USE PROHIBITED
7-22 Storing Tabular Data in Azure

Prepend/Append Problem

Demonstration: Implementing Azure Storage Tables


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:

o User name: testuser

o Password: TestPa$$w0rd

5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Create a new Console Application project in Visual Studio 2013:
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-23

o Name: Contoso.Storage.Table

o Location: AllFiles (E) E:\Mod07\Labfiles\Starter

2. Add the WCF Data Services Client for OData v1-3 NuGet package using the Package Manager
Console:

o Package Name: Microsoft.Data.Services.Client

o Version: 5.6.0

3. Add the Windows Azure Storage NuGet package using the Package Manager Console:

o Package Name: WindowsAzure.Storage

o Version: 3.1.0.1

4. Open the Program.cs file.


5. Add using statements for the Microsoft.WindowsAzure.Storage &
Microsoft.WindowsAzure.Storage.Table namespaces.
6. In the Main method, create a CloudTableClient instance using the following code:

CloudTableClient tableClient =
CloudStorageAccount.DevelopmentStorageAccount.CreateCloudTableClient();

7. Create a CloudTable instance using the following code:

CloudTable table = tableClient.GetTableReference("roster");

8. Ensure that the table is created using the following code:

table.CreateIfNotExists();

9. Create a new class in the Contoso.Storage.Table project:

o File Name: Employee.cs


10. Update the Employee class with the public accessor.

11. Add a using statement for the Microsoft.WindowsAzure.Storage.Table namespace.

12. Update the Employee class to inherit from the TableEntity class.
13. Add a YearsAtCompany public property of type int with both get and set accessors;

14. Override the ToString method of the Object base class and add this code:

return RowKey + "\t\t[" + YearsAtCompany + "]";

15. In the Program class at the end of the Main method, create three employees using the following
code:

Employee first = new Employee { PartitionKey = "IT", RowKey = "ibahena",


YearsAtCompany = 7 };
Employee second = new Employee { PartitionKey = "HR", RowKey = "rreeves",
YearsAtCompany = 12 };
Employee third = new Employee { PartitionKey = "HR", RowKey = "rromani",
YearsAtCompany = 3 };

16. Insert the employee with the IT partition key to the Table using the following code:

TableOperation insertOperation = TableOperation.InsertOrReplace(first);


MCT USE ONLY. STUDENT USE PROHIBITED
7-24 Storing Tabular Data in Azure

table.Execute(insertOperation);

17. Batch insert the employees with the HR partition key to the Table using the following code:

TableBatchOperation batchOperation = new TableBatchOperation();


batchOperation.InsertOrReplace(second);
batchOperation.InsertOrReplace(third);
table.ExecuteBatch(batchOperation);

Note: Batch operations can be used to insert multiple entities into an Azure Storage
table. The entities must all have the same PartitionKey in order to be inserted as a single batch.

18. Query the table for employees with a partition key equal to HR and print them to the console using
the following code:

TableQuery<Employee> query = new TableQuery<Employee>().Where(


TableQuery.GenerateFilterCondition("PartitionKey",
QueryComparisons.Equal, "HR")
);
Console.WriteLine("HR Employees\n");
foreach(Employee hrEmployee in table.ExecuteQuery<Employee>(query))
{
Console.WriteLine(hrEmployee);
}

19. Retrieve the single employee with a partition key of IT and a row key of ibahena and print the
employee to the console using the following code:

Console.WriteLine("\n\n\n\nIT Employee\n");
TableOperation retrieveOperation = TableOperation.Retrieve<Employee>("IT",
"ibahena");
TableResult result = table.Execute(retrieveOperation);
Employee itEmployee = result.Result as Employee;
Console.WriteLine(itEmployee);

20. Start the Azure Storage Emulator.


21. Start the console application without debugging to view the output of your console application.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-25

Lab B: Storing Event Registration Data in Azure Storage


Tables
Scenario
Even though event registrations could be stored in SQL, you have a unique need. Each event requires a
different registration form that can be changed at any time. Essentially, registrations could be of any
schema. To facilitate this you have elected to use Azure Table Storage for your event registrations.

Objectives
After you complete this lab, you will be able to:

• Use the Azure Store SDK to create a Table Storage client.

• Use the Azure Store SDK to create a table.

• Use the Azure Store SDK to add entities to a table.


• Use the Azure Store SDK to query entities.

• Use Server Explorer in Visual Studio 2013 to view Table Storage entities.

Estimated Time: 45 minutes


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:
• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:


o User name: testuser

o Password: TestPa$$w0rd
5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Populating the Sign-In Form with Registrant Names


Scenario
In this exercise you will:

• Query table entities using a CloudTableClient instance.


MCT USE ONLY. STUDENT USE PROHIBITED
7-26 Storing Tabular Data in Azure

• Use LINQ-to-Objects on a set of entities.

The main tasks for this exercise are as follows:

1. Create an Instance of the CloudTable Class

2. Retrieve Strongly-Typed Registration Records by Partition Key


3. Use LINQ-to-Objects to Project a List of Registrant Names

 Task 1: Create an Instance of the CloudTable Class


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (F):\Mod07\Labfiles\Starter\Tables\Contoso.Events


2. Open the TableStorageHelper.cs file in the Contoso.Events.Worker project.

3. Remove the existing code from the GetRegistrantNames method.

4. Using the _tableClient variable, Create a new CloudTable instance using the GetTableReference
method with the following parameters:

o tableName: EventRegistrations

 Task 2: Retrieve Strongly-Typed Registration Records by Partition Key


1. Create a string filter that finds entities with a PartitionKey equivalent to the eventKey provided by
the GetRegistrantsNames method’s parameters using the following code:

string partitionKey = eventKey;


string filter = TableQuery.GenerateFilterCondition("PartitionKey",
QueryComparisons.Equal, partitionKey);

2. Create a TableQuery with the filter and execute the query using the ExecuteQuery method of the
table variable using the following code:

TableQuery<Registration> query = new TableQuery<Registration>().Where(filter);


IEnumerable<Registration> registrations = table.ExecuteQuery<Registration>(query);

 Task 3: Use LINQ-to-Objects to Project a List of Registrant Names


1. Create a LINQ query that takes the registrations, orders them by LastName, then orders them by
FirstName and finally projects them into a string of this format “{LastName}, {FirstName}” using
the following code:

IEnumerable<string> names = registrations


.OrderBy(r => r.LastName)
.ThenBy(r => r.FirstName)
.Select(r => String.Format("{1}, {0}", r.FirstName, r.LastName));

Note: You can alternatively use the query syntax for LINQ-to-Objects:

IEnumerable<string> names = from r in registrations


orderby r.LastName, r.FirstName
select r.FirstName + ", " + r.LastName;

2. Return the LINQ query as the result of the GetRegistrantsNames method.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-27

Results: After completing this exercise, you will be able to query entities by row key or partition key from
Table Storage.

Exercise 2: Updating the Events Website to use Storage Tables


Scenario
In this exercise you will:

• Update the existing Contoso.Events application to use Table Storage.


The main tasks for this exercise are as follows:

1. Update the Register Controller Action to Store the Registration Record

2. Update the Register ViewModel to Retrieve the Dynamic Stub Registration from the Table

 Task 1: Update the Register Controller Action to Store the Registration Record
1. Open the RegisterController.cs file in the Contoso.Events.Web project.
2. Remove the existing code from the StoreRegistration method.

3. Create a CloudStorageAccount variable using the


Microsoft.WindowsAzure.Storage.ConnectionString stored in the Cloud configuration files using
the following code:

string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Storage.ConnectionString
");
var storageAccount =
Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

4. Create a CloudTable variable using the storage account and a Storage table named
EventRegistrations using the following code:

var tableClient = storageAccount.CreateCloudTableClient();


var table = tableClient.GetTableReference("EventRegistrations");

5. Create and execute a TableOperation to insert the dynamic registration object into the Storage table
using the following code:

var operation = TableOperation.Insert(registration);


table.Execute(operation);

6. Parse the RowKey of the registration as a System.Guid and return the value as the result of the
StoreRegistration method using the following code:

return Guid.Parse(registration.RowKey);

 Task 2: Update the Register ViewModel to Retrieve the Dynamic Stub Registration
from the Table
1. Open the RegisterViewModel.cs file in the Contoso.Events.ViewModels project.

2. Locate the RegisterViewModel constructor that has a single string parameter.


3. Create a CloudStorageAccount variable using the
Microsoft.WindowsAzure.Storage.ConnectionString stored in the Cloud configuration files using
the following code:
MCT USE ONLY. STUDENT USE PROHIBITED
7-28 Storing Tabular Data in Azure

string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Storage.ConnectionString
");
var storageAccount =
Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

4. Create a CloudTable variable using the storage account and a Storage table named
EventRegistrations using the following code:

var tableClient = storageAccount.CreateCloudTableClient();


var table = tableClient.GetTableReference("EventRegistrations");

5. Create a string filter that finds entities with a PartitionKey equivalent to the eventKey provided by
the GetRegistrantsNames method’s parameters using the following code:

string partitionKey = String.Format("Stub_{0}", this.Event.EventKey);


string filter = TableQuery.GenerateFilterCondition("PartitionKey",
QueryComparisons.Equal, partitionKey);

6. Create a TableQuery with the filter and execute the query using the ExecuteQuery method of the
table variable using the following code:

TableQuery query = new TableQuery().Where(filter);


IEnumerable<DynamicTableEntity> tableEntities = table.ExecuteQuery(query);

7. Since the query will only return a single entity, use the SingleOrDefault extension method to get the
DynamicTableEntity variable and then pass that variable into the
DynamicEntity.GenerateDynamicItem static method. Set the RegisterViewModel’s
RegistrationStub property to the result of the method call using the following code:

DynamicTableEntity tableEntity = tableEntities.SingleOrDefault();


this.RegistrationStub = DynamicEntity.GenerateDynamicItem(tableEntity);

Results: After completing this exercise, you will be able to use the Azure Storage SDK to retrieve and
create entities.

Exercise 3: Verify that the Events Web Site is using Azure Storage Tables
for Registrations
Scenario
In this exercise you will:

• Use the Azure Storage Emulator to test storage entities in development.


• Use Visual Studio to debug an application that uses development storage.

The main tasks for this exercise are as follows:

1. Run the Data Generation Console Project to Populate the Azure Storage Table with Data
2. Use Server Explorer in Visual Studio 2013 to View Table Storage Registrations

3. Debug the Cloud Web Project to Register for the Event


4. Use Server Explorer in Visual Studio 2013 to View the New Table Storage Registration
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 7-29

 Task 1: Run the Data Generation Console Project to Populate the Azure Storage
Table with Data
1. Locate the Contoso.Events.Data.Generation project.

2. Debug the Contoso.Events.Data.Generation project.

 Task 2: Use Server Explorer in Visual Studio 2013 to View Table Storage Registrations
1. Open the Windows Azure node of the Server Explorer pane.

2. Open the EventRegistrations table in the Development Azure Storage Account.


3. Explorer the Table entities auto generated by the console project.

 Task 3: Debug the Cloud Web Project to Register for the Event
1. Debug the Contoso.Events.Cloud cloud project.

2. Navigate to and register for an event using the website.

 Task 4: Use Server Explorer in Visual Studio 2013 to View the New Table Storage
Registration
1. Switch to the Contoso.Events - Visual Studio 2013 window

2. Open the Windows Azure node of the Server Explorer pane.


3. Open the EventRegistrations table in the Development Azure Storage Account.

4. Locate your recently created Registration entity.

5. Close the Internet Explorer and Contoso.Events – Visual Studio applications.

Results: After completing this exercise, you will be able to leverage Visual Studio and the Azure emulators
to create a comprehensive development environment for Azure Storage.

Question: Since the Azure Storage SDK shares a CloudStorageAccount class that is used for
all types of storage, what are some of the ways that you can refactor your application to take
advantage of this?
MCT USE ONLY. STUDENT USE PROHIBITED
7-30 Storing Tabular Data in Azure

Module Review and Takeaways


In this module, you were introduced to Azure Storage and the three basic storage types available. You
were also shown examples of how to use the Azure Storage SDK to interact with Table Storage. By using
Table Storage, you can design your application today knowing that your storage mechanism is ready to
scale to massive levels.

Azure SQL Databases provides a service offering for relational databases. It was built for the highest level
of compatibility with the existing management tools and SSDT features in Visual Studio 2013. Leveraging
Entity Framework allows you to write your code once and rely on configuration changes to point your
ORM at the right database depending on your environment.

Best Practice: Configuration settings and Web.config transformations can be used


effectively to point your application at 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(s)
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
8-1

Module 8
Storing Files and Media in Azure
Contents:
Module Overview 8-1

Lesson 1: Azure Storage Blobs 8-2

Lesson 2: Controlling Access to Storage Blobs & Containers 8-4


Lesson 3: Monitoring Storage Blobs 8-6

Lesson 4: Configuring Azure Storage Accounts 8-8


Lesson 5: Azure Files 8-9
Lesson 6: Uploading and Migrating Storage Data 8-10

Lab: Storing Generated Documents in Azure Storage Blobs 8-12

Module Review and Takeaways 8-18

Module Overview
When scaling to many different cloud instances, storing files to a local disk becomes a difficult process to
maintain and an unreliable method of storage. Azure provides a Blob Storage mechanism that offers high
performance and supports Content Delivery Network (CDN) integration for low latency downloads.
Lesson 1, “Azure Blob Storage”, describes the Azure Blob service and the types of blobs supported. Lesson
2, “Blob Storage Permissions”, details the ways that you can secure and grant temporary access to blobs or
containers. Lesson 3, “Azure Storage SDK”, describes the .NET libraries that can be used for Azure Storage
Blobs. Lesson 4, “Blob Storage Internals”, describes monitoring, metrics and the emulator.

Objectives
After completing this module, you will be able to:

• Describe the Blob services in Azure Storage.


• Detail the SDK libraries, namespaces and classes available for blobs.
MCT USE ONLY. STUDENT USE PROHIBITED
8-2 Storing Files and Media in Azure

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 will introduce the Blob Storage service and its basic concepts.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Storage Blobs service.


• Explain the structure of containers and blobs in Blob Storage.

Blob Storage

Blob Types
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-3

REST API for Blob Storage

Structure of Blob Storage


MCT USE ONLY. STUDENT USE PROHIBITED
8-4 Storing Files and Media in Azure

Lesson 2
Controlling Access to Storage Blobs & Containers
Sometimes files need to be secured so they cannot be accessed anonymously. Azure Storage Blobs
contain a mechanism for securing blobs and granting temporary access using query string tokens.

This lesson will introduces the concept of blob permissions and Shared Access Signature tokens.

Lesson Objectives
After completing this lesson, you will be able to:

• Secure a container or blob.


• Generate a Shared Access Signature token.

• Create a Shared Access Policy that can be used to generate SAS tokens.

Container Permissions

Blob Permissions
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-5

Shared Access Signatures

Shared Access Policies

Generating Shared Access Signatures from Policies


MCT USE ONLY. STUDENT USE PROHIBITED
8-6 Storing Files and Media in Azure

Lesson 3
Monitoring Storage Blobs
Just like with other Azure Storage types, monitoring the account and testing in the emulator are
important to understand the behavior of your application.

This lesson will detail the monitoring options available for Azure Storage Blobs and the emulator
implementation.

Lesson Objectives
After completing this lesson, you will be able to:

• Monitor Azure Storage Blobs.

• Describe the implementation of blobs in the Azure Storage Emulator.

Storage Blobs Metrics

Storage Blobs Logging


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-7

Storage Blobs and the Azure Storage Emulator


MCT USE ONLY. STUDENT USE PROHIBITED
8-8 Storing Files and Media in Azure

Lesson 4
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 CORS features for a Storage Account.

Lesson Objectives
After completing this lesson, you will be able to:

• Enable and use CDN to create low-latency replicas of content


• Enable and use CORS to enable cross-domain client script support

Content Delivery Network (CDN)

Cross-Origin Resource Sharing (CORS)


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-9

Lesson 5
Azure Files
Azure Files is a service that provides an SMB file share that can be used to share files among multiple
virtual machines.

This lesson describes the Azure Files service and the File Share logical unit.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Files service


• Describe the relationship between a File Share and a SMB share

Azure Files Overview

File Shares
MCT USE ONLY. STUDENT USE PROHIBITED
8-10 Storing Files and Media in Azure

Lesson 6
Uploading and Migrating Storage Data
Storage accounts would be useless if we could not populate them with files. The various client libraries
and management tools for Azure provides a wealth of options to assist in the ingress of new files into a
Storage Account.

This lesson will cover the Async Blob Copy and migration strategies for Azure Storage Blobs and Azure
Files.

Lesson Objectives
After completing this lesson, you will be able to:

• Use Async Blob Copy to create a job for duplicating blobs between storage accounts
• Describe strategies for uploading files to Azure Storage Blobs or Azure Files

Async Blob Copy

Migrating Data to Azure Storage Blobs


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-11

Migrating Data to Azure Files


MCT USE ONLY. STUDENT USE PROHIBITED
8-12 Storing Files and Media in Azure

Lab: Storing Generated Documents in Azure Storage Blobs


Scenario
Now that the Contoso Events application generates Word documents, you need a place to store these
documents. In this lab, you will store the generated Word documents in Azure Storage Blobs. You will
also create a protected container so that the Word documents cannot be accessed anonymously. Finally,
you will create the logic to generate SAS tokens for temporary access to one of the Word documents.

Objectives
After you complete this lab, you will be able to:

• Create a container using the Azure Management Portal.


• Add blobs to a container using the Azure Storage SDK.

• Download blobs from a container using MemoryStream objects.


• Generate SAS Tokens for access to a blob.

Estimated Time: 60 minutes

For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:

o User name: testuser


o Password: TestPa$$w0rd
5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Implement Azure Storage Blobs


Scenario
In this exercise you will:

• Create a blob container using the Azure Management Portal.

• Add blob files to a container.


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-13

• Access blob files in a container.

The main tasks for this exercise are as follows:

1. Login to the Azure Preview Portal

2. Create a Container using the Management Portal


3. Add and Access Blob Files in Your Container

 Task 1: Login to the Azure Preview Portal


1. Log into the Azure Management Portal (https://portal.azure.com).

 Task 2: Create a Container using the Management Portal


1. View the list of Storage instances for your subscription.

2. Navigate to the Containers page for your stor20532[Your Name] subscription.

3. Create a new Container with the following values.

o Name: example
o Access Type: Container

 Task 3: Add and Access Blob Files in Your Container


1. Open Visual Studio 2013.
2. Open the Windows Azure node of the Server Explorer pane.

3. Open the example container in your Azure Storage Account:

o Account name: stor20532[Your Name]


o Container name: example

4. In the Container tab, upload the sample file located at the following location:

o Sample File Location: (E):\Mod08\LabFiles\Starter\samplefile.txt


5. View the sample file’s text in Internet Explorer using the following Url:
o Url: http://[storage account].blob.core.windows.net/example/samplefile.txt

Results: After completing this exercise, you will be able to create a blob container using the Management
Portal and view blobs in the container.

Exercise 2: Populating the Container with Files and Media


Scenario
In this exercise you will:

• Use the Azure Storage SDK to access blobs in your storage account.

• Use the Azure Storage SDK to create blobs in your storage account.
The main tasks for this exercise are as follows:

1. Open the Blob Helper in the Cloud Service Worker Project

2. Add Word Documents to the Container After They are Created


MCT USE ONLY. STUDENT USE PROHIBITED
8-14 Storing Files and Media in Azure

 Task 1: Open the Blob Helper in the Cloud Service Worker Project
1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod08\Labfiles\Starter\Contoso.Events

2. Open the BlobStorageHelper.cs file in the Contoso.Events.Worker project.

 Task 2: Add Word Documents to the Container After They are Created
1. Remove the existing code from the CreateBlob method.

2. Create a CloudBlobContainer variable for the signin container and ensure that the container exists
using the following code:

CloudBlobContainer container = _blobClient.GetContainerReference("signin");


container.CreateIfNotExists();

3. Create a name for your blob using the following format “{eventKey}_SignIn_{date}”.

4. Create a blob reference using the new blobName, seek the MemoryStream back to the beginning
and upload the stream to the blob using the UploadFromStream method using the following code:

ICloudBlob blob = container.GetBlockBlobReference(blobName);


stream.Seek(0, SeekOrigin.Begin);
blob.UploadFromStream(stream);

5. Return the blob’s Uri property as the result of the method.

Results: After completing this exercise, you will be able to use the Azure Storage SDK to manage blobs
and containers in your storage account.

Exercise 3: Retrieving Files and Media From the Container


Scenario
In this exercise you will:
• Retrieve blobs from your storage account using the Azure Storage SDK.

The main tasks for this exercise are as follows:

1. Download Documents from Blob Storage and Stream to Client


2. Generate the Test Data

3. Download Generated Sign-In Sheets from Blob Storage

 Task 1: Download Documents from Blob Storage and Stream to Client


1. Open the DownloadViewModel.cs file in the Contoso.Events.ViewModels project.
2. Remove the existing code from the GetStream method.

3. Use the _storageAccount variable to create a new CloudBlobClient, then create a


CloudBlobContainer variable for the signin container and ensure that the container exists using the
following code:

CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();


CloudBlobContainer container = blobClient.GetContainerReference("signin");
container.CreateIfNotExists();
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-15

4. Create a blob reference using the new blobName and use the OpenReadAsync method to create a
Stream variable using the following code:

ICloudBlob blob = container.GetBlockBlobReference(_blobId);


Stream blobStream = await blob.OpenReadAsync();

5. Return a new instance of the DownloadPayload class assigning the Stream variable to the
DownloadPayload.Stream property and the ICloudBlob variable’s Properties.ContentType value
for the DownloadPayload.ContentType property.

 Task 2: Generate the Test Data


1. Debug the Contoso.Events.Data.Generation project to generate the SQL and Azure Storage Tables
data.

 Task 3: Download Generated Sign-In Sheets from Blob Storage


1. Debug the solution.
Note: You will configure the solution to launch the Contoso.Events.Cloud project in debug
and simply launch the Contoso.Events.Management project without debugging.

2. After the Contoso Events (Contoso.Events.Cloud) website is open, use IIS Express to open the
Contoso.Events.Management website.
3. In the Administration web application, choose any event, generate a sign-in sheet and download the
sign-in sheet.

Note: Currently, the web applications gets a Stream of the blob and uses MVC’s File helper to
return the file to the user. The implementation is available to view in the DownloadSignIn method
of the HomeController class in the Contoso.Events.Management project.

Results: After completing this exercise, you will be able to download blobs from your storage account
using the Azure Storage SDK.

Exercise 4: Specifying Permissions for the Container


Scenario
In this exercise you will:

• Use the Visual Studio 2013 Server Explorer to modify a container.

• Generate a SAS Token using the Azure Storage SDK.

The main tasks for this exercise are as follows:

1. Modify Container Access using Server Explorer

2. Generate Temporary SAS Tokens using the SDK

3. Download Documents from a Protected Container using the SAS Token

 Task 1: Modify Container Access using Server Explorer


1. Switch back to the Contoso.Events - Visual Studio 2013 window and stop debugging.
2. Open the Windows Azure node of the Server Explorer pane.

3. View the signin container in your Azure development Storage Account:


MCT USE ONLY. STUDENT USE PROHIBITED
8-16 Storing Files and Media in Azure

o Account name: Development

o Container name: signin

4. Change the signin container’s public access to Off.

 Task 2: Generate Temporary SAS Tokens using the SDK


1. Open the DownloadViewModel.cs file in the Contoso.Events.ViewModels project.

2. Remove the existing code from the GetSecureUrl method.

3. Use the _storageAccount variable to create a new CloudBlobClient, then create a


CloudBlobContainer variable for the signin container and ensure that the container exists using the
following code:

CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();


CloudBlobContainer container = blobClient.GetContainerReference("signin");
container.CreateIfNotExists();

4. Create a new instance of the SharedAccessBlobPolicy class, set the expiry time to 15 minutes from
the current time and set the blob permission to read using the following code:

SharedAccessBlobPolicy blobPolicy = new SharedAccessBlobPolicy();


blobPolicy.SharedAccessExpiryTime = DateTime.Now.AddHours(0.25d);
blobPolicy.Permissions = SharedAccessBlobPermissions.Read;

5. Create a new instance of the BlobContainerPermissions class, add the newly created
SharedAccessBlobPolicy with the name “ReadBlobPolicy” and disable public access using the
following code:

BlobContainerPermissions blobPermissions = new BlobContainerPermissions();


blobPermissions.SharedAccessPolicies.Add("ReadBlobPolicy", blobPolicy);
blobPermissions.PublicAccess = BlobContainerPublicAccessType.Off;

6. Use the CloudBlobContainer asynchronous SetPermissionsAsync method to apply the


BlobContainerPermissions variable, then generate a SAS Token using the
GetSharedAccessSignature method using the following code:

await container.SetPermissionsAsync(blobPermissions);
string sasToken = container.GetSharedAccessSignature(new SharedAccessBlobPolicy(),
"ReadBlobPolicy");

7. Create a blob reference using the _blobId variable then store the Blob’s Uri in a Uri variable using the
following code:

ICloudBlob blob = container.GetBlockBlobReference(_blobId);


Uri blobUrl = blob.Uri;

8. Concatenate the Uri variable’s AbsoluteUri property with the sasToken concatenated and return the
new string as the result of the method.

 Task 3: Download Documents from a Protected Container using the SAS Token
1. Debug the solution.

2. After the Contoso Events (Contoso.Events.Cloud) website is open, use IIS Express to open the
Contoso.Events.Management website.

3. In the Administration web application, choose any event, generate a sign-in sheet and download the
sign-in sheet.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 8-17

Note: You can always look at Internet Explorer’s download manager if you want to see the full
URL used (with SAS Token) to download the file.

4. Close the Internet Explorer and Contoso.Events – Visual Studio applications.

Results: After completing this exercise, you will be able to modify the permissions of containers and
generate SAS Tokens for the containers.

Question: Your server application needs to generate a Shared Access Signature for the client
to download a subset of blobs in a single container. Should you give the signature read
access to the container or read access to the individual blobs?
MCT USE ONLY. STUDENT USE PROHIBITED
8-18 Storing Files and Media in Azure

Module Review and Takeaways


In this module, you used Azure Storage Blobs to store files for your cloud application. You also learned
how to use the Azure Storage SDK to manage blobs, containers and their permissions. Finally you
explored the mechanisms used to generate SAS Tokens for a container.

Review Question(s)
Question: You have a web application that allows your end-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
9-1

Module 9
Designing a Communication Strategy using Queues and
Service Bus
Contents:
Module Overview 9-1

Lesson 1: Queue Mechanisms in Azure 9-2


Lesson 2: Azure Storage Queues 9-3

Lesson 3: Handling Storage Queue Messages 9-5


Lesson 4: Azure Service Bus 9-6
Lesson 5: Azure Service Bus Queues 9-8

Lesson 6: Azure Service Bus Relay 9-10

Lesson 7: Azure Service Bus Notification Hubs 9-12


Lab: Using Queues and Service Bus to Manage Communication Between Web
Applications in Azure 9-14
Module Review and Takeaways 9-23

Module Overview
With web applications presenting content and worker roles processing logic, there needs to be a
mechanism to communicate between these different entities. Azure provides two queuing mechanisms
that can be used for this purpose. Lesson 1, “Queue Mechanisms in Azure” introduces the Azure Storage
Queues and Service Bus Queues. Lesson 2, “Azure Storage Queues”, introduces the queue mechanism
available in Azure Storage accounts. Lesson 3, “Using the Azure Storage SDK to Manage Storage Queues”,
describes the classes and methods that can be used to interact with queues. Lesson 4, “Monitoring Queue
Storage”, details how you can use Visual Studio to view queue data in an Azure Storage account. Lesson
5, “What is Azure Service Bus?”, introduces the Service Bus offering in Azure. Lesson 6, “Azure Service Bus
Queues”, describes the queuing mechanism available in Service Bus and the difference between that and
Azure Storage Queues. Lesson 7, “Using the Azure Service Bus SDK to Manage Service Bus Queues”,
details how you can use the classes and methods available in the SDK to manage Service Bus Queues.

Objectives
After completing this module, you will be able to:
• Describe Azure Storage Queues.

• Describe Azure Service Bus.

• Describe Azure Service Bus Queues.


MCT USE ONLY. STUDENT USE PROHIBITED
9-2 Designing a Communication Strategy using Queues and Service Bus

Lesson 1
Queue Mechanisms in Azure
There are multiple ways to queue messages that need to be sent to workers or other services in Azure.

This lesson will introduce the Azure Storage and Service Bus queues.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe Azure Storage Queues.


• Describe Azure Service Bus.

Azure Storage Queues

Service Bus Queues


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-3

Lesson 2
Azure Storage Queues
Azure Storage Queues provide a consistent and reliable way to store messages that can be consumed by
multiple workers.

This lesson will introduce the Azure Storage Queues service and describe some of its characteristics.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Storage Queues.


• Describe the operations that can be performed using the REST API.

• Describe the characteristics of the Storage Queues in the Azure Storage Emulator.

Storage Queues Overview

REST API
MCT USE ONLY. STUDENT USE PROHIBITED
9-4 Designing a Communication Strategy using Queues and Service Bus

Viewing Queue Storage Data

Storage Queues in the Storage Emulator


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-5

Lesson 3
Handling Storage Queue Messages
The key to managing Storage Queues is understanding and handling messages.

This lesson will demonstrate Storage Queues and their messages.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the characteristics of messages in Storage Queues.


• Describe message operations.

Message Characteristics

Message Operations
MCT USE ONLY. STUDENT USE PROHIBITED
9-6 Designing a Communication Strategy using Queues and Service Bus

Lesson 4
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 Azure Service Bus and it’s features.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe Azure Service Bus


• List the features of Service Bus

• Create a Service Bus namespace

Service Bus Overview

Service Bus Features


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-7

Namespaces
MCT USE ONLY. STUDENT USE PROHIBITED
9-8 Designing a Communication Strategy using Queues and Service Bus

Lesson 5
Azure Service Bus Queues
Service Bus provides queue functionality that can be used to marshal messages from reporting
applications to consuming applications. The Service Bus Queue is different than the Azure Storage
Queues.

This lesson will describe the Service Bus Queues and describe the difference between these queues and
Azure Storage Queues.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe Service Bus Queues.


• Describe the differences between Service Bus Queues and Azure Storage Queues.

Service Bus Queues Overview

Queue Message Delivery


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-9

Characteristics of Service Bus Queue Messages

Service Bus Queues vs. Storage Queues

Monitoring a Service Bus Queue


MCT USE ONLY. STUDENT USE PROHIBITED
9-10 Designing a Communication Strategy using Queues and Service Bus

Lesson 6
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. By connecting the WCF service to the relay in an outgoing
manner, you clients only need to be able to connect to the Service Bus endpoint in Azure to be able to
communicate with your WCF service.

This lesson will describe the benefits and architecture of Service Bus Relays.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the benefits of using a Service Bus Relay.


• Detail the architecture of Service Bus Relays.

Service Bus Relay Overview

Benefits of Service Bus Relay


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-11

Service Bus Relay Architecture

Management Credentials

Event & One-Way Relay Binding


MCT USE ONLY. STUDENT USE PROHIBITED
9-12 Designing a Communication Strategy using Queues and Service Bus

Lesson 7
Azure Service Bus Notification Hubs
Notification Hubs provides a simple interface for a highly-scalable managed mobile push notification
platform. 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:

• Describe the architecture of Notification Hubs in Azure

• Register a client device to a Notification Hub from either the client or service application

• Use templates to generalize a notification across platforms


• Use tags to target notifications to specific client devices

Service Bus Notification Hubs Overview

Benefits of using Notification Hubs


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-13

Notification Hubs Architecture

Registrations

Message Templates and Tags


MCT USE ONLY. STUDENT USE PROHIBITED
9-14 Designing a Communication Strategy using Queues and Service Bus

Lab: Using Queues and Service Bus to Manage


Communication Between Web Applications in Azure
Scenario
Now that we are generating sign-in sheets in a worker roles, you need a scalable and consistent way to
enqueue messages for the worker role. You have decided to use an Azure queue mechanism so that you
can scale the worker roles in isolation to meet the demand of the queue size. In this lab, you will begin by
implementing communication between the Administration Web Application and the Worker Role using
Azure Storage Queues. Then you will replace that implementation with an implementation that uses
Service Bus Queues.

Currently, your on premise 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:
• Create a Service Bus Namespace using the Management Portal.

• Create Azure Storage Queue messages.

• Consume Azure Storage Queue messages.


• Create Service Bus Queue messages.

• Consume Service Bus Queue messages.

• 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.
Estimated Time: 90 minutes

For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-15

o User name: testuser

o Password: TestPa$$w0rd

5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Creating an Azure Service Bus Namespace


Scenario
In this exercise you will:

• Create a Service Bus Namespace using the Management Portal.


The main tasks for this exercise are as follows:

1. Create the Service Bus Namespace using the Management Portal

 Task 1: Create the Service Bus Namespace using the Management Portal

Note: Service Bus functionality is not available yet in the new Preview Portal. Because of
this, the existing Management Portal will be used for this lab.

1. Log into the Azure Management Portal (https://manage.windowsazure.com).

2. View the list of Service Bus namespaces for your subscription.


3. Create a new Service Bus namespace with the following values:

o Namespace Name: sb20532[Your Name]

o Region: Select the region that is closest to you


4. Write down the connection string, shared secret key and issuer for your newly created Service Bus
namespace.

5. Create a new queue in your namespace with the following details:

o Queue Name: signin

o Namespace: sb20532[Your Name]

Results: After completing this exercise, you will be able to create a Service Bus Namespace using the
Azure Management Portal.

Exercise 2: Using Azure Queue Storage for Document Generation


Scenario
In this exercise you will:

• Create queue messages using Azure Storage Queues.

• Consume queue messages from Azure Storage Queues.

The main tasks for this exercise are as follows:

1. Update Worker Role to Consume Requests from the Queue

2. Update Administration Application to Add Requests to the Queue


MCT USE ONLY. STUDENT USE PROHIBITED
9-16 Designing a Communication Strategy using Queues and Service Bus

3. Generate the Test Data

4. Debug and Verify the Application

 Task 1: Update Worker Role to Consume Requests from the Queue


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod09\Labfiles\Starter\Queues\Contoso.Events


2. Open the TableStorageQueueHelper.cs file.

3. In the TableStorageQueueHelper constructor get the Queue Client and name of the queue using
the following code:

CloudStorageAccount storageAccount = base.StorageAccount;


_queueClient = storageAccount.CreateCloudQueueClient();
_signInQueueName = CloudConfigurationManager.GetSetting("SignInQueueName");

4. Remove the existing code from the Receive method.


5. Create a new CloudQueue instance and ensure that the instance exists using the following code:

CloudQueue queue = _queueClient.GetQueueReference(_signInQueueName);


queue.CreateIfNotExists();

6. Get the CloudQueueMessage variable by calling the GetMessage method of the CloudQueue class
and pass the message variable into the constructor of the TableStorageQueueMessage class using
the following code:

CloudQueueMessage message = queue.GetMessage();


return new TableStorageQueueMessage(message);

7. In the CompleteMessage method, create a new CloudQueue instance and ensure that the instance
exists using the following code:

CloudQueue queue = _queueClient.GetQueueReference(_signInQueueName);


queue.CreateIfNotExists();

8. Call the DeleteMessage method of the CloudQueue class with the CloudQueueMessage variable as
the first parameter using the following code:

queue.DeleteMessage(message);

 Task 2: Update Administration Application to Add Requests to the Queue


1. Open the SignInSheetViewModel.cs file.
2. In the GenerateSignInSheetTableStorage method, create a CloudStorageAccount and
CloudQueueClient with the Microsoft.WindowsAzure.Storage.ConnectionString setting value
using the following code:

CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(tableStorageConnectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

3. Using the SignQueueName cloud setting value, create a new CloudQueue instance and ensure that
the instance exists using the following code:

CloudQueue queue = queueClient.GetQueueReference(signInQueueName);


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-17

queue.CreateIfNotExists();

4. Add the message to the queue by creating a new instance of the CloudQueueMessage class using
the string message as the constructor parameter and adding the new instance with the CloudQueue
AddMessage method using the following code:

CloudQueueMessage queueMessage = new CloudQueueMessage(message);


queue.AddMessage(queueMessage);

 Task 3: Generate the Test Data


1. Debug the Contoso.Events.Data.Generation project to generate the SQL and Azure Storage Tables
data.

 Task 4: Debug and Verify the Application


1. Debug the solution.

Note: You should configure the solution to launch the Contoso.Events.Cloud project in
debug and simply launch the Contoso.Events.Management project without debugging.

2. After the Contoso Events (Contoso.Events.Cloud) website is open, use IIS Express to open the
Contoso.Events.Administration website.

3. Switch back to the Contoso.Events - Visual Studio 2013 window.


4. Open the WorkerRole.cs file.

5. Add a breakpoint to the following line:

HandleMessage(message);

6. Switch back to the Home - Contoso.Events.Administration window.


7. In the Administration web application, choose any event, generate a sign-in sheet and download the
sign-in sheet.

8. Verify that the application pauses execution at the debug breakpoint.


9. Stop Debugging in Visual Studio and close Internet Explorer.

Results: After completing this exercise, you will be able to create and consume messages from Azure
Storage Queues.

Exercise 3: Use Service Bus Queues for Document Generation


Scenario
In this exercise you will:

• Create queue messages using Service Bus Queues.

• Consume queue messages from Service Bus Queues.


The main tasks for this exercise are as follows:

1. Update Worker Role to Consume Requests from the Queue


MCT USE ONLY. STUDENT USE PROHIBITED
9-18 Designing a Communication Strategy using Queues and Service Bus

2. Update Administration Application to Add Requests to the Queue

3. Debug and Verify the Application

 Task 1: Update Worker Role to Consume Requests from the Queue


1. Update the ServiceConfiguration.Local.cscfg file in the Contoso.Events.Cloud project to use the
connection string for your Service Bus namespace as the setting value for the
Microsoft.ServiceBus.ConnectionString setting:

2. Name: Microsoft.ServiceBus.ConnectionString
3. Value: [Your Service Bus Connection String]

4. Open the ServiceBusQueueHelper.cs file.

5. In the ServiceBusQueueHelper constructor get the Queue Client using the following code:

string serviceBusConnectionString =
CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
string signInQueueName = CloudConfigurationManager.GetSetting("SignInQueueName");
_client = QueueClient.CreateFromConnectionString(serviceBusConnectionString,
signInQueueName);

6. Remove the existing code from the Receive method.

7. Invoke the Receive method of the QueueClient class, store the result in a BrokeredMessage and
pass the new variable into the ServiceBusQueueMessage constructor using the following code:

BrokeredMessage message = _client.Receive();


return new ServiceBusQueueMessage(message);

8. In the CompleteMessage method, invoke the Complete method of the BrokeredMessage


parameter using the following code:

message.Complete();

9. In the AbandonMessage method, invoke the Abandon method of the BrokeredMessage


parameter using the following code:

message.Abandon();

10. Open the WorkerRole.cs file.


11. Locate and replace the line of code creating the TableStorageQueueHelper:

var queueHelper = new TableStorageQueueHelper();

with a line creating a new instance of the ServiceBusQueueHelper:

var queueHelper = new ServiceBusQueueHelper();

 Task 2: Update Administration Application to Add Requests to the Queue


1. Update the Web.config file in the Contoso.Events.Management project to use the connection
string for your Service Bus namespace as the setting value for the
Microsoft.ServiceBus.ConnectionString app setting:

o Key: Microsoft.ServiceBus.ConnectionString

o Value: [Your Service Bus Connection String]


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-19

2. Open the SignInSheetViewModel.cs file.

3. In the constructor, locate the following line of code:

GenerateSignInSheetTableStorage(context, eventItem, messageString);

4. Replace the above line of code with the following line of code:

GenerateSignInSheetServiceBus(context, eventItem, message);

5. In the GenerateSignInSheetServiceBus method, create a QueueClient with the


Microsoft.WindowsAzure.Storage.ConnectionString setting value and the SignInQueueName
setting value using the following code:

QueueClient client =
QueueClient.CreateFromConnectionString(serviceBusConnectionString, signInQueueName);

6. Add the message to the queue by creating a new instance of the BrokeredMessage class using the
QueueMessage message as the constructor parameter and adding the new instance with the
QueueClient Send method using the following code:

BrokeredMessage queueMessage = new BrokeredMessage(message);


client.Send(queueMessage);

 Task 3: Debug and Verify the Application


1. Debug the solution.
2. After the Contoso Events (Contoso.Events.Cloud) website is open, use IIS Express to open the
Contoso.Events.Administration website.

3. Switch back to the Contoso.Events - Visual Studio 2013 window.


4. Open the WorkerRole.cs file.
5. Add a breakpoint to the following line:

HandleMessage(message);

6. Switch back to the Home - Contoso.Events.Administration window.

7. In the Administration web application, choose any event, generate a sign-in sheet and download the
sign-in sheet.

8. Verify that the application pauses execution at the debug breakpoint.

9. Stop Debugging in Visual Studio and close Internet Explorer.

Results: After completing this exercise, you will be able to create and consume messages from Azure
Storage Queues.

Exercise 4: Use Service Bus Relay to Connect a WCF Service and Client[s]
Scenario
In this exercise you will:
• Manage the XML configuration for a WCF service.
MCT USE ONLY. STUDENT USE PROHIBITED
9-20 Designing a Communication Strategy using Queues and Service Bus

• Modify an existing WCF service to use Service Bus Relay bindings

• Manage the C# configuration for a WCF service.

• Update a WCF client to use a Service Bus Relay binding

• Consume a WCF service using Service Bus Relay endpoints.


The main tasks for this exercise are as follows:

1. Test the Existing WCF Service using a Console Application


2. Modify the WCF Service Endpoints to use Service Bus Relay

3. Test the Relayed WCF Service using a Console Application

4. Updating the Cloud Web Application to Connect to the Relayed WCF Service
5. Debug the Cloud Web Application

 Task 1: Test the Existing WCF Service using a Console Application


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod09\ Labfiles\Starter\Relay\Contoso.Events


2. Open the Contoso.Events.Lodging.Client solution from the following location:

o File location: Allfiles (E):\Mod09\ Labfiles\Starter\Relay\Contoso.Events.Lodging.Client

3. Switch back to the Contoso.Events - Visual Studio 2013 window.


4. Debug the Contoso.Events solution.

5. Switch back to the Contoso.Events.Lodging.Client - Visual Studio 2013 window.

6. Debug the Contoso.Events.Lodging.Client solution.


7. Switch back to the Contoso.Events - Visual Studio 2013 window.

8. Stop debugging the solution.

 Task 2: Modify the WCF Service Endpoints to use Service Bus Relay
1. Switch back to the Contoso.Events - Visual Studio 2013 window.

2. Open the App.config file in the Contoso.Events.Lodging project.

3. Update the service endpoint to use a netTcpRelayBinding instead of a netTcpBinding.

4. Update the service endpoint to use an address in the following format:

o sb://[namespace].servicebus.windows.net/lodging

o Filling in the [namespace] tag with the name of your namespace.

5. Update the ServiceBusRelayBehavior behavior element with the following content:

<behavior name="ServiceBusRelayBehavior">
<transportClientEndpointBehavior>
<tokenProvider>
<sharedSecret issuerName="owner" issuerSecret="[key]" />
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>

6. Locate the issuerSecret attribute in the sharedSecret element and replace it with your previously
recorded Default Key.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-21

 Task 3: Test the Relayed WCF Service using a Console Application


1. Debug the solution.

2. Switch back to the Contoso.Events.Lodging.Client - Visual Studio 2013 window.

3. Open the Program.cs file in the Contoso.Events.Lodging.Client project.

4. Locate the GetHotels method.

5. Replace the line that creates the Uri:

Uri serviceUri = new Uri("net.tcp://localhost:8000/lodging", UriKind.Absolute);


With a line that uses the CreateServiceUri helper method:
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", "[namespace]",
"lodging");

6. Update the NetTcpBinding with its relay equivalent (NetTcpRelayBinding).

7. After the creation of the ChannelFactory<ILodgingService> instance, create an endpoint behavior


with the Shared Secret Token provider using the following code:

TransportClientEndpointBehavior endpointBehavior = new


TransportClientEndpointBehavior();
endpointBehavior.TokenProvider =
TokenProvider.CreateSharedSecretTokenProvider("owner", "[key]");
cf.Endpoint.EndpointBehaviors.Add(endpointBehavior);

8. Debug the solution.

 Task 4: Updating the Cloud Web Application to Connect to the Relayed WCF Service
1. Copy the GetHotels method from the Program.cs file.

2. Switch back to the Contoso.Events - Visual Studio 2013 window and stop debugging.
3. Open the HotelsViewModel.cs file in the Contoso.Events.ViewModels project.

4. Replace the GetHotels method that returned an empty Enumerable with your copied method.

private static IEnumerable<Hotel> GetHotels()


{
return Enumerable.Empty<Hotel>();
}

 Task 5: Debug the Cloud Web Application


1. Configure Visual Studio to use Multiple startup projects with the following configuration:

o Contoso.Events.Cloud: Start without debugging


o Consoto.Events.Lodging: Start without debugging

o Contoso.Events.Management: None

2. Debug the Contoso.Events.Data.Generation project to generate the SQL and Azure Storage Tables
data.

3. Close Microsoft Visual Studio 2013.

4. Re-launch Microsoft Visual Studio 2013 as an Administrator.


5. Open the Contoso.Events solution:

o File location: Allfiles (E):\Mod09\ Labfiles\Starter\Relay\Contoso.Events


MCT USE ONLY. STUDENT USE PROHIBITED
9-22 Designing a Communication Strategy using Queues and Service Bus

6. Start the Contoso.Events solution.

7. Close the Internet Explorer and Contoso.Events – Visual Studio applications.

Results: After completing this exercise, you will be able to connect existing WCF applications to clients
using Service Bus Relay.

Question: What are some of the ways that you can automate the change of your WCF
bindings from their on premise versions to a Service Bus Relay binding after the projects are
published?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 9-23

Module Review and Takeaways


In this module, you were introduced to Azure Storage Queues. You were also introduced to the Service
Bus namespaces and the various features that are available for use in your cloud applications. Finally, the
two queue mechanisms were compared. Below is a link to a MSDN article that goes into a deeper
comparison of the two queue services:

Reference Links: http://go.microsoft.com/fwlink/?LinkID=510217

Review Question(s)
Question: Which Queuing mechanism is better suited for massive amounts of messages?

Question: If you have an application that cannot afford to lose any messages, should you
use PeekLock or ReceiveAndDelete mode in your consuming client? How do you check to
see if the message is a duplicate?

Question: If you have a weather app, use Notification Hubs for messaging and you would
like to let people within a specific zip code receive an emergency alert for a hurricane, how
would you architect your application to support this?
MCT USE ONLY. STUDENT USE PROHIBITED
9-24 Designing a Communication Strategy using Queues and Service Bus
MCT USE ONLY. STUDENT USE PROHIBITED
10-1

Module 10
Automating Integration with Azure Resources
Contents:
Module Overview 10-1

Lesson 1: Azure SDK Client Libraries 10-2

Lesson 2: Scripting Azure Service Management using PowerShell 10-3


Lesson 3: Azure REST Interface 10-6

Lesson 4: Azure Resource Manager 10-7


Lab: Automating the Creation of a Test Environment using PowerShell 10-10
Module Review and Takeaways 10-16

Module Overview
While many of the Azure service can be managed using the portals and Visual Studio, scripting can be
used to completely automate the management of the same resources. As part of managing Azure
resources, this module will look at automating the services’ lifecycles using Client Libraries, PowerShell,
REST and the Resource Manager. Lesson 1, “Azure SDK Client Libraries”, briefly looks at the client libraries
available for managing and interacting with Azure services. Lesson 2, “Scripting Azure Service
Management using PowerShell”, describes the modules available for managing services using the
traditional methods or the Resource Manager using Azure PowerShell cmdLets. Lesson 3, “Azure REST
Interface”, introduces and briefly describes the Service Management API. Lesson 4, “Resource Manager”,
discusses the new Resource Manager in Azure and the concepts associated with the new method of
managing resources.

Objectives
After completing this module, you will be able to:
• Describe the Azure SDKs and client libraries.

• Use PowerShell to automate Azure service management.

• Describe the Service Management API and how to authenticate to the API.
• Use the Resource Manager to create resource groups and templates.
MCT USE ONLY. STUDENT USE PROHIBITED
10-2 Automating Integration with Azure Resources

Lesson 1
Azure SDK Client Libraries
Client Libraries are available for a variety of platforms to manage Azure services and create constructs
within existing services.

This lesson will list the SDKs available and how they are used to manage Azure services.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure SDKs and their platforms.


• Describe how the SDKs can be used to create Cloud Service roles.

Azure SDKs

Cloud Services
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-3

Lesson 2
Scripting Azure Service Management using PowerShell
PowerShell can be used to automate many of the administration that IT Pros perform on a daily basis. For
developers, PowerShell can be used to facilitate and automate many of their DevOps responsibilities.

This lesson will describe the two sets of CmdLets available in Azure PowerShell.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure PowerShell module.


• Detail the options for authenticating to Azure using PowerShell.

• Use PowerShell cmdLets to create an Azure service instance.

Azure PowerShell Module

Installing Azure PowerShell cmdLets


MCT USE ONLY. STUDENT USE PROHIBITED
10-4 Automating Integration with Azure Resources

Authenticating to Azure using PowerShell

Demonstration: Managing an Azure Web Site using PowerShell


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:
• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
4. If necessary, sign in using the following credentials:

• User name: testuser

• Password: TestPa$$w0rd
5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Download and run the Azure PowerShell installation executable.

• Url: http://go.microsoft.com/fwlink/p/?linkid=320376

2. Install the Azure PowerShell module.


3. Open the Windows Azure PowerShell application.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-5

4. Authenticate to Azure by logging in to your Azure Active Directory account:

Add-AzureAccount

5. View your active account details:

Get-AzureAccount

6. Authenticate to Azure by downloading and saving the Publish Settings file using the following
command and details:

Get-AzurePublishSettingsFile

• File name: 20532

• Save as type: PUBLISHSETTINGS file


• Directory: E:\Mod10\Demofiles

7. Authenticate to Azure by importing the saved Publish Settings file:

Import-AzurePublishSettingsFile E:\Mod10\Demofiles\20532.publishsettings

8. View your active account details:

Get-AzureAccount

9. Create a new Azure Website using a unique name:

New-AzureWebsite [Unique Name]

10. View the list of Websites for your subscription:

Get-AzureWebsite

11. View the details for your newly created Website:

Get-AzureWebsite –Name [Unique Name]

12. Stop your newly created Website instance:

Stop-AzureWebsite –Name [Unique Name]

13. View the list of Websites for your subscription:

Get-AzureWebsite

14. Remove your newly created Website instance:

Remove-AzureWebsite –Name [Unique Name]

15. View the details for your recently deleted Website:

Get-AzureWebsite –Name [Unique Name]


MCT USE ONLY. STUDENT USE PROHIBITED
10-6 Automating Integration with Azure Resources

Lesson 3
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 Service Management API that can be used
to manage services regardless of your current platform.

This lesson will describe the Service Management API and how to authenticate against the API.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Service Management API.

• Detail the two options for authenticating to the API.

Service Management REST API

Authenticating Requests to the Service Management REST API


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-7

Lesson 4
Azure Resource Manager
With the new 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 has been made much easier.

This lesson will describe the new Resource Manager offering.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure Resource Manager.

• Describe resource groups and resource group templates.

• Use the Resource Manager to create multiple resources as a single managed unit.

Azure Resource Manager Overview

Resource Groups
MCT USE ONLY. STUDENT USE PROHIBITED
10-8 Automating Integration with Azure Resources

Resource Group Templates

Demonstration: Viewing a Resource Group Template


For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:

• User name: testuser

• Password: TestPa$$w0rd

5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Demonstration Steps
1. Open the Windows Azure PowerShell application.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-9

2. Switch to using the AzureResourceManager mode:

Switch-AzureMode AzureResourceManager

3. Authenticate to Azure by logging in to your Azure Active Directory account:

Add-AzureAccount

4. View the list of Resource Gallery Templates available for your subscription:

Get-AzureResourceGroupGalleryTemplate

5. View the description of the MSOpenTech.OracleDB12cWebLogicServer12cStand resource group


template using the following command:

Get-AzureResourceGroupGalleryTemplate -Identity
MSOpenTech.OracleDB12cWebLogicServer12cStand.0.2.0-preview

6. Download the JSON template of the MSOpenTech.OracleDB12cWebLogicServer12cStand


resource group template using the following command:

Save-AzureResourceGroupGalleryTemplate -Identity
MSOpenTech.OracleDB12cWebLogicServer12cStand.0.2.0-preview -Path E:\Mod10\Demofiles

7. Open the MSOpenTech.OracleDB12cWebLogicServer12cStand.0.2.0-preview.json file from the


following location:

• File location: Allfiles (E):\Mod10\Demofiles\


MCT USE ONLY. STUDENT USE PROHIBITED
10-10 Automating Integration with Azure Resources

Lab: Automating the Creation of a Test Environment using


PowerShell
Objectives
After you complete this lab, you will be able to:

• Install the Azure PowerShell modules


• Authenticate to Azure using PowerShell

• Create a Website instance using PowerShell

• Remove a Website instance using PowerShell


• Create a Resource Group from a template using PowerShell

• Remove a Resource Group using PowerShell


Estimated Time: 45
For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.
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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.
4. If necessary, sign in using the following credentials:
• User name: testuser

• Password: TestPa$$w0rd

5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Prepare Azure PowerShell Environment


Scenario
In this exercise you will:

• Install the Azure PowerShell modules and cmdLets

• Authenticate to Azure in PowerShell using a Publish Settings File

• View account details using PowerShell


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-11

The main tasks for this exercise are as follows:

1. Install the Azure PowerShell Module

2. Import your Azure Subscription using a Publish Setting File

 Task 1: Install the Azure PowerShell Module


1. Download and run the Azure PowerShell installation executable.
• Url: http://go.microsoft.com/fwlink/p/?linkid=320376

1. Install the Azure PowerShell module.

 Task 2: Import your Azure Subscription using a Publish Setting File


1. Open the Windows Azure PowerShell application.

2. Authenticate to Azure by downloading and saving the Publish Settings file using the following
command and details:

Get-AzurePublishSettingsFile

• File name: 20532


• Save as type: PUBLISHSETTINGS file

• Directory: E:\Mod10\Labfiles
3. Authenticate to Azure by importing the saved Publish Settings file:

Import-AzurePublishSettingsFile E:\Mod10\Labfiles\20532.publishsettings

4. View your active account details:

Get-AzureAccount

Note: If you have multiple Azure subscriptions, you can use Select-AzureSubscription to
select the correct subscription to use. If your Azure subscription was provided by a Learning
Partner it may be an auto-generated account without any “details”. In this case, this command
would return an empty result.

Results: After completing this exercise, you will be able to setup a development environment to use
PowerShell for Azure service automation.

Exercise 2: Use PowerShell to Create and Access a Web Site Instance


Scenario
In this exercise you will:

• View a list of Websites using PowerShell

• Create a Website using PowerShell


• Delete a Website using PowerShell

The main tasks for this exercise are as follows:

1. Create a new Web Site Instance using PowerShell


MCT USE ONLY. STUDENT USE PROHIBITED
10-12 Automating Integration with Azure Resources

2. Remove a Web Site Instance using PowerShell

 Task 1: Create a new Web Site Instance using PowerShell


1. Create a new Azure Website using a unique name:

New-AzureWebsite [Unique Name]

2. View the list of Websites for your subscription:

Get-AzureWebsite

3. View the details for your newly created Website:

Get-AzureWebsite –Name [Unique Name]

4. Record the hostname value from your new website’s details.

5. View the newly created Website:

Invoke-Expression “cmd.exe /C start http://[Host Name]”

6. Close the Internet Explorer application.


7. Switch to the Windows Azure PowerShell application.

 Task 2: Remove a Web Site Instance using PowerShell


1. Stop your newly created Website instance:

Stop-AzureWebsite –Name [Unique Name]

2. View the list of Websites for your subscription:

Get-AzureWebsite

3. Remove your newly created Website instance:

Remove-AzureWebsite –Name [Unique Name]

4. View the details for your recently deleted Website:

Get-AzureWebsite –Name [Unique Name]

Results: After completing this exercise, you will be able to use PowerShell to manage instances of an
Azure service.

Exercise 3: Use a Resource Template to Create Multiple Pre-Configured


Resources
Scenario
In this exercise you will:

• Authenticate to Azure in PowerShell using Azure Active Directory.

• Switch the Azure modules in use using PowerShell


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-13

• Create a Resource Group from a template using PowerShell

• Delete a Resource Group using PowerShell

The main tasks for this exercise are as follows:

1. Switch to the Azure Resource Manager PowerShell Modules


2. Import your Azure Subscription using Azure Active Directory

3. Create a Resource Group using PowerShell


4. Remove the Resource Group using PowerShell

 Task 1: Switch to the Azure Resource Manager PowerShell Modules


1. Switch to using the AzureResourceManager mode:

Switch-AzureMode AzureResourceManager

 Task 2: Import your Azure Subscription using Azure Active Directory


1. Authenticate to Azure by logging in to your Azure Active Directory account:

Add-AzureAccount

2. View your active account details:

Get-AzureAccount

Note: If you have multiple Azure subscriptions, you can use Select-AzureSubscription to
select the correct subscription to use.

 Task 3: Create a Resource Group using PowerShell


1. View the description of the Microsoft.WebSiteSQLDatabase resource group template using the
following command:

Get-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSiteSQLDatabase.0.2.0-


preview

2. Create a new instance of the Microsoft.WebSiteSQLDatabase resource group template following


command and details:

New-AzureResourceGroup –Name rga20532a –Location “West Us” -GalleryTemplateIdentity


Microsoft.WebSiteSQLDatabase.0.2.0-preview

• siteName: rs20532a[Your Name Here]

• hostingPlanName: rp20532a[Your Name Here]

• siteLocation: West US
• serverName: rv20532a[Your Name Here]

• serverLocation: West US

• administratorLogin: testuser
• administratorLoginPassword: TestPa$$w0rd
MCT USE ONLY. STUDENT USE PROHIBITED
10-14 Automating Integration with Azure Resources

• databaseName: rd20532a[Your Name Here]

Note: Please wait for the provisioning process to complete. Status messages will be
displayed periodically and a final details message will be shown when provisioning is complete.

3. View the details for your newly created Resource Group:

Get-AzureResourceGroup –ResourceGroupName rga20532a

4. View the details for your newly created Website in your Resource Group:

Get-AzureResource -Name rs20532a[Your Name Here] -ResourceGroupName rga20532a -


ResourceType "Microsoft.Web/sites" -ApiVersion 2014-04-01

5. Record the single value in the hostNames array from your new website’s details.
6. View the newly created Website:

Invoke-Expression “cmd.exe /C start http://[Host Name]”

7. Close the Internet Explorer application.


8. Switch to the Windows Azure PowerShell application.

 Task 4: Remove the Resource Group using PowerShell


1. Remove your newly created Resource Group:

Remove-AzureResourceGroup –Name rga20532a

Note: Since removing a Resource Group involves removing multiple resources, this
process can take anywhere from 10-15 minutes.

Results: After completing this exercise, you will be able to use Azure to interact with the Resource
Manager, resource groups and resource group templates.

Lab Review
Test Your Knowledge
Question

Which Azure cmdLet can be used to verify that a Resource Group has been deleted?

Select the correct answer.

Remove-AzureResourceGroup

Get-AzureResourceStatus
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 10-15

Question

Get-AzureResourceGroup

Delete-AzureResourceGroup

Get-AzureResourceGroupTemplate

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
10-16 Automating Integration with Azure Resources

Module Review and Takeaways


In this module, you were introduced to various methods of automating the management aspects of
Azure. While SDKs, client libraries, xplat CLI and the Service Management API were discussed; a heavy
focus was placed on automation using PowerShell. PowerShell was used to manage services using both
the traditional cmdLets and the Azure Resource Manager.

Best Practice: Moving forward, the Azure Resource Manager is the preferred method of
managing resources in Azure. Resource should be grouped into logical units using resource
groups and templates should be created for resources that may need to be created multiple
times.

Review Question(s)
Question: When automating the creation of a group of Azure service instances, would your
choose to use the standard PowerShell modules or the new Resource Manager modules?
What factors would drive your decision?
Question: How could you create your own Resource Group template?
MCT USE ONLY. STUDENT USE PROHIBITED
11-1

Module 11
Implementing Security in Web Applications using Azure
Contents:
Module Overview 11-1

Lesson 1: Azure Active Directory 11-2

Lesson 2: Azure AD Directories 11-4


Lesson 3: Azure AD Access Control Service 11-6

Lesson 4: Azure AD Multi-Factor Authentication 11-7


Lab: Integrating Azure Active Directory with the Events Administration Portal 11-8
Module Review and Takeaways 11-13

Module Overview
Just like applications on premise, applications in the cloud need streamlined security mechanisms that are
flexible. One of the greatest benefits of Azure Active Directory is that it can be extended with optional
services and even code in your projects. Azure AD Access Control Services even allows you to integrate
third-party identity providers. Lesson 1, “Azure Active Directory”, introduces the Azure Active Directory
service offering. Lesson 2, “Azure AD Directories”, details how to create a directory in Azure AD. Lesson 3,
“Azure AD Access Control Service”, describes the ACS functionality and how it can be used to integrate
your application with third-party identity providers. Lesson 4, “Azure AD Multi-Factor Authentication”,
describes the MFA features in Azure AD.

Objectives
After completing this module, you will be able to:

• Describe the Azure Active Directory service offering.


• Detail the features available for directories in Azure AD.

• Describe the Azure AD Access Control Service.

• Describe the Azure AD Multi-Factor Authentication service.


MCT USE ONLY. STUDENT USE PROHIBITED
11-2 Implementing Security in Web Applications using Azure

Lesson 1
Azure Active Directory
Azure Active Directory provides a suite of services that can be integrated with custom applications, on
premise machines, existing domains and even third party services.

This lesson will describe the Azure Active Directory service and its features and benefits.

Lesson Objectives
After completing this lesson, you will be able to:

• Detail the benefits of Active Directory in Azure.


• List the Active Directory services in Azure.

Azure Active Directory Overview

Benefits of AD in Azure
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-3

Azure AD Services
MCT USE ONLY. STUDENT USE PROHIBITED
11-4 Implementing Security in Web Applications using Azure

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.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe how users and third-party accounts can be added to a directory.


• Describe the integration of SaaS applications and Azure directories.

• Describe the Graph and the Graph API.

Directory Services in Azure AD

Third-Party Account Integration


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-5

Applications in Azure AD

Azure AD Graph
MCT USE ONLY. STUDENT USE PROHIBITED
11-6 Implementing Security in Web Applications using Azure

Lesson 3
Azure AD Access Control Service
Access Control Services provides an identity integration solution that allows you to enable multiple
identity providers and map their claims to common claims that you can use in your application. This cuts
down greatly on the amount of custom code you need to write in your application for each identity
provider.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Azure AD Access Control Service.

• Use the ACS Management Portal.

Access Control Service

ACS Management Portal


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-7

Lesson 4
Azure AD Multi-Factor Authentication
Multi-Factor Authentication is a feature in Azure AD that can be used to provide MFA capabilities to your
existing directory accounts.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe Multi-Factor Authentication in Azure AD.


• List the MFA providers available for Azure AD.

Multi-Factor Authentication

Multi-Factor Authentication Providers


MCT USE ONLY. STUDENT USE PROHIBITED
11-8 Implementing Security in Web Applications using Azure

Lab: Integrating Azure Active Directory with the Events


Administration Portal
Scenario
Even though the Contoso Events web application is public, the Administration application should be
locked down to only user from your domain. You have decided to leverage Azure AD and ASP.NET
Identity to provide this functionality. In this lab, you will create a new ASP.NET project using the ASP.NET
Identity framework and integrate that project with Azure AD. The website will then use your Organization
Accounts for logging in.

Objectives
After you complete this lab, you will be able to:

• Create an Azure AD Directory using the Management Portal.


• Create users in Azure AD using the Management Portal.

• Use the MVC AuthorizeAttribute class to secure a web application.


• Create a new MVC project that uses Azure AD organizational accounts for security.

Estimated Time: 60 minutes

For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:

o User name: testuser


o Password: TestPa$$w0rd
5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create an Azure AD Directory


Scenario
In this exercise you will:
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-9

• Create an Azure AD Directory using the Management Portal

• Create a Global Administrator in the new directory.

• Create a standard User in the new directory.

The main tasks for this exercise are as follows:


1. Login to the Azure Management Portal

2. Create a Directory using the Management Portal


3. Create a Global Administrator in the Directory

4. Create a User in the Directory

 Task 1: Login to the Azure Management Portal

Note: For this lab, we will use the Management Portal since the functionality to create new
Azure Active Directory domains is not available in the Preview Portal.

1. Log into the Azure Management Portal (https://manage.windowsazure.com).

 Task 2: Create a Directory using the Management Portal


1. View the list of Active Directory directories for your subscription.
2. Create a new directory with the following details:

o Name: 20532

o Domain Name: ad20532[Your Name]


3. Country: Select your current location

 Task 3: Create a Global Administrator in the Directory


1. Navigate to your newly created directory’s Users list.

2. Add a new user to your directory with the following details:

o Type of User: New user in your organization


o User Name: admin

o Domain: ad20532[Your Name]

o First Name: Admin


o Last Name: User

o Display Name: Admin User

o Role: Global Administrator


o Alternate E-mail Address: example@contoso.com

Note: Make sure you record the temporary password generated when you create the new
user. In case you forget, you can always reset the user’s password using the Reset Password
button next to the Add User button in the Management Portal.
MCT USE ONLY. STUDENT USE PROHIBITED
11-10 Implementing Security in Web Applications using Azure

 Task 4: Create a User in the Directory


1. Add a new user to your directory with the following details:

o Type of User: New user in your organization

o User Name: standard

o Domain: ad20532[Your Name]

o First Name: Standard

o Last Name: User

o Display Name: Standard User

o Role: User

Note: Make sure you record the temporary password generated when you create the new
user. In case you forget, you can always reset the user’s password using the Reset Password
button next to the Add User button in the Management Portal.

Results: After completing this exercise, you will be able to create an Azure AD Directory and populate
that directory with users.

Exercise 2: Secure an Existing ASP.NET Web Application


Scenario
In this exercise you will:

• Use the MVC AuthorizeAttribute to secure a web application.

The main tasks for this exercise are as follows:


1. Add the Authorize Attribute to the HomeController

2. Debug the Web Application

 Task 1: Add the Authorize Attribute to the HomeController


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod11\Labfiles\Starter\Contoso.Events

2. Open the HomeController.cs file in the Contoso.Events.Management.Old project.


3. Add the Authorize attribute to the HomeController class.

 Task 2: Debug the Web Application


1. Debug the solution and verify that you receive a 401 (Unauthorized) error message.

2. Stop Debugging

Results: After completing this exercise, you will be able to use MVC to require a user to be logged in
before accessing a controller or action.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-11

Exercise 3: Integrate Azure AD with ASP.NET Identity


Scenario
In this exercise you will:

• Create a new ASP.NET MVC application using ASP.NET Identity for authentication and authorization.

• Integrate the new website with Azure AD Organization Accounts.

The main tasks for this exercise are as follows:

1. Repair the IIS 8.0 Express Installation

2. Create a New Management Web Application using Azure AD as the Identity Provider

3. Verify that the Management Web Application Requies Login using a Organizational Account

 Task 1: Repair the IIS 8.0 Express Installation

Note: The original IIS 8.0 Express installation with Visual Studio 2013 Update 3 can be
corrupted when you image your machine and recreate the machine with a new user. IIS Express
depends on configuration files that are located in your user’s Documents folder. When the
machine is imaged, the old user account is lost and a new user account is created when you
create a new VM from the image. Repairing the installation will create the configuration files for
your new user.

1. Open the Run application.

2. In the Run prompt, open the appwiz.cpl shortcut.


3. In Programs and Features, locate IIS 8.0 Express and Repair the installation.

 Task 2: Create a New Management Web Application using Azure AD as the Identity
Provider
1. Create a new Contoso.Events.Management ASP.NET Web Application in the Administration
solution folder with the following details:
o Project Name: Contoso.Events.Management

o Project Location: Allfiles (E):\Mod11\Labfiles\Starter\Contoso.Events

o Template: MVC
o Authentication: Organizational Accounts

o Domain: ad20532[Your Name].onmicrosoft.com

o Account used for authentication: admin@ad20532[Your Name].onmicrosoft.com

Note: When associating your new ASP.NET Web Application with an Azure Active Directory
domain, you must login using an account that is a Global Administrator.

2. Set the Contoso.Events.Management project as the Startup Project.

3. Add two references to the Contoso.Events.Management project for the Contoso.Events.Models


and Contoso.Events.ViewModels projects.
MCT USE ONLY. STUDENT USE PROHIBITED
11-12 Implementing Security in Web Applications using Azure

4. Copy all folders from the Contoso.Events.Management.Old project to the


Contoso.Events.Management project.

Note: Ensure that you copy the folders and not any individual files. Ignore the following
files:
• favicon.ico
• Global.asax
• packages.config
• Web.config

 Task 3: Verify that the Management Web Application Requies Login using a
Organizational Account
1. Debug the solution.

2. Verify that you are required to login before accessing the Contoso.Events.Managent web
application.

Results: After completing this exercise, you will be able to use an Azure AD domain with the ASP.NET
Identity framework.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 11-13

Module Review and Takeaways


In this module, Azure Active Directory is presented as a solution for identity management in many
different scenarios. With the ACS offering, the third-party SaaS integration and Multi-Factor
authentication; Azure AD provides unique services that can be leveraged to improve you existing on
premise identity solution.

Note: The ASP.NET Identity framework is a newer way of securing web applications and has
certain advantages over Membership and Forms Authentication.

Review Question(s)
Question: When using Azure Active Directory Access Control Service, why would you want
to remap the claims from each identity provider?
MCT USE ONLY. STUDENT USE PROHIBITED
11-14 Implementing Security in Web Applications using Azure
MCT USE ONLY. STUDENT USE PROHIBITED
12-1

Module 12
Deploying Web Applications to Azure
Contents:
Module Overview 12-1

Lesson 1: Deployment Strategies for Web Applications 12-2

Lesson 2: Deploying Azure Web Sites 12-4


Lesson 3: Deploying Azure Cloud Services 12-6

Lesson 4: Continuous Integration 12-8


Lesson 5: Monitoring Cloud Applications 12-9
Lab: Deploying the Events Web Application to Azure 12-11

Module Review and Takeaways 12-17

Module Overview
Moving applications from a development environment to either a staging or production environment can
be an arduous task. Technologies have been around such as FPSE, FTP and WebDeploy to help make this
easier. We can take advantage of either existing technologies or new deployment methods to publish our
cloud web applications to Azure. Lesson 1, “Deployment Strategies for Azure Web Applications”, lists
some of the methods that can be used to deploy applications in general. Lesson 2, “Deploying Web
Applications using Cloud Service Packages”, describes the publish process for Azure Cloud Services.
Lesson 3, “Deploying Web Applications using WebDeploy”, describes the publish process for Azure Web
Sites. Lesson 4, “Monitoring Cloud Applications”, details the various tools available to perform forensic
analysis of a web application.

Objectives
After completing this module, you will be able to:
• List the deployment strategies for web applications.

• Describe Cloud Service package deployment for Azure Cloud Services.

• Describe WebDeploy deployment for Azure Web Sites.


• Describe the options for monitoring a web application in Azure.
MCT USE ONLY. STUDENT USE PROHIBITED
12-2 Deploying Web Applications to Azure

Lesson 1
Deployment Strategies for Web Applications
There are many existing methods for deploying web applications that can even be used with applications
in Azure. It is important to understand the differences between each method so that the best one can be
selected for each rollout.

This lesson will list and describe the different methods for deploying web applications.

Lesson Objectives
After completing this lesson, you will be able to:

• Explain the things to consider for each deploy method.

• List the different deployment methods.

On-Premise Deployment Strategies

Considerations when Deploying to the Cloud


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-3

Deployment Methods
MCT USE ONLY. STUDENT USE PROHIBITED
12-4 Deploying Web Applications to Azure

Lesson 2
Deploying Azure Web Sites
ASP.NET Web Applications that are deployed to Azure Web Sites simply use the WebDeploy protocol and
packages. The publish wizard for this method even allows you to customize the behavior of a Database
context that uses Entity Framework Code First Migrations.

This lesson describes the publish process for ASP.NET Web Applications that are being deployed to a
Windows Azure Web Site instance.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the relationship between WebDeploy and IIS.


• Describe the Web.config transformation options for publishing web applications.

• Describe how Entity Framework Code First can be manipulated in the Publish Wizard.

Using WebDeploy with Internet Information Services

Transforming Web.config Settings


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-5

Using Entity Framework Code First with WebDeploy


MCT USE ONLY. STUDENT USE PROHIBITED
12-6 Deploying Web Applications to Azure

Lesson 3
Deploying Azure Cloud Services
Azure Cloud Service projects use a special type of package during the publish process. This package
contains the configuration settings for each role along with instance counts, VM sizes and other Cloud
Service settings.

This lesson describes the publish process for a Cloud Service project.

Lesson Objectives
After completing this lesson, you will be able to:

• Use different configuration settings for the cloud environment and the local environment.

• Describe the publish process for Cloud Services.

• Detail the steps for the Cloud Service Publish Wizard.

Components of a Cloud Service Package

Transforming Cloud Configuration Settings


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-7

Publishing a Cloud Service Project using Visual Studio 2013


MCT USE ONLY. STUDENT USE PROHIBITED
12-8 Deploying Web Applications to Azure

Lesson 4
Continuous Integration
Source Control providers can be used in an integrated manner with Azure Web Sites or Cloud Services.
Using Visual Studio Online, you can gain insights into your application’s behavior and status using
feature-rich dashboards and reports. Visual Studio Online and other source control providers can also be
used to continuously deploy your web applications to Azure Web Site instances.

This lesson introduces the Visual Studio Online service and how it (along with other source control
providers) can be used to continuously deploy the latest build of your web application to an Azure Web
Site.

Lesson Objectives
After completing this lesson, you will be able to:

• Describe the Visual Studio Online service

• Use a source control provider to deploy builds to an Azure Web Site

Visual Studio Online

Web Sites and Continuous Deployment


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-9

Lesson 5
Monitoring Cloud Applications
Once web applications are deployed to the cloud, there are many options available for debugging the
applications and even monitoring the applications’ logs. Even Intellitrace logs can be captured from
errant cloud services.

This lesson describes the different options available for monitoring web applications hosted in Azure.

Lesson Objectives
After completing this lesson, you will be able to:

• Use Service Logs to monitor the behavior of a deployed application

• View Trace Output for a Web Site in Visual Studio

• View the built-in Metrics for a Web Site or Cloud Service


• Use Intellitrace with a Cloud Service

Service Logs

Viewing Trace Output in Azure


MCT USE ONLY. STUDENT USE PROHIBITED
12-10 Deploying Web Applications to Azure

Web Site Metrics

Using Intellitrace with a Cloud Service


MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-11

Lab: Deploying the Events Web Application to Azure


Scenario
Now that you have wrapped up the majority of the development for the Contoso Events web application,
it is time to start planning for the production rollout. Your IT administrations require you to document
the steps to publish applications to Azure. To support this goal, you are deploying the Administration
private web application and Events public web application to your Azure account.

Objectives
After you complete this lab, you will be able to:

• Modify Web.config transformation files.


• Deploy a Cloud Service project to Azure.

• Deploy an ASP.NET Web Application project to Azure Web Sites.


• View Streaming Logs for an Azure Web Site.

Estimated Time: 60 minutes

For this lab, you will use the available host machine. Before you begin this lab, you must complete the
following steps:

• Prior to starting this lab, you must have completed the labs in Modules 2 and 3.

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 dialog
box using this format:
vm20532a[Your Name Here].cloudapp.net:[Your VM RDP Port]

Note: The name and port for your VM may already be saved in the drop-down list when
selecting a Computer. If this is the case, use this value instead of typing it in manually. If you are
unsure about your VM’s RDP port, use either of the Azure portal to look up your VM’s endpoints.
The endpoint with the name Remote Desktop is the correct port for RDP. This port is
randomized to protect your VM from unauthorized access.

3. In Remote Desktop Connection, click Connect. Wait until the RDP client accesses the virtual machine.

4. If necessary, sign in using the following credentials:

o User name: testuser


o Password: TestPa$$w0rd
5. Verify that you received credentials to log into the Azure portal from you training provider, these
credentials and the Azure account will be used throughout the labs of this course.

Exercise 1: Create the Target Azure Services for Deployment


Scenario
In this exercise you will:

• Create an SQL Databases instance.

• Create a Service Bus instance.


MCT USE ONLY. STUDENT USE PROHIBITED
12-12 Deploying Web Applications to Azure

• Create a Storage account.

• Determine the connection strings for your Azure services.

The main tasks for this exercise are as follows:

1. Login to the Azure Preview Portal


2. Create a SQL Database Instance

3. Create a Storage Instance


4. Switch to the Azure Management Portal

5. Create a Service Bus Namespace

 Task 1: Login to the Azure Preview Portal


1. Log into the Azure Preview Portal (https://portal.azure.com).

 Task 2: Create a SQL Database Instance


1. View the list of SQL Databases for your subscription.
2. Create a SQL Database with the following details:

o Name: dp20532a[Your Name Here]


o Edition: Web
o Server Name: sp20532a[Your Name Here]

o Server Admin Login: testuser


o Server Admin Password: TestPa$$w0rd
o Location: Select the region that is closest to your location

3. Access the new SQL Databases instance using the Startboard.


4. Record the ADO.NET connection string for your SQL Database, replacing the text
{your_password_here} with the password TestPa$$w0rd.

 Task 3: Create a Storage Instance


1. View the list of Storage instances for your subscription.

2. Create a Storage instance with the following details:

o Name: sp20532a[Your Name Here]

o Location: Select the region that is closest to your location

o Pricing Tier (Replication): Locally Redundant (L1 LRS)

3. Access the new Storage instance using the Startboard.

4. Record the Name and Primary Access Key for the Storage Account instance.

 Task 4: Switch to the Azure Management Portal


1. Open the Azure Management Portal (https://manage.windowsazure.com).

 Task 5: Create a Service Bus Namespace


1. View the list of Service Bus namespaces for your subscription.

2. Create a Service Bus namespace in your subscription with the following details:
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-13

o Namespace Name: sp20532a[Your Name]

o Region: Select the region that is closest to you

3. Record the ACS connection string for the Service Bus namespace.

Results: After completing this exercise, you will be able to create services that will be used for your
deployed web application.

Exercise 2: Manage Configuration Settings for a Cloud Web Application


Scenario
In this exercise you will:

• Update the Cloud Service configuration settings.


• Update the Web.config Release transformation file.

The main tasks for this exercise are as follows:


1. Modify the Cloud Configuration Settings

2. Modify the Web.config Transformation File for the Administration Project

3. Modify the app.config File for the Worker Role Project


4. Modify the Web.config Transformation File for the Web Role Project

 Task 1: Modify the Cloud Configuration Settings


1. Open the Contoso.Events solution from the following location:

o File location: Allfiles (E):\Mod12\Labfiles\Starter\Contoso.Events


2. Open the Contoso.Events.Worker role’s property page.

3. Go to the Settings section of the property page.

4. Find the Service Bus connection string setting with the name
Microsoft.ServiceBus.ConnectionString and update it for all configurations with the following
values:

o Type: String

o Value: [The ACS Connection String recorded in the previous Task]

5. For the Cloud service configuration, locate the two settings with the names
Microsoft.WindowsAzure.Storage.ConnectionString &
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString and set the connection string
using the Storage Account Name and Primary key recorded from the previous task.

6. Record the connection string used for the Microsoft.WindowsAzure.Storage.ConnectionString


setting.

7. View the Local service configuration settings and ensure that the storage connection strings are using
development storage.
8. Open the Contoso.Events.Web role’s property page.
9. Go to the Settings section of the property page.
MCT USE ONLY. STUDENT USE PROHIBITED
12-14 Deploying Web Applications to Azure

10. For the Cloud service configuration, locate the two settings with the names
Microsoft.WindowsAzure.Storage.ConnectionString &
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString and set the connection string
using the Storage Account Name and Primary key recorded from the previous task.
11. View the Local service configuration settings and ensure that the storage connection strings are using
development storage.

 Task 2: Modify the Web.config Transformation File for the Administration Project
1. Open the Web.Debug.config file in the Contoso.Events.Web project.

2. Update the Microsoft.WindowsAzure.Storage.ConnectionString appSetting’s value to use the


storage connection string recorded from the settings in the previous task.
3. Update the Microsoft.ServiceBus.ConnectionString appSetting’s value to use the ACS Connection
String recorded in the first task.

4. Update the EventsContextConnectionString connectionString entry to use the ADO.NET


Connection String recorded in the first task.

 Task 3: Modify the app.config File for the Worker Role Project
1. Open the app.config file in the Contoso.Events.Worker project.

2. Update the EventsContextConnectionString connectionString entry to use the ADO.NET


Connection String recorded in the first task.

 Task 4: Modify the Web.config Transformation File for the Web Role Project
1. Open the Web.Release.config file in the Contoso.Events.Web project.

2. Update the EventsContextConnectionString connectionString entry to use the ADO.NET


Connection String recorded in the first task.

Results: After completing this exercise, you will be able to make changes to your web applications so that
they will use different settings and connection strings after they are deployed to the cloud.

Exercise 3: Deploy the Web Applications to Azure


Scenario
In this exercise you will:
• Deploy a Cloud Service project to Azure.

• Deploy an ASP.NET Web Application project to an Azure Web Site.

The main tasks for this exercise are as follows:


1. Deploy the Cloud Service Project to a Cloud Service Production Environment

2. Deploy the ASP.NET Web Application Project to a Web Site Instance


3. Verify that the Application was Successfully Published

 Task 1: Deploy the Cloud Service Project to a Cloud Service Production Environment
1. Begin the Publish Windows Azure Application wizard for the Contoso.Events.Cloud project.

2. Create a new Cloud Service instance using the Wizard with the following details:
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-15

o Name: cs20532[Your Name]

o Region or Affinity Group: Select the region that is closest to your location

3. Publish the Cloud Service with the following values:

o Environment: Production
o Build configuration: Release

o Service configuration: Cloud

 Task 2: Deploy the ASP.NET Web Application Project to a Web Site Instance
1. Using the Server Explorer, create a new WebSite with the following details:

o Site name: ws20532[Your Name]

o Region: Select the region closest to your location

o Database server: No database


2. Begin the Publish Web wizard for the Contoso.Events.Management project.

3. Publish the web application to the newly created Website instance with the following details:

o Name: ws20532[Your Name]

 Task 3: Verify that the Application was Successfully Published


1. Verify that all of the events are listed in the Administration web application.

2. Close Internet Explorer.

Results: After completing this exercise, you will be able to deploy projects to both Azure Web Sites and
Cloud Services.

Exercise 4: Monitor the Web Applications in Azure


Scenario
In this exercise you will:

• View the Trace output for an Azure Web Site.

The main tasks for this exercise are as follows:

1. View Streaming Logs for the Administration Application

 Task 1: View Streaming Logs for the Administration Application


1. In the Server Explorer, view the settings for the newly created Website instance with the following
name:

o Website name: ws20532[Your Name]

2. On the Website settings page, change the Application Logging (File System) setting to Verbose
and save the changes.

3. View the streaming logs for the Website.

4. Open the website in Internet Explorer and verify that the log information is shown when navigating to
a page.
MCT USE ONLY. STUDENT USE PROHIBITED
12-16 Deploying Web Applications to Azure

5. Close the Internet Explorer and Contoso.Events – Visual Studio applications

Results: After completing this exercise, you will be able to view a live stream of the Trace logs for an
Azure Web Site.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing Microsoft Azure™ Solutions 12-17

Module Review and Takeaways


In this module, different deployment strategies for web applications were discussed and compared
against the three standards of composability, idempotence and traceability. Specifically the Cloud Service
packages and WebDeploy packages were explored in detail. Finally, monitoring and debugging
techniques for Cloud Services and Web Sites were described.

Best Practice: WebDeploy is a very flexible and modern method of deploying packages to
and from IIS. Even for on premise applications, WebDeploy typically is one of the best choices
for deploying your web applications and configuring IIS.

Review Question(s)
Question: When deploying a web application to the cloud, what are some examples of
settings that should be different locally then in the cloud?
MCT USE ONLY. STUDENT USE PROHIBITED
12-18 Deploying Web Applications to Azure

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.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-1

Module 2: Establishing a Development Environment using


Azure™ Virtual Machines
Lab: Creating an Azure Virtual Machine for
Development & Testing
Exercise 1: Create a Logical Network using Azure
 Task 1: Login to the Azure Preview Portal
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://portal.azure.com
3. Enter your Microsoft Account e-mail

4. Click the Continue button.

5. Enter your Microsoft Account password


6. Click the Sign In button.

7. In the popup window, click the Get Started button.

 Task 2: Create a Virtual Network


1. In the navigation pane on the left side, scroll down and click Browse.
2. In the Browse blade that appears, click Virtual networks.

3. In the Virtual networks blade that appears, view your list of Virtual Network instances.

4. At the bottom left corner of the screen, click New.


5. In the New blade that appears, click the Everything link at the top.

6. In the Gallery blade that appears, click the Virtual machines link.

7. In the Virtual machines blade that appears, scroll down and select Virtual Network.

8. In the Virtual Network blade that appears, click the full Azure portal hyperlink at the bottom.

Note: Creating Virtual Networks is not available in the Preview Portal yet. This hyperlink
will take you to the Management Portal.

9. Switch to the new Windows Azure tab in Internet Explorer.

Note: If this is your first time accessing the Management Portal, you may see a
Management Portal Tour dialog appear. You can either review the information provided in this
tour or dismiss it by using the x button in the top right corner of the dialog.

10. In the navigation pane on the left side, scroll down and click Networks.
11. At the bottom left corner of the screen, click New.
12. If it is not automatically selected, select Network Services => Virtual Network => Quick Create.

13. In the Quick Create form, do the following:


MCT USE ONLY. STUDENT USE PROHIBITED
L2-2 Developing Microsoft Azure™ Solutions

o In the Name dialog box, provide the value Net20532A.

o In the Location list, select the region that is closest to your current location.

o Click Create a Virtual Network.

14. Close the Networks - Windows Azure tab in Internet Explorer.


15. Return to the Microsoft Azure tab in Internet Explorer.

Results: After completing this exercise, you will have a new Virtual Network in Azure.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-3

Exercise 2: Create a Development Virtual Machine using Azure


 Task 1: Create a Storage Account
1. In the navigation pane on the left side, scroll down and click Browse.

2. In the Browse blade that appears, click Storage.


3. In the Storage blade that appears, view your list of Storage instances.

4. At the bottom left corner of the screen, click New.

5. In the New blade that appears, click the Storage link near the bottom.
6. In the Storage account blade that appears, do the following:

7. In the Storage dialog box, provide the value stor20532[Your Name Here].

8. Click the Location link.


9. In the Location blade, select the region closest to your current location.

10. Click the Pricing Tier link.

11. In the Recommended Pricing Tiers blade, select the L1 LRS option for local redundancy.
12. Click the Select button.

13. Click the Create button.

 Task 2: Create a Virtual Machine


1. In the navigation pane on the left side, scroll down and click Browse.
2. In the Browse blade that appears, click Virtual machines.

3. In the Virtual machines blade that appears, view your list of Virtual Machine instances.
4. At the bottom left corner of the screen, click New.
5. In the New blade that appears, click the Windows Server 2012 R2 Datacenter link near the top.

6. In the Create VM blade that appears, do the following:


7. In the Host Name dialog, provide a value with the prefix vm20532a and ending with your name.
8. In the User Name dialog, provide the value testuser.

9. In the Password dialog, provide the value TestPa$$w0rd.

10. Click the Pricing Tier link.


11. In the Recommend Pricing Tiers blade, click the Browse All Pricing Tiers link.

12. Select the A3 Standard option.


13. Click the Select button.

14. In the Recommended Pricing Tiers blade, click the Select button.

15. Click the Optional Configuration link.


16. In the Optional Config blade, click the Network link.

17. In the Network blade, click the Virtual Network link.

18. In the Virtual Network blade, select your previously created network Net20532A.
19. In the Network blade, click the OK button.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-4 Developing Microsoft Azure™ Solutions

20. In the Optional Config blade, click the Storage Account link.

21. In the Storage account blade, select your previously created Storage account stor20532[Your
Name Here].

22. In the Optional Config blade, click the OK button.

23. Click the Create button to create the Virtual Machine using your specified configuration.

Note: The creation of a new Virtual Machine can take anywhere from 5-10 minutes. The
Startboard (home screen) will notify you when your VM is created and running.

24. Select the newly created Virtual Machine from your Startboard.

25. In the vm20532a[Your Name Here] blade, scroll down to the Disks tile.

26. Click the Disks tile.


27. In the Disks blade, click the Attach New button at the top of the blade.

28. In the Attach a new disk blade, do the following:

29. Click the Storage Container link.


30. In the Choose a container blade, click the Choose Storage Account link.

31. In the Storage account blade, select your previously created Storage account stor20532[Your
Name Here]

32. In the Choose a container blade, click the Choose Container link.

33. In the Storage container blade, select the vhds container.


34. In the Choose a container blade, click the OK button.
35. In the Disk File Name dialog box, provide the value vm20532a-AllFiles.vhd.

36. In the Size (GB) dialog box, provide the value 6.

37. Click the OK button to create the second disk.

Note: Wait about 5 minutes for the empty disk to be attached to the virtual machine.

38. Return to the vm20532a[Your Name Here] blade.


39. Click Connect at the top of the screen.

40. In the Internet Explorer download dialog, click Open.

41. In the Remote Desktop Connection – Unknown Publisher dialog, do the following:
42. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.

43. Click Connect.


44. In the Windows Security dialog, do the following:

45. For the User name dialog box, provide the value testuser.

46. For the Password dialog box, provide the value TestPa$$w0rd.
47. Click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-5

48. In the Remote Desktop Connection – Untrusted Certificate dialog, do the following:

49. Verify the Remote certificate name matches the name of your Virtual Machine.

50. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.

51. Click Yes.

52. When you are prompted to allow your network connection to discover external devices, click No.

Results: After completing this exercise, you will have a new Virtual Machine stored in a new Storage
account.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-6 Developing Microsoft Azure™ Solutions

Exercise 3: Configure the Virtual Machine for Development


 Task 1: Create an AllFiles drive
1. On the Windows Start screen, click the Server Manager tile.

2. In the navigation pane on the left side, click Local Server.


3. In the Properties box, click the IE Enhanced Security Configuration option currently set to On.

4. In the Internet Explorer Enhanced Security Configuration dialog box, do the following:

5. For Administrators, select Off.


6. For Users, select Off.

7. Click OK.

8. Use the Windows Key + W shortcut key combination to open Universal Search – Settings.
9. In the Search dialog box, provide the value disk.

10. Click the Create and format hard disk partitions option.

11. In the Initialize Disk dialog box, do the following:


12. Verify that Disk 2 is selected for initialization.

13. Verify that MBR (Master Boot Record) is the selected partition style.
14. Click OK.
15. In the bottom half of the Disk Management window, do the following:

16. Scroll down and find Disk 2 that was previously initialized.

17. Right-click the Unallocated partition and select New Simple Volume….
18. In the New Simple Volume Wizard, do the following:

19. Click Next.


20. Verify the Simple volume size in MB is 6141.

21. Click Next.

22. In the Assign the following drive letter list, select the value F.
23. Click Next.
24. Verify that the File System setting is set to NTFS.

25. In the Volume Label dialog box, provide the value AllFiles.

26. Click Next.


27. Click Finish to close the dialog and create the partition.

Note: If a dialog box shows up stating that “You need to format the disk in drive F: before you can
use it.”, you can safely close this dialog since you already formatted the disk.
28. On the Windows Start screen, click the Internet Explorer tile.

29. If prompted to setup Internet Explorer 11, do the following:

30. Select the Use recommended security and compatibility settings option.
31. Click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-7

32. Browse to http://www.microsoft.com/learning/companionmoc.


33. Scroll down the screen until you find the '%*('69ZkZade^c\B^Xgdhd[i6ojgZHdaji^dch
course.

34. Click the 20532A-ENU-AllFiles.exe link to download the AllFiles executable.


35. In the Internet Explorer download dialog, click Run.

36. “The download of the AllFiles executable typically takes around 5 minutes.”

37. On the Official Microsoft Learning Product License Terms dialog box, click Accept.
38. On the WinRAR self-extracting archive dialog box, do the following:

39. In the Destination folder dialog, provide the value F:\.

40. Click Extract.


41. Wait for the extraction process to complete.

 Task 2: Install Visual Studio 2013 Ultimate Update 3


1. On the Windows Start screen, click Internet Explorer.
2. In the Address bar, type in the following url:

o http://go.microsoft.com/fwlink/?LinkID=510170

3. Press the Enter key.


4. Click the Download button.

5. Select only the vs_ultimate.exe option.

6. Click Next.
Note: You will notice that Internet Explorer blocks the download popup. You will need to
view the yellow warning message at the bottom of the Internet Explorer window, click Options for
this Site and then click Always Allow. This will allow you to view popups and downloads without
any restriction.
7. At the bottom of the Internet Explorer window, click the Run button in the download dialog.

8. In the initial Visual Studio dialog, click the I agree to the License Terms and Privacy Policy
checkbox.

9. Click Next.

10. In the Optional features to install list, click the Windows Phone 8.0 SDK checkbox.
11. Click Install.

Note: The download of required assets for Visual Studio 2013 typically takes around 10-15
minutes. The installation of said assets will take another 10 minutes.
12. Click Restart Now.

Note: The Remote Desktop connection will now close and the Virtual Machine will restart. Give
the Virtual Machine about 5 minutes before trying to connect to it again using Remote Desktop.

13. Go back to the Internet Explorer window.

14. Switch to the Microsoft Azure – Virtual Machines tab in Internet Explorer.

Note: You may need to log into the portal again if the browser has timed out and logged off
your portal user.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-8 Developing Microsoft Azure™ Solutions

15. Click Connect at the top of the screen.

16. In the Internet Explorer download dialog, click Open.

17. In the Windows Security dialog, do the following:

18. For the User name dialog box, provide the value testuser.
19. For the Password dialog box, provide the value TestPa$$w0rd.

20. Click OK.


21. Wait for the Visual Studio 2013 Ultimate installation to finalize.

22. In the Visual Studio Ultimate 2013 dialog box, click Launch.

23. In the Visual Studio Sign In dialog box, click Not now, maybe later.
24. In the Visual Studio Settings dialog box, do the following:

25. In the Development Settings list, select the Visual C# value.

26. Click Start Visual Studio.


27. Wait for the Visual Studio configuration to complete

28. Close the Visual Studio 2013 Ultimate window by clicking the x button in the top right-hand corner
of the window.

 Task 3: Install Azure SDK for .NET 2.4


1. On the Windows Start screen, click Internet Explorer.
2. In the Address bar, type in the following url:

a. http://go.microsoft.com/fwlink/?LinkID=510171
3. Press Enter.
4. Expand the Details section by clicking the plus button immediately to the left of the Details header.

5. Scroll down and click the VS 2013 hyperlink.


6. At the bottom of the Internet Explorer window, click the Run button in the download dialog.

Note: You may have to wait a minute or two while the Web Platform Installer 5.0
software is installed that will retrieve the Azure SDK for .NET 2.4.

7. Verify that the package is named Windows Azure SDK for .NET (VS 2013) – 2.4.

8. Click Install.

9. Click I Accept.

10. “The download and installation of the SDK takes about 5 minutes.”
11. Wait for the Web Platform Installer process to complete.

12. Click Continue to view the .NET Dev Center | Azure.


13. Close Internet Explorer.

14. In the Web Platform Installer 5.0 window, click Finish.

15. Click Exit


MCT USE ONLY. STUDENT USE PROHIBITED
L2-9

16. On the Start screen, click the down arrow to see all applications and then right-click the Visual
Studio 2013 tile.

17. Click the Pin to Start button at the bottom of the screen.
18. Click the Visual Studio 2013 tile.

19. On the View menu, click Server Explorer.

20. Locate the Azure node and click the arrow immediately to the left.

21. Right-click the Azure node and click “Connect to Microsoft Azure”.

22. If necessary, login to your Azure subscription using your Microsoft account credentials.

Results: After completing this exercise, your development Virtual Machine will have Visual Studio and the
Azure SDK installed.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-10 Developing Microsoft Azure™ Solutions

Exercise 4: Create an Image from the Virtual Machine


 Task 1: Use the System Preperation Tool with the Azure Virtual Machine
1. Use the Windows Key + S shortcut key combination to open Universal Search – Everywhere.

2. In the Search dialog box, provide the value command.


3. Right-click the Command Prompt option.

4. Click Run as administrator.

5. In the Command Prompt window, type in the following command:

cd %windir%\system32\sysprep

6. Hit the Enter key.

7. Type in the following command:

sysprep.exe

8. Hit the Enter key.


9. In the System Cleanup Action list, select the Enter System Out-of-Box Experience option.

10. Ensure that the Generalize checkbox is selected.


11. In the Shutdown Options list, select the Shutdown option.
12. Click the OK button.

Note: You will be disconnected from the Virtual Machine once SysPrep is completed. The VM
will shutdown and this will close your RDP connection.

 Task 2: Capture a Virtual Machine Image


1. On the Start screen, click the Internet Explorer tile

2. Browse to https://manage.windowsazure.com
3. Enter your Microsoft Account e-mail

4. Click the Continue button

5. Enter your Microsoft Account password


6. Click the Sign In button.

7. In the navigation pane on the left side, scroll down and click Virtual Machines.

8. Click the Virtual Machine Instances tab at the top of the screen.
9. Select the newly created Virtual Machine in the list of Virtual Machine Instances.

10. Click the Capture button at the bottom of the screen.

11. In the Capture the virtual machine dialog box, do the following:
12. In the Image Name dialog, provide the value vm20532Template.

13. In the Image Description dialog, provide the value Template for 20532 VM.

14. Select the I have run Sysprep on the virtual machine checkbox.

15. Click the checkmark button.


MCT USE ONLY. STUDENT USE PROHIBITED
L2-11

Results: After completing this exercise, you will have a custom image in Azure that can be used to create
new Virtual Machines.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-12 Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
L3-1

Module 3: Managing Infrastructure in Azure™


Lab: Managing Multiple Virtual Machines in
a Virtual Network
Exercise 1: Create the Database Virtual Machine
 Task 1: Login to the Azure Preview Portal
1. On your host machine, open the Internet Explorer application.

2. Browse to https://portal.azure.com.

3. Enter your Microsoft Account e-mail.

4. Click the Continue button.

5. Enter your Microsoft Account password.

6. Click the Sign In button.


7. In the popup window, click the Get Started button.

 Task 2: Create the SQL Server 2014 Standard Virtual Machine


1. At the bottom left corner of the screen, click New.

2. In the New blade that appears, click the SQL Server 2014 Standard link near the top.
3. In the Create VM blade that appears, do the following:

4. In the Host Name dialog, provide a value with the prefix db20532a and ending with your name.

5. In the User Name dialog, provide the value testuser.


6. In the Password dialog, provide the value TestPa$$w0rd.

7. Click the Pricing Tier link.

8. In the Recommend Pricing Tiers blade, click the Browse All Pricing Tiers link.
9. Select the A2 Standard option.

10. Click the Select button.

11. In the Recommended Pricing Tiers blade, click the Select button.
12. Click the Optional Configuration link.

13. In the Optional Config blade, click the Network link.

14. In the Network blade, click the Virtual Network link.

15. In the Virtual Network blade, select your previously created network Net20532A.
16. In the Network blade, click the OK button.

17. In the Optional Config blade, click the Storage Account link.

18. In the Storage account blade, select your previously created Storage account stor20532[Your
Name Here].

19. In the Optional Config blade, click the OK button.

20. Click the Create button to create the Virtual Machine using your specified configuration.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-2 Developing Microsoft Azure™ Solutions

21. Select the newly created Virtual Machine from your Startboard.

22. Return to the db20532a[Your Name Here] blade.

23. Click Connect at the top of the db20532[Your Name Here] blade.

24. In the Internet Explorer download dialog, click Open.


25. In the Remote Desktop Connection – Unverified Publisher dialog, do the following:

26. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.
27. Click Connect.

28. In the Windows Security dialog, do the following:


29. For the User name dialog box, provide the value testuser.

30. For the Password dialog box, provide the value TestPa$$w0rd.

31. Click OK.


32. In the Remote Desktop Connection – Untrusted Certificate dialog, do the following:

33. Verify the Remote certificate name matches the name of your Virtual Machine.

34. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.

35. Click Yes.

36. When you are prompted to allow your network connection to discover external devices, click No.

 Task 3: Add a Rule to the Windows Firewall for SQL Server


1. On the Windows Start Screen, click the down arrow in the bottom left corner.
2. Find and click the Run application.

3. In the Run dialog box, do the following:


4. In the Open dialog, provide the value WF.msc.
5. Click the OK button to open the Windows Firewall application.

6. In the Windows Firewall with Advanced Security window, do the following:

7. Right-click the Inbound Rules link and click New Rule….


8. Select the Port radio button.

9. Click the Next button.

10. Select the TCP radio button.


11. Select the Specific local ports: radio button.

12. In the Specific local ports: dialog, provide the value 1433.
13. Click the Next button.

14. Select the Allow the connection radio button.

15. Click the Next button.


16. Ensure that the Domain, Private and Public checkboxes are all selected.

17. Click the Next button.


MCT USE ONLY. STUDENT USE PROHIBITED
L3-3

18. In the Name dialog, provide the value SQL Inbound.

19. Click the Finish button.

20. Close the Windows Firewall with Advanced Security window.

 Task 4: Enable Mixed Mode Authentication for SQL Server


1. On the Windows Start Screen, click the down arrow in the bottom left corner.

2. Find and click the SQL Server 2014 Management Studio application.

3. In the Connect to Server dialog box, do the following:

4. In the Server name dialog, provide the value . (period).

5. Click the Connect button.

6. Right-click the SQL Server node at the top of the Object Explorer pane and click Properties.

7. In the Server Properties dialog box, do the following:


8. Select the Security page.

9. In the Server authentication section, select the SQL Server and Windows Authentication mode.

10. Click the OK button.

11. In the Microsoft SQL Server Management Studio dialog, click OK.

12. Right-click the SQL Server node at the top of the Object Explorer pane and click Restart.

13. In the Microsoft SQL Server Management Studio dialog, click Yes.
14. Right-click the Security node in the Object Explorer pane, hover over New, and then click Login….

15. In the Login – New dialog box, do the following:


16. In the Login name: dialog, provide the value dbuser.

17. Select the SQL Server authentication radio button.

18. In the Password dialog, provide the value TestPa$$w0rd.


19. In the Confirm Password dialog, provide the value TestPa$$w0rd.
20. Ensure the Enforce password policy checkbox is unselected.

21. Ensure the Enforce password expiration checkbox is unselected.

22. Ensure the User must change password at next login checkbox is unselected.
23. Click the Server Roles page.

24. Ensure the public Server role checkbox is selected.


25. Ensure the sysadmin Server role checkbox is selected.

26. Click the OK button to create the new login.

27. Right-click the Databases node in the Object Explorer pane and click New Database….
28. In the New Database dialog box, do the following:

29. In the Database name dialog, provide the value Contoso.Test.

30. Click the OK button to create the new database.

31. Close the Microsoft SQL Server Management Studio window.


MCT USE ONLY. STUDENT USE PROHIBITED
L3-4 Developing Microsoft Azure™ Solutions

32. Close the Remote Desktop application.

Results: After completing this exercise, your will have a new Virtual Machine with SQL installed that can
use Mixed Mode authentication when accessed by an external Virtual Machine.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-5

Exercise 2: Create the Application Virtual Machines


 Task 1: Switch to the Azure Management Portal
33. On your host machine, switch to the Internet Explorer application.

34. Locate the Microsoft Azure tab.


35. On the Startboard (home screen), click the Azure Portal tile.

36. Switch to the Windows Azure tab.

 Task 2: Create the Application Virtual Machine from an Existing Image


1. At the bottom left corner of the screen, click New.

2. If it is not automatically selected, select Compute => Virtual Machine => From Gallery.

3. In the Create a Virtual Machine dialog box, do the following:

1. On the left, select the My Images option.


2. Select the vm20532Template image.

3. Click the right arrow to move to the second step.

4. In the Virtual Machine Name dialog box, provide a value with the prefix vm20532a and ending
with your name.

5. In the Tier slider, select Standard.


6. In the Size list, select the A2 (2 cores, 3.5 GB memory) option.

7. In the New User Name dialog box, provide the value testuser.

8. In the New Password dialog box, provide the value TestPa$$w0rd.

9. In the Confirm dialog box, provide the value TestPa$$w0rd.

10. Click the right arrow to move to the third step.

11. In the Region/Affinity Group/Virtual Network list, select your previously created virtual network
Net20532A.

12. Click the right arrow to move to the fourth step.

13. Click the checkmark button to create the Virtual Machine using your specified configuration.

Results: After completing this exercise, you will have a new Virtual Machine created from your
development image.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-6 Developing Microsoft Azure™ Solutions

Exercise 3: Connect the Test Application to the SQL Server Virtual Machine
 Task 1: Login to the Azure Preview Portal
1. On your host machine, switch to the Internet Explorer application.

2. Close the Virtual machines - Windows Azure tab.


3. Locate and switch to the Microsoft Azure tab.

 Task 2: Retrieve your SQL Server Virtual Machine’s Internal IP Address


1. In the navigation pane on the left side, click Browse.

2. In the Browse blade that appears, click Virtual machines.


3. In the Virtual machines blade that appears, select the row for your virtual machine named
db20532a[Your Name Here].

4. In the db20532a[Your Name Here] blade that appears, click the Properties tile.
5. In the Properties blade that appears, record the value of the Internal IP Address field.

6. Close the Properties blade by click the X button at the top right corner of the blade.

 Task 3: Connect to the Application Virtual Machine


1. In the navigation pane on the left side, click Browse.
2. In the Browse blade that appears, click Virtual machines.

3. In the Virtual machines blade that appears, select the row for your virtual machine named
vm20532a[Your Name Here].
4. In the vm20532a[Your Name Here] blade that appears, click the Connect button at the top.

5. Click Connect at the top of the vm20532[Your Name Here] blade.

6. In the Internet Explorer download dialog, click Open.


7. In the Remote Desktop Connection – Unverified Publisher dialog, do the following:

8. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.

9. Click Connect.

10. In the Windows Security dialog, do the following:

11. For the User name dialog box, provide the value testuser.

12. For the Password dialog box, provide the value TestPa$$w0rd.

13. Click OK.

14. In the Remote Desktop Connection – Untrusted Certificate dialog, do the following:

15. Verify the Remote certificate name matches the name of your Virtual Machine.

16. Click Don’t ask me again for connections to this computer to prevent this dialog from showing up
again.
17. Click Yes.

18. When you are prompted to allow your network connection to discover external devices, click No.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-7

 Task 4: Repair the Azure SDK for .NET Storage Emulator Installation

Note: When using SysPrep with your original application VM, the user that installed the
Storage Emulator is removed. When you create a new VM from the template, you create a new
user and this user does not have access to some of the files and applications that the old user
could access. Because of this, you must repair the Storage Emulator Installation.

1. On the Windows Start screen, click Internet Explorer.

2. In the Address bar, type in the following url:

o http://www.microsoft.com/en-us/download/details.aspx?id=43709

3. Press Enter.

4. Click the Download button.

5. Select only the WindowsAzureStorageEmulator.msi option.

6. Click Next.
Note: You will notice that Internet Explorer blocks the download popup. You will need to
view the yellow warning message at the bottom of the Internet Explorer window, click Options for
this Site and then click Always Allow. This will allow you to view popups and downloads without
any restriction.

7. At the bottom of the Internet Explorer window, click the Run button in the download dialog.

8. In the Windows Azure Storage Emulator – v3.3 Setup installation wizard, do the following:
o Click Next.

o Click the Repair option.


o Click Repair.

o Wait for the repair process to complete.

9. Click Finish to close the installation wizard.

 Task 5: Debug the Contoso.Events Database Test Web Application


1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.

3. In the Libraries window, navigate to Allfiles (E):\Mod03\Labfiles\Starter\Contoso.Events, and


then double-click Contoso.Events.sln.

Note: Since this is your first time starting Visual Studio with this sysprep image, you will have to
walk through the setup steps (from Module 2) for Visual Studio again. Visual Studio detects that you are a
“new user” using the product for the first time.
4. In the Visual Studio Sign In dialog box, click Not now, maybe later.

5. In the Visual Studio Settings dialog box, do the following:

6. In the Development Settings list, select the Visual C# value.

7. Click Start Visual Studio.

8. Wait for the Visual Studio configuration to complete.


MCT USE ONLY. STUDENT USE PROHIBITED
L3-8 Developing Microsoft Azure™ Solutions

9. In the Solution Explorer pane, right-click the Contoso.Events.Web project and then click Set as Startup
Project.

10. On the DEBUG menu, click Start Debugging.

Note: This web application references multiple NuGet packages. When you debug the
solution, Visual Studio will start by building the solution. The act of building the solution triggers
the NuGet automatic package restore capability.

NuGet Automatic Package Restore

http://go.microsoft.com/fwlink/?LinkID=510175

11. On the home page of the web application, enter the previously recorded Internal IP Address for the
SQL Server VM in the IP Address dialog.
12. Click the Verify button.

13. Verify that the Events page shows a list of events.

14. Close the Internet Explorer application.

Results: After completing this exercise, you will have used the Internal IP address of the Database Virtual
Machine in your Virtual Network to connect to SQL Server 2014.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-9

Exercise 4: Modify the Application Virtual Machine into a Web Server


 Task 1: Install the Web Server Role and ASP.NET Hosting Functionality
1. On the Windows Start Screen, find and click the Server Manager application.

2. At the top of the Server Manager window, click the Manage link.
3. Click the Add Roles and Features menu item.

4. In the Add Roles and Features Wizard dialog, do the following:

5. Click the Next button to move to the Installation Type page.


6. Ensure that the Role-based or feature-based installation radio button is selected.

7. Click the Next button to move to the Server Selection page.

8. Your vm20532a[Your Name Here] server is already selected, leave all options to their default values.
9. Click the Next button to move to the Server Roles page.

10. In the Roles list, click the Web Server (IIS) checkbox to select the Role.

11. Click the Add Features button in the Add Roles and Features Wizard dialog that appears.
12. Click the Next button to move to the Features page.

13. Click the Next button to move to the Web Server Role (IIS) page.
14. Click the Next button to move to the Role Services page.
15. In the Role services list, expand the Application Development option by clicking the arrow on the
left.

16. Click the ASP.NET 4.5 checkbox to select the Role Service.

17. Click the Add Features button in the Add Roles and Features Wizard dialog that appears.

18. Click the Next button to move to the Confirmation page.

19. Click the Install button


20. Wait for the installation of the new Role and Role Service to complete.

21. When the installation is complete, close the Add Roles and Features Wizard dialog.
22. Close the Server Manager application.

 Task 2: Publish the Web Application to the Local IIS Instance


1. Switch to the running Contoso.Events - Microsoft Visual Studio window.

2. In the Solution Explorer pane, right-click the Contoso.Events.Web project and then click Publish….

3. In the Publish Web dialog, do the following:


4. In the Select a publish target list, select the Custom option.

5. In the New Custom Profile dialog, enter the value localhost.

6. Click the OK button to close the New Custom Profile dialog.


7. In the Server dialog box, provide the value localhost.

8. In the Site name dialog box, provide the value Default Web Site

9. In the Destination URL dialog box, provide the value http://localhost/.


MCT USE ONLY. STUDENT USE PROHIBITED
L3-10 Developing Microsoft Azure™ Solutions

10. Click the Publish button.

11. On the home page of the web application, enter the previously recorded Internal IP Address for the
SQL Server VM in the IP Address dialog.

12. Click the Verify button.

13. Verify that the Events page shows a list of events.

14. Close the Contoso.Events – Visual Studio application.

15. Close the Remote Desktop application.

 Task 3: Login to the Azure Preview Portal


1. On your host machine, switch to the Internet Explorer application.

2. Locate and switch to the Microsoft Azure tab.

 Task 4: Create a HTTP Port 80 Endpoint for the Virtual Machine


3. In the navigation pane on the left side, click Browse.
4. In the Browse blade that appears, click Virtual machines.

5. In the Virtual machines blade that appears, select the row for your virtual machine named
vm20532a[Your Name Here].
6. In the vm20532a[Your Name Here] blade that appears, scroll down and click the Endpoints tile.

7. In the Endpoints blade that appears, click the Add button.

8. In the Add an endpoint blade that appears, do the following:


9. In the Endpoint dialog box, provide the value HTTP.

10. In the Protocol list, select the value TCP.

11. In the Public Port dialog box, provide the value 80.
12. In the Private Port dialog box, provide the value 80.

13. In the Floating IP selector, select the Disabled value.


14. Click the OK button to add the endpoint.
15. Wait until the new Endpoint appears in the Endpoints blade.

 Task 5: Connect to the Publically Hosted Web Application


1. Close the Endpoints blade by click the X button at the top right corner of the blade.

2. Locate the vm20532a[Your Name Here] blade.


3. Click the Properties tile.

4. Copy the Domain Name value for your Virtual Machine instance.

5. Open a new tab in Internet Explorer.


6. Paste the copied value in the Internet Explorer Address Bar and press Enter.

7. On the home page of the web application, enter the previously recorded Internal IP Address for the
SQL Server VM in the IP Address dialog.
8. Click the Verify button.

9. Verify that the Events page shows a list of events.


MCT USE ONLY. STUDENT USE PROHIBITED
L3-11

10. Close the Internet Explorer application.

Results: After completing this exercise, you will have enabled IIS and the ASP.NET features on your
Windows Server 2012 R2 Virtual Machine and created a custom HTTP Endpoint for port 80 to view your
web server from any public browser.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-12 Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
L4-1

Module 4: Web Infrastructure in the Azure™ Platform


Lab: Creating an ASP.NET Web Site Using
Azure Web Sites
Exercise 1: Create an Azure Web Site
 Task 1: Create a Web Site Instance Using the Management Portal
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://manage.windowsazure.com.

3. Enter your Microsoft Account e-mail and password and then click Sign In.

4. In the navigation pane on the left side, click Web Sites.


5. Click the Create a Web Site link.

Note: You can also click the + New button at the bottom of the screen in the left corner.

6. Click Custom Create.

7. In the form that appears, do the following:


8. In the Web Hosting Plan list, select Create New Web Hosting Plan.

9. In the Region list, select the region that is closest to your location.

10. In the Url dialog box, create a unique name for your website.
11. In the Database list, select Create a free 20 MB SQL database.

12. In the DB Connection String Name dialog box, provide the connection string:
EventsContextConnectionString.

13. Click the next arrow button.

14. In the Name dialog box, provide the database name: EventsContextDB.
15. In the Server dialog box, select New SQL database server.

16. In the Server Login Name dialog box, create a username for your administrative SQL user.

17. In the Server Login Password dialog boxes, create a password for your administrative SQL user.
18. Click the checkmark button to create your Web Site and SQL database.

 Task 2: Browse to the Newly Created Web Site's Placeholder Page

Note: While creating an Azure Website is typically very fast, you have to wait for the Web
Site to be created and running before browsing to the site. This is indicated by the WebSite
having a status of “Running” when viewing it in the Web Sites list.

1. In the navigation page on the left side, click Web Sites.

2. In the Web Sites list, click the web site that you just created.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-2 Developing Microsoft Azure™ Solutions

3. Click the Dashboard tab at the top of the screen.

4. Locate the Quick Glance section on the right side of the dashboard

5. Under the Site Url header, click the hyperlink to the website.

6. Verify that the website exists.


7. Close the tab displaying the website.

Results: After completing this exercise, you will be able to use the Management Portal to create Azure
Web Site instances and browse to the instance.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-3

Exercise 2: Deploy an ASP.NET Web Application to an Azure Web Site


 Task 1: Open an Existing ASP.NET Web Application Project with Visual Studio 2013
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod04\Labfiles\Starter\Contoso.Events, and
then double-click Contoso.Events.sln.

4. In the Solution Explorer pane, right-click the Contoso.Events.Management project and then click
Set as Startup Project.

5. On the DEBUG menu, click Start Debugging.

Note: If this is the first time Building this solution, NuGet will implicitly restore any missing
packages. This does not require any interaction on your part.

6. On the home page of the web application, verify that it shows a list of three events under the Latest
3 Events header.
7. Click the Events link in the navigation bar at the top of the web page.

8. Verify that the Events page shows a list of events.


9. Close the tab displaying the website.

 Task 2: Download the Publish Profile for the Azure Web Site
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://manage.windowsazure.com.
3. Enter your Microsoft Account e-mail and password and then click Sign In.
4. In the Web Sites list, click the website that you just created.

5. Click the Dashboard tab at the top of the screen.


6. Locate the Quick Glance section on the right side of the dashboard
7. Click the Download the publish profile link.

8. In the download dialog, click the arrow immediately to the right of the Save button and click Save
As.

9. In the Save As window, navigate to Allfiles (E):\Mod04\Labfiles, and then click Save.

 Task 3: Publish the ASP.NET Web Application to the Azure Web Site
1. In the Solution Explorer pane of the Contoso.Events - Microsoft Visual Studio window, right-click
Contoso.Events.Management and then click Publish….

2. In the Publish Web window, click Import.

3. View the Import from a publish profile file dialog box.

4. Click Browse….
5. In the Libraries window, navigate to Allfiles (E):\Mod04\Labfiles, and then double-click your
previously saved publish profile.

6. Click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-4 Developing Microsoft Azure™ Solutions

7. Verify that the Site Name dialog box matches your Azure Web Site’s name.

8. Click Publish.

 Task 4: Verify the Web Application has been Successfully Published

Note: If you see the placeholder page that was shown in Exercise 1 - Task 2, make sure to
refresh your browser as there may be client side caching occurring. You can always force refresh
your browser and cache by using the Ctrl+F5 key combination.

1. On the home page of the web application, verify that it shows a list of three events under the Latest
3 Events header.

2. Click the Events link in the navigation bar at the top of the web page.

3. Verify that the Events page shows a list of events.

4. Close the tab displaying the website.

Results: After completing this exercise, you will be able to use a publish profile to publish web
applications directly an Azure Web Site.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-5

Exercise 3: Configure an Azure Web Site


 Task 1: Implement Logic to Read a Configuration Setting from App Settings
1. In the Solution Explorer pane of the Contoso.Events - Microsoft Visual Studio window, expand the
Contoso.Events.ViewModels project.

2. In the Solution Explorer pane, double-click EventsListViewModel.cs.

3. Locate the following code at Line 20 of EventsListViewModel.cs:

this.EventCount = 3;

4. Replace the line of code with:

this.EventCount =
Int32.Parse(ConfigurationManager.AppSettings["EventsListViewModel.EventCount"]);

5. In the Solution Explorer pane of the Contoso.Events - Microsoft Visual Studio window, expand the
Contoso.Events.Management project.
6. In the Solution Explorer pane, double-click Web.config.

7. In the appSettings element, at Line 14, add this line of code:

<add key="EventsListViewModel.EventCount" value="5" />

8. On the DEBUG menu, click Start Debugging.


9. On the home page of the web application, verify that it shows a list of five events under the Latest 5
Events header.

10. Close the tab displaying the website.

 Task 2: Publish Web Application to the Azure Web Site


1. In the Solution Explorer pane of the Contoso.Events - Microsoft Visual Studio window, right-click
Contoso.Events.Management and then click Publish….
2. Click the Publish button.
3. On the home page of the web application, verify that it shows a list of five events under the Latest 5
Events header.

4. Close the tab displaying the website.

 Task 3: Modify the App Settings in the Management Portal


1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://manage.windowsazure.com.
3. Enter your Microsoft Account e-mail and password and then click Sign In.
4. In the Web Sites list, click the website that you just created.

5. Click the Configure tab at the top of the screen.

6. Scroll down to the App Settings section.


7. In the Key dialog box, provide the value EventsListViewModel.EventCount.

8. In the Value dialog box, provide the value 2.


9. At the bottom of the screen, click the Save button.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-6 Developing Microsoft Azure™ Solutions

Note: Typically there is a very short wait after updating configuration settings before you
are able to view the web site and see the configuration changes. You will know that the
configuration changes are applied when the Configure tab is editable again.

 Task 4: Verify the App Settings have been Successfully Updated


1. Click the Dashboard tab at the top of the screen.

2. Locate the Quick Glance section on the right side of the dashboard
3. Under the Site Url header, click the hyperlink to the website.

4. On the home page of the web application, verify that it shows a list of two events under the Latest 2
Events header.

5. Close the tab displaying the website.

Results: After completing this exercise, you will be able to leverage custom appSettings using a
web.config or the Azure Management Portal.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-1

Module 6: Processing Background Logic using Azure


Lab: Creating a Background Process Using
Azure Worker Roles
Exercise 1: Create a C# Class Library
 Task 1: Create a C# Class Library project
1. On the Start screen, right-click the Visual Studio 2013 tile.

2. In the AppBar, click Run as Administrator.

Note: If the UAC prompt appears, you can elevate permissions so that you can run Visual
Studio 2013 as an Administrator.

3. On the Visual Studio Start Screen, click Open Project.

4. In the Open Project dialog box, navigate to Allfiles (E):\Mod06\Labfiles\Starter\Contoso.Events


and then click Contoso.Events.sln.
5. Click Open to close the dialog.

6. Expand the Solution Explorer pane to view the projects in the solution.

7. In the Solution Explorer pane, right-click the Contoso.Events solution node.


8. Hover over the Add menu item.

9. Click New Project….

10. In the Add New Project dialog box, do the following:


11. Expand Installed, Visual C#, and then click Windows Desktop.

12. Click the Class Library template.


13. In the Name box, specify a value Contoso.Events.Worker.
14. Click OK

 Task 2: Add a Reference to the Azure SDK Libraries and Solution Projects
1. Right-click the Contoso.Events.Worker project.
2. Hover over the Add menu item.

3. Click Reference….

4. In the Reference Manager – Contoso.Events.Worker dialog box, do the following:


5. Expand Assemblies and then click Extensions.

6. Select the Microsoft.WindowsAzure.ServiceRuntime assembly, Version 2.4.0.0.

7. Click OK.
8. Right-click the Contoso.Events.Worker project.

9. Hover over the Add menu item.

10. Click Reference….


MCT USE ONLY. STUDENT USE PROHIBITED
L6-2 Developing Microsoft Azure™ Solutions

11. In the Reference Manager – Contoso.Events.Worker dialog box, do the following:

12. Expand Solution and then click Projects.

13. Select the Contoso.Events.Models project.

14. Select the Contoso.Events.Data project.


15. Select the Contoso.Events.Documents project.

16. Click OK
17. On the VIEW menu, hover over the Other Windows menu item and then click Package Manager
Console.

18. In the Package Manager Console pane, locate the Default Project list box and then select
Contoso.Events.Worker.

19. In the Package Manager Console text area, immediately to the right of:

PM>

Type in the following command:

Install-Package EntityFramework -Version 6.0.2

20. Press Enter.


21. On the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click Build.

 Task 3: Create a Class Inheriting from RoleEntryPoint


1. In the Solution Explorer pane, right-click the Contoso.Events.Worker project.
2. Hover over the Add menu item.

3. Click New Item….

4. In the Add New Item – Contoso.Events.Worker dialog box, do the following:


1. Expand Installed and Visual C# Items.

2. Click the Class item.

3. In the Name dialog box, provide the value WorkerRole.cs.

4. Click Add.
5. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

6. Double-click the WorkerRole.cs item.

7. Locate the following line of code:

class WorkerRole

8. Replace that single line of code with the following code:

public class WorkerRole

9. Add the following using block to the top of the class:

using Microsoft.WindowsAzure.ServiceRuntime;

10. Locate the following line of code:


MCT USE ONLY. STUDENT USE PROHIBITED
L6-3

public class WorkerRole

11. Replace that single line of code with the following code:

public class WorkerRole : RoleEntryPoint

12. Click anywhere between the opening and closing curly brackets of the WorkerRole class.

13. Use the return key to add vertical space for your method[s].
14. Add the following block of code to your class:

public override bool OnStart()


{
ServicePointManager.DefaultConnectionLimit = 12;
return base.OnStart();
}

15. Add the following using block to the top of the class:

using System.Net;

16. Click anywhere between the opening and closing curly brackets of the WorkerRole class.
17. Use the return key to add vertical space for your method[s].

18. Add the following block of code to your class:

public override void Run()


{
Trace.WriteLine("Queue Run Start");
while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Queue Run Iteration");
}
}

19. Add the following using blocks to the top of the class:

using System.Diagnostics;
using System.Threading;

20. Save the WorkerRole.cs class.

 Task 4: Implement the Run Logic to Get Requests from the SQL Database
1. Right-click the Contoso.Events.Worker project.

2. Hover over the Add menu item.


3. Click Existing Item….

4. In the Add Existing Item – Contoso.Events.Worker dialog box, do the following:

5. Navigate to Allfiles (E):\Mod06\Labfiles\Starter.


6. Click WorkerRole.cs.

7. Click Add.
8. In the Destination File Exists dialog, click the Yes button to replace the existing file.

9. In the Microsoft Visual Studio dialog, click the Yes button to refresh the source editor.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-4 Developing Microsoft Azure™ Solutions

10. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

11. Double-click the App.config item.

12. Select the entire content of the configuration file.

13. Press the Delete keyboard key.


14. Type in the following XML content:

<?xml version="1.0" encoding="utf-8"?>


<configuration>
<connectionStrings>
<add name="EventsContextConnectionString" connectionString="Data
Source=(localdb)\v11.0;Initial Catalog=EventsContextDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

Results: After completing this exercise, you will be able to create a Worker Role class library and
implement the appropriate pattern for a background worker.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-5

Exercise 2: Add the Class Library to a Cloud Service Project


 Task 1: Add Class Library as a Worker Role to the Cloud Service project
1. In the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click
Unload Project.

2. If you have not saved the project yet, you will be prompted to save the project. Click Yes.

3. In the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click Edit
Contoso.Events.Worker.csproj.

4. Locate the <PropertyGroup> opening XML element.

5. Immediately after the <PropertyGroup> XML element and before the <Configuration> XML
element, add the following XML element:

<RoleType>Worker</RoleType>

6. In the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click Reload
Project.
7. You will be prompted to close the .csproj file since it is already open. Click Yes.

8. If you have not saved the file, you will be prompted to save the .csproj file. Click Yes.

9. In the Solution Explorer pane, expand the Contoso.Events.Cloud project, then the Roles folder.
10. Right-click the Roles folder.

11. Hover over the Add menu item.

12. Click Worker Role Project in solution….

Note: If the Worker Role Project in Solution… option is disabled, you can enable it by
reloading the Contoso.Events.Worker project using the following steps:

13. In the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click
Unload Project

14. In the Solution Explorer pane, right-click the Contoso.Events.Worker project and then click Reload
Project

15. In the Associate with Role Project dialog, do the following:

16. Click Contoso.Events.Worker.

17. Click OK.

Results: After completing this exercise, you will be able to take an existing Class Library project and turn it
into a Worker Role in an existing Cloud Service project.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-6 Developing Microsoft Azure™ Solutions

Exercise 3: Debug Worker Roles in a Cloud Service Project


 Task 1: Debug the Worker Role
1. In the Solution Explorer pane, right-click the Contoso.Events.Cloud project and then click Set as
Startup Project.

2. On the DEBUG menu, click Start Debugging.

3. On the homepage of the Contoso Events web site, click the name of any event.

4. Click the Generate Sign-In Sheet button.

5. Refresh the page once every 30 seconds until the sign-in sheet is generated.

Note: You will know that the sign-in sheet generation is done when the text of the button
changes from “Generate Sign-In Sheet” to “Download Sign-In Sheet”.

6. Click the Download Sign-In Sheet button to download the Word document.

7. At the bottom of the Internet Explorer window, click the Run button in the download dialog.
8. Observe the content of the .docx file that opened in WordPad.

Results: After completing this exercise, you will be able to debug a Worker Role.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-1

Module 7: Storing Tabular Data in Azure


Lab A: Storing Event Data in Azure SQL
Databases
Exercise 1: Creating an Azure SQL Databases Instance
 Task 1: Login to the Azure Preview Portal
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://portal.azure.com.

3. Enter your Microsoft Account e-mail.

4. Click the Continue button.


5. Enter your Microsoft Account password.

6. Click the Sign In button.

 Task 2: Create an Azure SQL Database using the Preview Portal


1. In the navigation pane on the left side, scroll down and click Browse.
2. In the Browse blade that appears, click SQL databases.

3. In the bottom left corner of the portal, click the New button.
4. In the New blade that appears, click the SQL Database link.
5. In the SQL database blade that appears, do the following:

6. In the Name dialog box, provide the value db20532a[Your Name Here].
7. Click the Pricing Tier link.
8. In the Recommended pricing tier blade that appears, select the Web option.

9. Click the Select button to close the blade.

10. In the SQL database blade, click the Server link.


11. In the Server blade that appears, click the Create a new server link.

12. In the New Server blade that appears, locate the Server Name dialog box.
13. In the Server Name dialog box, provide the value sv20532a[Your Name Here].

14. In the Server Admin Login dialog box, provide the value testuser.

15. In the Password dialog box, provide the value TestPa$$w0rd.


16. In the Confirm Password dialog box, provide the value TestPa$$w0rd.

17. Click the Location link.

18. In the Location blade that appears, select the region that is closes to your location.
19. In the New server blade, click the OK button.
20. In the SQL database blade, click the Create button to create the SQL Database and Server.

21. Write down the name of the new SQL Database.


MCT USE ONLY. STUDENT USE PROHIBITED
L7-2 Developing Microsoft Azure™ Solutions

Results: After completing this exercise, you will be able to create both servers and databases in the Azure
SQL Databases service.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-3

Exercise 2: Using Entity Framework with Azure SQL Databases


 Task 1: Run the ASP.NET Web Application to View Events from LocalDb
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod07\Labfiles\Starter\SQL\Contoso.Events,
and then double-click Contoso.Events.sln

4. In the Solution Explorer pane, right-click the Contoso.Events.DataGeneration project, highlight Debug
and then click Start New Instance.

Note: The Data Generation script takes between 1-2 minutes to run.
5. In the Solution Explorer pane, right-click the Contoso.Events.Cloud project and then click Set as
Startup Project.

6. On the DEBUG menu, click Start Debugging.

7. On the home page of the web application, verify that it shows a list of multiple events.
8. Close the tab displaying the website.

 Task 2: Configure the DbContext with a New DatabaseInitializer


1. In the Solution Explorer pane, right-click the Contoso.Events.Data project, highlight Add and then
click NewItem….
2. In the Add New Item dialog, do the following:

3. Expand Installed, Visual C# Items, and then click Code.


4. Click the Class template.
5. In the Name box, specify the value EventsContextInitializer.cs.

6. Click Add.

7. In the EventsContextInitializer class, add the accessor public to the left of the class definition:

class EventsContextInitializer

8. Verify that the updated class definition reads:

public class EventsContextInitializer

9. In the EventsContextInitializer class, add the inheritance statement :


DropCreateDatabaseAlways<EventsContext> to the right of the class definition:

public class EventsContextInitializer

10. Verify that the updated class definition reads:

public class EventsContextInitializer : DropCreateDatabaseAlways<EventsContext>

11. Add this using statement to the top of the code file:

using System.Data.Entity;

12. In the Solution Explorer pane, expand the Contoso.Events.Data project


MCT USE ONLY. STUDENT USE PROHIBITED
L7-4 Developing Microsoft Azure™ Solutions

13. Open the EventsContext.cs file in the Contoso.Events.Data project.

14. Within the static constructor static EventsContext(), add the following line of code:

Database.SetInitializer<EventsContext>(new EventsContextInitializer());

15. Save the EventsContext.cs file.

 Task 3: Implement Seed Data with the DbContext


1. In the Solution Explorer pane, expand the Contoso.Events.Data project

2. Open the EventsContextInitializer.cs file in the Contoso.Events.Data project.

3. Add the following method to the EventsContextInitializer class:

protected override void Seed(EventsContext context)


{
}

4. Add this using statement to the top of the code file:

using Contoso.Events.Models;

5. Place your typing cursor immediately before the closing bracket of the Seed(EventsContext
context) method.

6. Type the following lines of code:

Event eventItem = new Event();


eventItem.EventKey = "FY17SepGeneralConference";
eventItem.StartTime = DateTime.Today;
eventItem.EndTime = DateTime.Today.AddDays(3d);
eventItem.Title = "FY17 September Technical Conference";
eventItem.Description = "Sed in euismod mi.";
eventItem.RegistrationCount = 1;

7. Place your typing cursor immediately before the closing bracket of the Seed(EventsContext
context) method.

8. Type the following line of code:

context.Events.Add(eventItem);

9. Place your typing cursor immediately before the closing bracket of the Seed(EventsContext
context) method.

10. Type the following lines of code:

Registration registrationItem = new Registration();


registrationItem.EventKey = "FY17SepGeneralConference";
registrationItem.FirstName = "Aisha";
registrationItem.LastName = "Witt";

11. Place your typing cursor immediately before the closing bracket of the Seed(EventsContext
context) method.

12. Type the following line of code:

context.Registrations.Add(registrationItem);
MCT USE ONLY. STUDENT USE PROHIBITED
L7-5

13. Place your typing cursor immediately before the closing bracket of the Seed(EventsContext
context) method.

14. Type the following line of code:

context.SaveChanges();

15. Save the EventsContextInitializer.cs file.

16. In the Solution Explorer pane, right-click the Contoso.Events.Data project and then click Build.

 Task 4: Publish the Cloud Application with the Updated DbContext to Azure
1. In the Solution Explorer pane, expand the Contoso.Events.Web project.

2. In the Solution Explorer pane, expand the Web.config file in the Contoso.Events.Web project.
3. Double-click the Web.Release.config file.

4. In the Web.Release.config file update the EventsContextConnectionString and provide these values:
o [database]: db20532a[Your Name Here]

o [login]: testuser

o [server]: sv20532a[Your Name Here]


o [password]: TestPa$$w0rd
5. Save the Web.Release.config file.

6. In the Solution Explorer pane, right-click the Contoso.Events.Cloud project and then click Publish.

7. In the Publish Windows Azure Application dialog, do the following:


1. If you have not already selected a subscription in the past, do the following:

o If prompted, log in with your Microsoft Account.


o Locate the Choose your subscription list, and select your Azure subscription.
o Click Next.

2. Otherwise, you will be immediately directed to the Windows Azure Publish Settings step.

3. Open the Create Cloud Service and Storage Account dialog.


4. If you do not have any existing cloud services you will be prompted with the Create Cloud Service
and Storage Account dialog immediately.

5. Otherwise, locate the Cloud Service list and select the Create New value to open the dialog.
6. In the Create Cloud Service dialog, do the following:

7. In the Name dialog box, provide the value cs20532a[Your Name].


8. In the Region or Affinity Group list, select the region that is closest to your location.

9. Click Create.

10. In the Microsoft Azure Publish Settings dialog, do the following:


11. Leave all fields to their default values.

12. Click Publish.


MCT USE ONLY. STUDENT USE PROHIBITED
L7-6 Developing Microsoft Azure™ Solutions

Note: It typically takes between 5-10 minutes for the publish operation to complete. You can
track the progress of your publish in the Windows Azure Activity Log pane that is opened when you
being publishing your Cloud Service project.

 Task 5: Verify that the Azure Cloud Service Website is using the New Data
1. Wait until the publish process is complete and the console window shows a line with the message
“Complete”.

Note: The publish process is complete when the message Complete is shown in the
Windows Azure Activity Log’s history console. The green circular indicator in the Activity Log
does not necessarily indicate that the publish process is complete, just that the package has been
uploaded successfully.

2. In the Windows Azure Activity Log, click the hyperlink to the published web application.

3. Verify that the website shows the single event you created in your Entity Framework context
initializer.

 Task 6: Login to the Azure Management Portal


1. On the Start screen, click the Internet Explorer tile.
2. Browse to https://manage.windowsazure.com

3. Enter your Microsoft Account e-mail and password and then click Sign In.

 Task 7: View the Migrated Data in the Azure SQL Management Portal
1. In the navigation pane on the left side, scroll down and click SQL Databases.
2. Click the Databases tab at the top of the screen.

3. In the list of SQL Databases, click the Name of your SQL Database with the prefix db20532a.

4. Click the Dashboard tab at the top of the screen.


5. At the bottom of the page, click the Manage button.

6. You will be prompted to add your IP address to those included in the firewall rules to manage your
database. Click Yes.

Note: If you have not visited the Management Portal before, you will notice that Internet
Explorer blocks the popup. You will need to view the yellow warning message at the bottom of
the Internet Explorer window, click Options for this Site and then click Always Allow. This will
allow you to view popups without any restriction. Once these steps are complete, you will see
the Azure Management Portal refresh. You can then click the Manage button again to resume
the lab.

7. Once your IP address is added, you will be prompted again to ask if you would like to manage your
database. Click Yes.

8. In the Management Portal – SQL Database popup window, do the following:

9. In the Username dialog box, provide the value testuser.

10. In the Password dialog box, provide the value TestPa$$w0rd.


MCT USE ONLY. STUDENT USE PROHIBITED
L7-7

11. Click Log On.

12. In the bottom left corner of the Management Portal – SQL Database window, click the Design
button.

13. In the list of Tables, click the dbo.Events table.

14. Click the Edit button immediately to the right of the selected table.

15. On the table’s page, click the Data tab at the top of the window.

16. View the single record in the dbo.Events table.

17. Close the Management Portal – SQL Database window.

Results: After completing this exercise, you will be able to configure Entity Framework to initialize a new
database with seed data.

Lab B: Storing Event Registration Data in


Azure Storage Tables
Exercise 1: Populating the Sign-In Form with Registrant Names
 Task 1: Create an Instance of the CloudTable Class
1. On the Windows Start screen, click Desktop.
2. On the taskbar, click the File Explorer icon.

3. In the Libraries window, navigate to Allfiles (F):\Mod07\Labfiles\Starter\Tables\Contoso.Events,


and then double-click Contoso.Events.sln.
4. In the Solution Explorer pane, expand the Roles solution folder.

5. In the Soution Explorer pane, expand the Contoso.Events.Worker project.

6. Double-click the TableStorageHelper.cs file.


7. In the TableStorageHelper class, find the method with the following signature:

IEnumerable<string> GetRegistrantNames(string eventKey);

8. Remove the single line of code in the class:

return Enumerable.Empty<string>();

9. At the end of the GetRegistrantNames method before the closing bracket, create a CloudTable
instance:

CloudTable table = _tableClient.GetTableReference("EventRegistrations");

 Task 2: Retrieve Strongly-Typed Registration Records by Partition Key


1. At the end of the GetRegistrantsNames method before the closing bracket, store the eventKey in a
string variable named partitionKey:

string partitionKey = eventKey;


MCT USE ONLY. STUDENT USE PROHIBITED
L7-8 Developing Microsoft Azure™ Solutions

2. Create a string filter using the TableQuery.GenerateFilterCondition:

string filter = TableQuery.GenerateFilterCondition("PartitionKey",


QueryComparisons.Equal, partitionKey);

3. At the end of the GetRegistrantsNames method before the closing bracket, create a new instance of
the TableQuery class and use the fluent Where method with your filter to generate a query:

TableQuery<Registration> query = new TableQuery<Registration>().Where(filter);

4. Pass the generated query into the ExecuteQuery method of the table variable using the
Registration model class as the generic parameter:

IEnumerable<Registration> registrations = table.ExecuteQuery<Registration>(query);

 Task 3: Use LINQ-to-Objects to Project a List of Registrant Names


1. At the end of the GetRegistrantsNames method before the closing bracket, add a statement
without the closing semi-colon to store the registrations in a variable of the same type named names:

IEnumerable<string> names = registrations

2. Append the lambda-syntax query with a fluent method to order the result by LastName:

.OrderBy(r => r.LastName)

3. Append the query further with a fluent method to order the result by FirstName:

.ThenBy(r => r.FirstName)

4. Finalize the query with a projection method that uses the String.Format static method to format the
string with LastName, followed by a command, then a space and FirstName:

.Select(r => String.Format("{1}, {0}", r.FirstName, r.LastName));

5. At the end of the GetRegistrantsNames method before the closing bracket, add the following
statement:

return names;

Results: After completing this exercise, you will be able to query entities by row key or partition key from
Table Storage.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-9

Exercise 2: Updating the Events Website to use Storage Tables


 Task 1: Update the Register Controller Action to Store the Registration Record
1. In the Solution Explorer pane, expand the Roles solution folder.

2. In the Solution Explorer pane, expand the Contoso.Events.Web project.


3. In the Contoso.Events.Web project, expand the Controllers folder.

4. Double-click the RegisterController.cs file.

5. In the RegisterController class, find the method with the following signature:

Guid StoreRegistration(dynamic registration)

6. Remove the single line of code in the class:

return Guid.Empty;

7. At the end of the StoreRegistration method before the closing bracket, get the connection string
using the CloudConfigurationManager.GetSetting static method and the
Microsoft.WindowsAzure.Storage.ConnectionString value as the parameter:

string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Storage.ConnectionString
");

8. Use the CloudStorageAccount.Parse static method with the connection string as the parameter to
get the storage account:

var storageAccount =
Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

9. At the end of the StoreRegistration method before the closing bracket, create a CloudTableClient
variable using the CreateCloudTableClient method of the storage account:

var tableClient = storageAccount.CreateCloudTableClient();

10. Using the GetTableReference method of the CloudTableClient variable and “EventRegistrations”
as the parameter, create a CloudTable variable:

var table = tableClient.GetTableReference("EventRegistrations");

11. At the end of the StoreRegistration method before the closing bracket, create a new
TableOperation using the TableOperation.Insert static method and the dynamic registration as the
parameter:

var operation = TableOperation.Insert(registration);

12. Using the CloudTable variable, invoke the Execute method passing the TableOperation as the
parameter:

table.Execute(operation);

13. At the end of the StoreRegistration method before the closing bracket, use the Guid.Parse static
method to parse the registration.RowKey string as a System.Guid:
MCT USE ONLY. STUDENT USE PROHIBITED
L7-10 Developing Microsoft Azure™ Solutions

Guid rowKey = Guid.Parse(registration.RowKey);

14. Return the rowKey variable as the result of the StoreRegistration method.

return rowKey;

 Task 2: Update the Register ViewModel to Retrieve the Dynamic Stub Registration
from the Table
1. In the Solution Explorer pane, expand the Shared solution folder.

2. In the Solution Explorer pane, expand the Contoso.Events.ViewModels project.


3. Double-click the RegisterViewModel.cs file.

4. In the RegisterViewModel class, locate the method with the following signature:

RegisterViewModel(string eventKey)

5. At the end of the RegisterViewModel constructor before the closing bracket, get the connection
string using the CloudConfigurationManager.GetSetting static method and the
Microsoft.WindowsAzure.Storage.ConnectionString value as the parameter:

string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Storage.ConnectionString
");

6. Use the CloudStorageAccount.Parse static method with the connection string as the parameter to
get the storage account:

var storageAccount =
Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

7. At the end of the RegisterViewModel constructor before the closing bracket, create a
CloudTableClient variable using the CreateCloudTableClient method of the storage account:

var tableClient = storageAccount.CreateCloudTableClient();

8. Using the GetTableReference method of the CloudTableClient variable and “EventRegistrations”


as the parameter, create a CloudTable variable:

var table = tableClient.GetTableReference("EventRegistrations");

9. At the end of the RegisterViewModel constructor before the closing bracket, store the eventKey in
a string variable named partitionKey:

string partitionKey = String.Format("Stub_{0}", this.Event.EventKey);

10. Create a string filter using the TableQuery.GenerateFilterCondition

string filter = TableQuery.GenerateFilterCondition("PartitionKey",


QueryComparisons.Equal, partitionKey);

11. At the end of the RegisterViewModel constructor before the closing bracket, create a new instance
of the TableQuery class and use the fluent Where method with your filter to generate a query:

TableQuery query = new TableQuery().Where(filter);


MCT USE ONLY. STUDENT USE PROHIBITED
L7-11

12. Pass the generated query into the ExecuteQuery method of the table variable:

IEnumerable<DynamicTableEntity> tableEntities = table.ExecuteQuery(query);

13. At the end of the RegisterViewModel constructor before the closing bracket, select the single
element in the enumerable of DynamicTableEntity objects:

DynamicTableEntity tableEntity = tableEntities.SingleOrDefault();

14. Set the RegistrationStub property to the DyanmicTableEntity variable:

this.RegistrationStub = DynamicEntity.GenerateDynamicItem(tableEntity);

Results: After completing this exercise, you will be able to use the Azure Storage SDK to retrieve and
create entities.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-12 Developing Microsoft Azure™ Solutions

Exercise 3: Verify that the Events Web Site is using Azure Storage Tables
for Registrations
 Task 1: Run the Data Generation Console Project to Populate the Azure Storage
Table with Data
1. In the Solution Explorer pane, expand the Shared solution folder.

2. In the Solution Explorer pane, expand the Contoso.Events.Data.Generation project.


3. In the Solution Explorer pane, right-click the Contoso.Events.Data.Generation project, highlight
Debug and then click Start New Instance.

 Task 2: Use Server Explorer in Visual Studio 2013 to View Table Storage Registrations
1. On the View menu, click Server Explorer.

2. Locate the Windows Azure node and click the arrow immediately to the left.
3. Expand the Storage node under the Windows Azure node.

4. If prompted for your account credentials, login using your Microsoft Account.
5. Expand the Development account node under the Storage node.

6. Expand the Tables node under the Development account node.

7. Double-click the EventRegistrations table.


8. In the EventRegistrations [Table] tab, scroll through the entities.
9. Drill-down into the properties of a single entity by double-clicking on a row.

10. Exit out of the Edit Entity dialog box.

 Task 3: Debug the Cloud Web Project to Register for the Event
1. In the Solution Explorer pane, right-click the Contoso.Events.Cloud project and then click Set As
Startup Project.

2. On the DEBUG menu, click Start Debugging.

3. If the Storage Emulator is already running, you will be prompted to shut down the emulator and
restart it using a different mode. Click OK.

4. On the home page of the web application, verify that it shows a list of events.

5. Click on any of the events in the list.

6. On the event web page, click the Register Now link.

7. Fill out all of the fields in the registration form and click Submit.

8. Close the tab displaying the website.

 Task 4: Use Server Explorer in Visual Studio 2013 to View the New Table Storage
Registration
1. On your desktop taskbar, locate the Contoso.Events - Visual Studio 2013 window.

2. On the View menu, click Server Explorer.

3. Locate the Windows Azure node.


4. Double-click the EventRegistrations table within the hierarchy of the Windows Azure node.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-13

5. In the EventRegistrations [Table] tab, scroll through the entities.

6. In the yellow prompt asking if you would like to download the remaining entities, click the click here
hyperlink.

7. Drill-down into the properties of a single entity by double-clicking on a row.

8. Click the Timestamp table header twice to sort entities in a descending order by their Timestamp.

9. Locate your new entity at the top of the table.

10. Close the Internet Explorer application.

11. Switch to the Contoso.Events – Visual Studio window.

12. On the DEBUG menu, click Stop Debugging.

13. Close the Contoso.Events - Visual Studio application.

Results: After completing this exercise, you will be able to leverage Visual Studio and the Azure emulators
to create a comprehensive development environment for Azure Storage.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-14 Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
L8-1

Module 8: Storing Files and Media in Azure


Lab: Storing Generated Documents in Azure
Storage Blobs
Exercise 1: Implement Azure Storage Blobs
 Task 1: Login to the Azure Preview Portal
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://portal.azure.com

3. Enter your Microsoft Account e-mail

4. Click the Continue button


5. Enter your Microsoft Account password

6. Click the Sign In button.

 Task 2: Create a Container using the Management Portal


1. In the navigation pane on the left side, scroll down and click Browse.
2. In the Browse blade that appears, click Storage.

3. In the Storage blade that appears, view your list of Storage instances.
4. In the list of Storage instances, locate your storage account with the prefix stor20532.
5. Click the name of your storage account to go to its dashboard.

6. In the stor20532[Your Name Here] blade that appears, click the Containers tile.
7. In the Containers blade that appears, view the list of your containers.
8. At the top of the blade, click the Add button.

9. In the Add a container blade that appears, do the following:

10. In the Name dialog box, provide the value example.


11. In the Access Type list, select the value Container.

12. Click the OK button to create your container.

 Task 3: Add and Access Blob Files in Your Container


13. On the Start screen, click the Visual Studio 2013 tile.
14. On the View menu, click Server Explorer.

15. Locate the Windows Azure node and click the arrow immediately to the left.

16. Expand the Storage node under the Windows Azure node.

Note: If you have not previously indicated that you would like Visual Studio to remember
your credentials, you will be prompted to enter your Microsoft Account username and
password to continue.

17. Expand the stor20532[Your Name] account node under the Storage node.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-2 Developing Microsoft Azure™ Solutions

18. Expand the Blobs node under your storage account’s node.

19. Double-click the example container.

20. In the Container tab, locate and click the Upload Blob button.

Note: The upload button iconography includes an arrow pointing up to a horizontal line.

21. In the Upload Blob dialog, do the following:

22. Navigate to the (E):\Mod08\LabFiles\Starter\ directory.

23. Click the samplefile Text Document.


24. Click the Open button.

25. Switch back to the Internet Explorer window.

26. In a new tab, type in the Url replacing [storage account] with the name of your storage account:
o http://[storage account].blob.core.windows.net/example/samplefile.txt
27. Verify that the text “This is your sample file!” shows up in the browser.

Results: After completing this exercise, you will be able to create a blob container using the Management
Portal and view blobs in the container.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-3

Exercise 2: Populating the Container with Files and Media


 Task 1: Open the Blob Helper in the Cloud Service Worker Project
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod08\Labfiles\Starter\Contoso.Events, and
then double-click Contoso.Events.sln.

4. In the Solution Explorer pane, expand the Roles solution folder.

5. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

6. Double-click the BlobStorageHelper.cs file.

 Task 2: Add Word Documents to the Container After They are Created
1. In the BlobStorageHelper class, find the method with the following signature:

public Uri CreateBlob(MemoryStream stream, string eventKey)

2. Remove the single line of code in the class:

return null;

3. At the end of the CreateBlob method before the closing bracket, create a new CloudBlobContainer
for the signin container.

CloudBlobContainer container = _blobClient.GetContainerReference("signin");

4. Call the CreateIfNotExists method of the CloudBlobContainer variable to ensure that the container
exists:

container.CreateIfNotExists();

5. At the end of the CreateBlob method before the closing bracket, create a new variable named
blobName:

string blobName;

6. Use the String.Format static method to create a string and assign the string to the blobName
variable:

blobName = String.Format("{0}_SignIn_{1:ddmmyyyss}.docx", eventKey, DateTime.UtcNow);

7. At the end of the CreateBlob method before the closing bracket, create a block blob reference using
the GetBlockBlobReference method and the blobName variable as the parameter:

ICloudBlob blob = container.GetBlockBlobReference(blobName);

8. Use the Seek method of the MemoryStream variable to seek the Origin by 0 offset using the
beginning as the origin:

stream.Seek(0, SeekOrigin.Begin);

9. Use the UploadFromStream method of the ICloudBlob interface to upload the stream to the
referenced blob:
MCT USE ONLY. STUDENT USE PROHIBITED
L8-4 Developing Microsoft Azure™ Solutions

blob.UploadFromStream(stream);

10. At the end of the CreateBlob method before the closing bracket, add the following statement:

return blob.Uri;

Results: After completing this exercise, you will be able to use the Azure Storage SDK to manage blobs
and containers in your storage account.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-5

Exercise 3: Retrieving Files and Media From the Container


 Task 1: Download Documents from Blob Storage and Stream to Client
1. In the Solution Explorer pane, expand the Shared solution folder.

2. In the Solution Explorer pane, expand the Contoso.Events.ViewModels project.


3. Double-click the DownloadViewModel.cs file.

4. In the DownloadViewModel class, find the method with the following signature:

public async Task<DownloadPayload> GetStream()

5. Remove the single line of code in the class:

return await Task.FromResult<DownloadPayload>(null);

6. At the end of the GetStream method before the closing bracket, create a new CloudBlobClient for
the _storageAccount variable.

CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();

7. Create a new CloudBlobContainer for the signin container using the CloudBlobClient variable.

CloudBlobContainer container = blobClient.GetContainerReference("signin");

8. Call the CreateIfNotExists method of the CloudBlobContainer variable to ensure that the container
exists:

container.CreateIfNotExists();

9. At the end of the GetStream method before the closing bracket, create a block blob reference using
the GetBlockBlobReference method and the _blobId variable as the parameter:

ICloudBlob blob = container.GetBlockBlobReference(_blobId);

10. Use the OpenReadAsync method of the ICloudBlob variable to create a Stream and store it in a
variable:

Stream blobStream = await blob.OpenReadAsync();

11. At the end of the GetStream method before the closing bracket, create a new instance of the
DownloadPayload class:

DownloadPayload payload = new DownloadPayload();

12. Assign the Stream variable to the DownloadPayload variable’s Stream property:

payload.Stream = blobStream;

13. Assign the ICloudBlob variable’s Properties.ContentType value to the DownloadPayload variable’s
ContentType property:

payload.ContentType = blob.Properties.ContentType;

14. Return the DownloadPayload variable;


MCT USE ONLY. STUDENT USE PROHIBITED
L8-6 Developing Microsoft Azure™ Solutions

return payload;

 Task 2: Generate the Test Data


1. On the Windows Start screen, type Azure Storage Emulator.

2. Click the Windows Azure Storage Emulator – v3.3 tile.

3. Switch back to the Contoso.Events – Visual Studio 2013 window.

4. In the Solution Explorer pane, right-click the Contoso.Events.Data.Generation project, highlight


Debug and then click Start New Instance.

 Task 3: Download Generated Sign-In Sheets from Blob Storage


1. In the Solution Explorer pane, right-click the Contoso.Events solution and then click Properties.

2. In the Contoso.Events Property Pages dialog, do the following:


1. Make sure that CommonProperties => Startup Project is selected in the navigation menu on the
left.
2. Select the Multiple startup projects: radio button.
3. For Contoso.Events.Cloud, set the Action to Start.

4. For Contoso.Events.Management, set the Action to Start without debugging.

5. Ensure that all of the remaining projects have their Action set to None.
6. Click OK to close the dialog

7. On the DEBUG menu, click Start Debugging

8. In the Windows quick launch tray, click on the arrow to see the running tray icons.
9. Locate the IIS Express icon and right-click the tray icon.

10. Hover over the Contoso.Events.Management option under the View Sites header, then click the
URL under the Browse Applications header.

11. On the home page for the Administration web application, click the button to go to the list of
events.

12. Click the Sign-In Sheet button for any event in the list.
13. View the sign-in page which notifies you that a sign-in sheet is being generated.

14. Wait 1-2 minutes, then refresh the sign-in sheet page.
15. Click the Sign-In Sheet hyperlink to download the sign-in sheet from the server.

Results: After completing this exercise, you will be able to download blobs from your storage account
using the Azure Storage SDK.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-7

Exercise 4: Specifying Permissions for the Container


 Task 1: Modify Container Access using Server Explorer
1. On your desktop, click the Contoso.Events - Visual Studio 2013 window.

2. On the Debug menu, click Stop Debugging.


3. On the View menu, click Server Explorer.

4. Locate the Windows Azure node and click the arrow immediately to the left.

5. Expand the Storage node under the Windows Azure node.


6. Expand the Development account node under the Storage node.

7. Expand the Blobs node under Development account node.

8. Right-click the signin container, then click Properties.


9. In the Properties pane, locate the Public Read Access property.

10. Ensure that the value of the Public Read Access property is Off.

 Task 2: Generate Temporary SAS Tokens using the SDK


1. In the Solution Explorer pane, expand the Shared solution folder.
2. In the Solution Explorer pane, expand the Contoso.Events.ViewModels project.

3. Double-click the DownloadViewModel.cs file.


4. In the DownloadViewModel class, find the method with the following signature:

public async Task<string> GetSecureUrl()

5. Remove the single line of code in the class:

return await Task.FromResult<string>(String.Empty);

6. At the end of the GetSecureUrl method before the closing bracket, create a new CloudBlobClient
for the _storageAccount variable.

CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();

7. Create a new CloudBlobContainer for the signin container using the CloudBlobClient variable.

CloudBlobContainer container = blobClient.GetContainerReference("signin");

8. Call the CreateIfNotExists method of the CloudBlobContainer variable to ensure that the container
exists:

container.CreateIfNotExists();

9. At the end of the GetSecureUrl method before the closing bracket, create a new instance of the
SharedAccessBlobPolicy class:

SharedAccessBlobPolicy blobPolicy = new SharedAccessBlobPolicy();

10. Set the SharedAccessBlobPolicy variable’s SharedAccessExpiryTime property to 15 minutes from


the current time:
MCT USE ONLY. STUDENT USE PROHIBITED
L8-8 Developing Microsoft Azure™ Solutions

blobPolicy.SharedAccessExpiryTime = DateTime.Now.AddHours(0.25d);

11. Set the SharedAccessBlobPolicy variable’s Permissions property to


SharedAccessBlobPermissions.Read:

blobPolicy.Permissions = SharedAccessBlobPermissions.Read;

12. At the end of the GetSecureUrl method before the closing bracket, create a new instance of the
BlobContainerPermissions class:

BlobContainerPermissions blobPermissions = new BlobContainerPermissions();

13. Add the SharedAccessBlobPolicy to the BlobContainerPermissions variable’s SharedAccessPolicy


with the key “ReadBlobPolicy”:

blobPermissions.SharedAccessPolicies.Add("ReadBlobPolicy", blobPolicy);

14. Set the BlobContainerPermissions variable’s PublicAccess property to


BlobContainerPublicAccessType.Off:

blobPermissions.PublicAccess = BlobContainerPublicAccessType.Off;

15. At the end of the GetSecureUrl method before the closing bracket, call the asynchronous
SetPermissionsAsync method of the CloudBlobContainer variable using the
BlobContainerPermissions variable as the parameter:

await container.SetPermissionsAsync(blobPermissions);

16. Invoke the GetSharedAccessSignature method of the CloudBlobContainer variable using a new
instance of the SharedAccessBlobPolicy class as the first parameter and the “ReadBlobPolicy” key
as the second parameter:

string sasToken = container.GetSharedAccessSignature(new SharedAccessBlobPolicy(),


"ReadBlobPolicy");

17. At the end of the GetSecureUrl method before the closing bracket, create a block blob reference
using the GetBlockBlobReference method and the _blobId variable as the parameter:

ICloudBlob blob = container.GetBlockBlobReference(_blobId);

18. Take the Uri property of the ICloudBlob variable and store it in a new Uri variable.

Uri blobUrl = blob.Uri;

19. At the end of the GetSecureUrl method before the closing bracket, concatenate the AbsoluteUri of
the Uri variable and the sasToken variable:

string secureUrl = blobUrl.AbsoluteUri + sasToken;

20. Return the string variable as the result of the method:

return secureUrl;

 Task 3: Download Documents from a Protected Container using the SAS Token
1. On the DEBUG menu, click Start Debugging.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-9

2. In the Windows quick launch tray, click on the arrow to see the running tray icons.

3. Locate the IIS Express icon and right-click the tray icon.

4. Hover over the Contoso.Events.Management option under the View Sites header, then click the
URL under the Browse Applications header.

5. On the home page for the Administration web application, click the button to go to the list of
events.

6. Click the Sign-In Sheet button for any event in the list.

7. View the sign-in page which notifies you that a sign-in sheet is being generated.

8. Wait 1-2 minutes, then refresh the sign-in sheet page.


9. Click the Sign-In Sheet hyperlink to download the sign-in sheet from the server using the blob Url.

10. Close the Internet Explorer application.

11. Switch to the Contoso.Events – Visual Studio window.


12. On the DEBUG menu, click Stop Debugging.
13. Close the Contoso.Events - Visual Studio application.

Results: After completing this exercise, you will be able to modify the permissions of containers and
generate SAS Tokens for the containers.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-10 Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
L9-1

Module 9: Designing a Communication Strategy using


Queues and Service Bus
Lab: Using Queues and Service Bus to
Manage Communication Between Web
Applications in Azure
Exercise 1: Creating an Azure Service Bus Namespace
 Task 1: Create the Service Bus Namespace using the Management Portal

Note: Service Bus functionality is not available yet in the new Preview Portal. Because of
this, the existing Management Portal will be used for this lab.

1. On the Windows Start screen, click the Internet Explorer tile.

2. Browse to https://manage.windowsazure.com

3. Enter your Microsoft Account e-mail and password and then click Sign In.
4. In the navigation pane on the left side, scroll down and click Service Bus.

5. At the bottom of the screen, click the Create button.

6. In the Create a Namespace dialog, do the following:


7. In the Namespace Name dialog box, provide the value sb20532[Your Name].

8. In the Region list, select the region that is closest to your location.

9. Click the checkmark button to create your namespace.


10. In the list of Service Bus namespaces, click the name of the namespace that you have just created.
11. At the bottom of the screen, click the Connection Information button.

12. Record the connection string from the ACS Connection String field.

Note: Here you will be recording three items. First you will record the ACS Connection
String. Next you will record the Default Issuer and Default Key.

13. Close the Access connection information dialog.

14. At the top of the screen, click the Queues tab.

15. At the bottom left of the screen, click the New button.

16. If it is not automatically selected, select App Services => Service Bus => Queue => Custom
Create.

17. In the Create a Queue dialog, do the following:

18. In the Queue Name dialog box, provide the value signin.

19. In the Region list, select the region that is closest to you.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-2 Developing Microsoft Azure™ Solutions

20. In the Namespace dialog box, provide the value sb20532[Your Name].

21. Click the next arrow to move to the next step in the wizard.

22. Leave all fields as their default values.

23. Click the checkmark button to create the new queue.

Results: After completing this exercise, you will be able to create a Service Bus Namespace using the
Azure Management Portal.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-3

Exercise 2: Using Azure Queue Storage for Document Generation


 Task 1: Update Worker Role to Consume Requests from the Queue
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles
(E):\Mod09\Labfiles\Starter\Queues\Contoso.Events, and then double-click Contoso.Events.sln.

4. In the Solution Explorer pane, expand the Roles folder.

5. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

6. Double-click the TableStorageQueueHelper.cs file.

7. At the end of the TableStorageQueueHelper constructor before the closing bracket, store the
StorageAccount property from the base class in a CloudStorageAccount variable.

CloudStorageAccount storageAccount = base.StorageAccount;

8. Invoke the CreateCloudQueueClient method and assign the result to the _queueClient variable.

_queueClient = storageAccount.CreateCloudQueueClient();

9. Invoke the static CloudConfigurationManager.GetSetting method and assign the result to the
_signInQueueName variable.

_signInQueueName = CloudConfigurationManager.GetSetting("SignInQueueName");

10. In the TableStorageQueueHelper class, find the constructor with the following signature:

IQueueMessage<CloudQueueMessage> Receive()

11. Remove the single line of code in the class:

return new TableStorageQueueMessage(null);

12. At the end of the Receive method before the closing bracket, create a new instance of the
CloudQueue class by calling the GetQueueReference method of the CloudQueueClient variable
using the string name of the queue.

CloudQueue queue = _queueClient.GetQueueReference(_signInQueueName);

13. Invoke the CreateIfNotExists method to ensure that the queue exists.

queue.CreateIfNotExists();

14. At the end of the Receive method before the closing bracket, invoke the GetMessage method of the
CloudQueue class and store the result in a CloudQueueMessage variable.

CloudQueueMessage message = queue.GetMessage();

15. Pass the CloudQueueMessage variable into the constructor of the TableStorageQueueMessage
class and return the result.

return new TableStorageQueueMessage(message);


MCT USE ONLY. STUDENT USE PROHIBITED
L9-4 Developing Microsoft Azure™ Solutions

16. At the end of the CompleteMessage method before the closing bracket, create a new instance of the
CloudQueue class by calling the GetQueueReference method of the CloudQueueClient variable
using the string name of the queue.

CloudQueue queue = _queueClient.GetQueueReference(_signInQueueName);

17. Invoke the CreateIfNotExists method to ensure that the queue exists.

queue.CreateIfNotExists();

18. At the end of the CompleteMessage method before the closing bracket, invoke the DeleteMessage
method using the CloudQueueMessage variable as the parameter.

queue.DeleteMessage(message);

 Task 2: Update Administration Application to Add Requests to the Queue


1. In the Solution Explorer pane, expand the Shared folder.
2. In the Solution Explorer pane, expand the Contoso.Events.ViewModels project.

3. Double-click the SignInSheetViewModel.cs file.


4. At the beginning of the GenerateSignInSheetTableStorage method after the opening bracket,
create a CloudStorageAccount instance using the static CloudStorageAccount.Parse method and
the table storage connection string.

CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(tableStorageConnectionString);

5. Create a new instance of the CloudQueueClient class using the CreateCloudQueueClient method
of the CloudStorageAccount variable.

CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

6. After the previous code, create a new instance of the CloudQueue class by invoking the
GetQueueReference method of the CloudQueueClient variable using the queue name string
variable.

CloudQueue queue = queueClient.GetQueueReference(signInQueueName);

7. Invoke the CreateIfNotExists method of the CloudQueue class to ensure that the queue exists.

queue.CreateIfNotExists();

8. After the previous code, create a new instance of the CloudQueueMessage class by passing in the
string message into the constructor.

CloudQueueMessage queueMessage = new CloudQueueMessage(message);

9. Invoke the AddMessage method of the CloudQueue variable using the CloudQueueMessage as
the parameter:

queue.AddMessage(queueMessage);

 Task 3: Generate the Test Data


1. On the Windows Start screen, type Azure Storage Emulator.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-5

2. Click the Windows Azure Storage Emulator – v3.3 tile.

3. Switch back to the Contoso.Events – Visual Studio 2013 window.

4. In the Solution Explorer pane, right-click the Contoso.Events.Data.Generation project, highlight


Debug and then click Start New Instance

 Task 4: Debug and Verify the Application


1. In the Solution Explorer pane, right-click the Contoso.Events solution and then click Properties.

2. In the Contoso.Events Property Pages dialog, do the following:


3. Make sure that CommonProperties => Startup Project is selected in the navigation menu on the
left.

4. Select the Multiple startup projects: radio button.

5. For Contoso.Events.Cloud, set the Action to Start.


6. For Contoso.Events.Management, set the Action to Start without debugging.

7. Ensure that all of the remaining projects have their Action set to None.

8. Click OK to close the dialog


9. On the DEBUG menu, click Start Debugging.

10. In the Windows quick launch tray, click on the arrow to see the running tray icons.
11. Locate the IIS Express icon and right-click the tray icon.

12. Hover over the Contoso.Events.Management option under the Web Sites header, then click the
URL under the Browse Applications header.
13. On your desktop, click the Contoso.Events - Visual Studio 2013 window.
14. In the Solution Explorer pane, expand the Roles folder.

15. In the Server Explorer pane, expand the Contoso.Events.Worker project.


16. Double-click the WorkerRole.cs file.

17. Locate the Run method.

18. After the check to see if the SourceMessage property of the brokeredMessage variable is null,
locate the try-catch block within that conditional.

19. Locate the target line of code within the try-catch block:

HandleMessage(message);

20. Right-click the target line of code, hover over Breakpoint and click Insert Breakpoint.

21. On your desktop, click the Home - Contoso.Events.Administration window.


22. On the home page for the Administration web application, click the button to go to the list of
events.

23. Click the Sign-In Sheet button for any event in the list.
24. View the sign-in page which notifies you that that sign-in sheet is being generated with the message:
Sign-In Document Generation in Progress.

25. Wait 1 minute for the worker role to receive the queue message.

26. Verify that the breakpoint is hit and execution temporarily pauses.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-6 Developing Microsoft Azure™ Solutions

27. Hit F5 to resume execution of the application

28. Wait 1 minute, then refresh the sign-in sheet page.

29. Click the Sign-In Sheet link to download the sign-in sheet from the server.

30. Close the Internet Explorer window.

Results: After completing this exercise, you will be able to create and consume messages from Azure
Storage Queues.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-7

Exercise 3: Use Service Bus Queues for Document Generation


 Task 1: Update Worker Role to Consume Requests from the Queue
1. In the Solution Explorer pane, expand the Contoso.Events.Cloud project.

2. Double-click the ServiceConfiguration.Local.cscfg file.


3. Locate the Setting element with the name Microsoft.ServiceBus.ConnectionString.

4. Replace the value with your previously recorded connection string.

5. In the Solution Explorer pane, expand the Roles folder.


6. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

7. Double-click the ServiceBusQueueHelper.cs file.

8. At the end of the ServiceBusQueueHelper constructor, before the closing bracket, store the
Microsoft.ServiceBus.ConnectionString setting value from your Cloud configuration in a string
variable.

string serviceBusConnectionString =
CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");

9. Store the queue name in a string variable.

string signInQueueName = CloudConfigurationManager.GetSetting("SignInQueueName");

10. Invoke the static QueueClient.CreateFromConnectionString method using the queue name and
connection string as parameters and assign the result to the _client variable.

_client = QueueClient.CreateFromConnectionString(serviceBusConnectionString,
signInQueueName);

11. In the ServiceBusQueueHelper class, find the method with the following signature:

IQueueMessage<BrokeredMessage> Receive()

12. Remove the single line of code in the class:

return new ServiceBusQueueMessage(null);

13. At the end of the Receive method before the closing bracket, create a new instance of the
CloudQueue class by calling the GetQueueReference method of the CloudQueueClient variable
using the string name of the queue.

BrokeredMessage message = _client.Receive();

14. Invoke the CreateIfNotExists method to ensure that the queue exists.

return new ServiceBusQueueMessage(message);

15. At the end of the CompleteMessage method before the closing bracket, invoke the Complete
method on the message parameter.

message.Complete();

16. At the end of the AbandonMessage method before the closing bracket, invoke the Abandon
method on the message parameter.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-8 Developing Microsoft Azure™ Solutions

message.Abandon();

17. In the Solution Explorer pane, expand the Roles folder.

18. In the Solution Explorer pane, expand the Contoso.Events.Worker project.

19. Double-click the WorkerRole.cs file.

20. Locate and replace the line of code creating the TableStorageQueueHelper:

var queueHelper = new TableStorageQueueHelper();

with a line creating a new instance of the ServiceBusQueueHelper.

var queueHelper = new ServiceBusQueueHelper();

 Task 2: Update Administration Application to Add Requests to the Queue


1. In the Solution Explorer pane, expand the Contoso.Events.Management project.
2. Double-click the Web.config file.

3. Locate the appSettings element.


4. Locate the add element with the key Microsoft.ServiceBus.ConnectionString.
5. Replace the value with your previously recorded connection string.

6. In the Solution Explorer pane, expand the Shared folder.


7. In the Solution Explorer pane, expand the Contoso.Events.ViewModels project.
8. Double-click the SignInSheetViewModel.cs file.

9. In the constructor, locate the following line of code:

GenerateSignInSheetTableStorage(context, eventItem, messageString);

10. Replace the above line of code with the following line of code:

GenerateSignInSheetServiceBus(context, eventItem, message);

11. At the beginning of the GenerateSignInSheetServiceBus method after the opening bracket, create a
QueueClient instance using the connection string.

QueueClient client =
QueueClient.CreateFromConnectionString(serviceBusConnectionString, signInQueueName);

12. After the previous code, create a new instance of the BrokeredMessage class by passing in the
QueueMessage message into the constructor.

BrokeredMessage queueMessage = new BrokeredMessage(message);

13. Invoke the Send method of the QueueClient variable using the BrokeredMessage as the parameter.

client.Send(queueMessage);

 Task 3: Debug and Verify the Application


1. On the DEBUG menu, click Start Debugging.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-9

2. In the Windows quick launch tray, click on the arrow to see the running tray icons.

3. Locate the IIS Express icon and right-click the tray icon.

4. Hover over the Contoso.Events.Management option under the Web Sites header, then click the
URL under the Browse Applications header.

5. On your desktop, click the Contoso.Events - Visual Studio 2013 window.

6. In the Solution Explorer pane, expand the Roles folder.

7. In the Server Explorer pane, expand the Contoso.Events.Worker project.

8. Double-click the WorkerRole.cs file.

9. Locate the Run method.

10. After the check to see if the SourceMessage property of the brokeredMessage variable is null,
locate the try-catch block within that conditional.

11. Locate the target line of code within the try-catch block:

HandleMessage(message);

12. Right-click the target line of code, hover over Breakpoint and click Insert Breakpoint.
13. On your desktop, click the Home - Contoso.Events.Administration window.

14. On the home page for the Administration web application, click the button to go to the list of
events.
15. Click the Sign-In Sheet button for any event in the list.

16. View the sign-in page which notifies you that that sign-in sheet is being generated with the message:
Sign-In Document Generation in Progress.

17. Wait 1 minute for the worker role to receive the queue message.

18. Verify that the breakpoint is hit and execution temporarily pauses.

19. Hit F5 to resume execution of the application


20. Wait 1 minute, then refresh the sign-in sheet page.

21. Click the Sign-In Sheet link to download the sign-in sheet from the server.

22. Close the Internet Explorer window.

Results: After completing this exercise, you will be able to create and consume messages from Azure
Storage Queues.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-10 Developing Microsoft Azure™ Solutions

Exercise 4: Use Service Bus Relay to Connect a WCF Service and Client[s]
 Task 1: Test the Existing WCF Service using a Console Application
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod09\Labfiles\Starter\Relay\Contoso.Events,
and then double-click Contoso.Events.sln.

4. On the Windows Start screen, click Desktop.

5. On the taskbar, click the File Explorer icon.

6. In the Libraries window, navigate to Allfiles (E):\Mod09\


Labfiles\Starter\Relay\Contoso.Events.Lodging.Client, and then double-click
Contoso.Events.Lodging.Client.sln.

7. On your desktop, click the Contoso.Events - Visual Studio 2013 window.

8. In the Solution Explorer pane, expand the On-Premise folder, right-click the
Contoso.Events.Lodging project and then click Set as Startup Project.

9. On the DEBUG menu, click Start Debugging.


10. You will be prompted that the WCF service does not have any metadata. The dialog will ask if you
want to exit the debugging process. Click No.

11. Minimize the WCF Test Client.

12. On your desktop, click the Contoso.Events.Lodging.Client - Visual Studio 2013 window.
13. On the DEBUG menu, click Start Debugging.

14. Verify that the four hotel names are listed.


15. Type any key into the console window to close the window.

16. On your desktop, click the Contoso.Events - Visual Studio 2013 window.

17. On the DEBUG menu, click Stop Debugging.

 Task 2: Modify the WCF Service Endpoints to use Service Bus Relay
1. On your desktop, click the Contoso.Events - Visual Studio 2013 window.
2. In the Solution Explorer pane, expand the On-Premise folder.

3. In the Solution Explorer pane, expand the Contoso.Events.Lodging project.

4. Double-click the App.config file.


5. Locate the system.serviceModel XML element.

6. Locate the services child XML element.

7. Locate the service child XML element.


8. Locate the first endpoint child XML element with a contract value of
Contoso.Events.Models.ILodgingService.

9. Replace the value of the binding attribute with the value: netTcpRelayBinding.
10. Locate the first endpoint child XML element with a contract value of
Contoso.Events.Models.ILodgingService.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-11

11. Replace the value of the address attribute with the value: sb://.

12. Append the address attribute’s value with the name of your namespace.

13. Append the address attribute’s value with the value: .servicebus.windows.net/lodging.

14. Locate the system.serviceModel XML element.


15. Locate the behaviors child XML element.

16. Locate the endpointBehaviors child XML element.


17. Locate the first behavior child XML element with a name value of ServiceBusRelayBehavior:

<behavior name="ServiceBusRelayBehavior">
</behavior>

18. Within the tags of the behavior element, add a transportClientEndpointBehavior element:

<transportClientEndpointBehavior>
</transportClientEndpointBehavior>

19. Within the tags of the transportClientEndpointBehavior element, add a tokenProvider element:

<tokenProvider>
</tokenProvider>

20. Within the tags of the tokenProvider element, add a sharedSecret element with the issuerName
attribute’s value set to owner:

<sharedSecret issuerName="owner" issuerSecret="[key]" />

21. Within the sharedSecret element, remove the value of the issuerSecret attribute.
22. Replace the value of the issuerSecret attribute with your Default Key recorded in the previous task.

 Task 3: Test the Relayed WCF Service using a Console Application


1. In the Solution Explorer pane, expand the On-Premise solution folder, right-click the
Contoso.Events.Lodging project and then click Set as Startup Project.
2. On the DEBUG menu, click Start Debugging.

3. The WCF service will prompt that it does not have any metadata. Click No to continue with the
debugging process.

4. On your desktop, click the Contoso.Events.Lodging.Client - Visual Studio 2013 window.

5. In the Solution Explorer pane, expand the Contoso.Events.Lodging.Client project.

6. Double-click the Program.cs file.

7. Locate the method with the following signature:

private static IEnumerable<Hotel> GetHotels()

8. Remove the line that create a Uri using a static string:

Uri serviceUri = new Uri("net.tcp://localhost:8000/lodging", UriKind.Absolute);

9. Replace the line with a line of code that creates a Uri by invoking the static method
ServiceBusEnvironment.CreateServiceUri with the protocol, namespace and relative name as it’s
parameters:
MCT USE ONLY. STUDENT USE PROHIBITED
L9-12 Developing Microsoft Azure™ Solutions

Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", "[namespace]",


"lodging");

10. On the previous line of code, update the parameters for the CreateServiceUri method by replacing
the “[namespace]” string with your Service Bus namespace.

11. Remove the following line:

new NetTcpBinding(),

12. Replace the line with a line of code that creates a new instance of the NetTcpRelayBinding class:

new NetTcpRelayBinding(),

13. On the next line, create an instance of the TransportClientEndpointBehavior class.

TransportClientEndpointBehavior endpointBehavior = new


TransportClientEndpointBehavior();

14. On the next line, set the TransportClientEndpointBehavior variable’s TokenProvider property to
the result of an invocation of the TokenProvider.CreateSharedSecretTokenProvider static method.

endpointBehavior.TokenProvider =
TokenProvider.CreateSharedSecretTokenProvider("owner", "[key]");

15. On the previous line of code, update the parameters for the CreateSharedSecretTokenProvider
method by replacing the “[key]” string with the key for your Service Bus namespace and the
“owner” string with the issuer for your Service Bus namespace (this is likely the same value).
16. Add the new instance of the TransportClientEndpointBehavior to the EndpointBehaviors
collection property of the Endpoint.

cf.Endpoint.EndpointBehaviors.Add(endpointBehavior);

17. On the DEBUG menu, click Start Debugging.


18. Verify that the hotels are listed.

19. Type any key into the console window to close the window.

 Task 4: Updating the Cloud Web Application to Connect to the Relayed WCF Service
1. Locate the method with the following signature.

private static IEnumerable<Hotel> GetHotels()

2. Select the method signature and body.

3. Copy the entire method by right-clicking the selection and clicking Copy.

4. On your desktop, click the Contoso.Events - Visual Studio 2013 window.


5. On the DEBUG menu, click Stop Debugging.

6. In the Solution Explorer pane, expand the Shared folder.

7. In the Solution Explorer pane, expand the Contoso.Events. ViewModels project.


8. Double-click the HotelsViewModel.cs file.

9. Locate the method with the following signature.


MCT USE ONLY. STUDENT USE PROHIBITED
L9-13

private static IEnumerable<Hotel> GetHotels()

10. Select the entire method signature and body.

11. Paste the entire method by right-clicking the selection and clicking Paste.

 Task 5: Debug the Cloud Web Application


1. In the Solution Explorer pane, right-click the Contoso.Events solution and then click Properties.

2. In the Contoso.Events Property Pages dialog, do the following:


3. Make sure that CommonProperties => Startup Project is selected in the navigation menu on the
left.

4. Select the Multiple startup projects radio button.

5. For Contoso.Events.Cloud, set the Action to Start without debugging.

6. For Contoso.Events.Lodging, set the Action to Start without debugging.

7. For Contoso.Events.Management, set the Action to None.


8. Ensure that all of the remaining projects have their Action set to None.

9. Click OK to close the dialog.

10. On the Windows Start screen, type Azure Storage Emulator.


11. Click the Windows Azure Storage Emulator – v3.3 tile.

12. Switch back to the Contoso.Events – Visual Studio 2013 window.

13. In the Solution Explorer pane, right-click the Contoso.Events.Data.Generation project, highlight
Debug and then click Start New Instance.

14. Close the Contoso.Events – Microsoft Visual Studio application.


15. In the Windows Start Screen, located the Visual Studio 2013 tile, right-click and select the Run as
Administrator option.

Note: You may have to use the down arrow to locate the Visual Studio 2013 tile in your
Start screen. Once you launch the application in the Administrator context, you may see the UAC
prompt. Select Yes to continue.

16. On the FILE menu, hover over the Open option and then click Project/Solution.
17. In the Open Project dialog, do the following:

18. Navigate to Allfiles (E):\Mod09\Labfiles\Starter\Relay\Contoso.Events.


19. Click the Contoso.Events Microsoft Visual Studio Solution file.

20. Click the Open button.

21. On the DEBUG menu, click Start without Debugging.


22. You may also be prompted that the WCF service does not have any metadata. When asked whether
you would like to exit the service, click No.

23. On the home page of the web application, click any event.

24. On the event details page, click the Register Now button.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-14 Developing Microsoft Azure™ Solutions

25. Fill in the Registration form with any arbitrary values.

26. Click Submit.

27. Observe that the Registration Confirmation web page shows a list of hotels.

28. Close the Internet Explorer application.


29. Switch to the Contoso.Events – Visual Studio window.

30. On the DEBUG menu, click Stop Debugging.


31. Close the Contoso.Events - Visual Studio application.

Results: After completing this exercise, you will be able to connect existing WCF applications to clients
using Service Bus Relay.
MCT USE ONLY. STUDENT USE PROHIBITED
L10-1

Module 10: Automating Integration with Azure Resources


Lab: Automating the Creation of a Test
Environment using PowerShell
Exercise 1: Prepare Azure PowerShell Environment
 Task 1: Install the Azure PowerShell Module
1. On the Windows Start screen, click Internet Explorer.

2. In the Address bar, type in the following url and press Enter:

o http://go.microsoft.com/fwlink/p/?linkid=320376

Note: You will notice that Internet Explorer blocks the download popup. You will need to
view the yellow warning message at the bottom of the Internet Explorer window, click Options
for this Site and then click Always Allow. This will allow you to view popups and downloads
without any restriction.

3. At the bottom of the Internet Explorer window, click the Run button in the download dialog.
4. Verify that the package is named Windows Azure PowerShell.

5. Click Install.
6. Click I Accept.

Note: The download and installation of the Module takes about 5 minutes.

7. Wait for the Web Platform Installer process to complete.

8. In the Web Platform Installer 5.0 window, click Finish.

9. Click Exit.

 Task 2: Import your Azure Subscription using a Publish Setting File


1. On the Windows Start screen, click the down arrow to see all applications and then click Windows
Azure PowerShell.
2. Switch to the Windows Azure PowerShell window.

3. To get your publish settings file, type the following command in the console and press Enter:

Get-AzurePublishSettingsFile

4. In the Internet Explorer tab that opens, do the following:

5. Enter your Microsoft Account e-mail.


6. Click the Continue button.

7. Enter your Microsoft Account password.

8. Click the Sign In button.


MCT USE ONLY. STUDENT USE PROHIBITED
L10-2 Developing Microsoft Azure™ Solutions

9. At the bottom of the Internet Explorer window, click the arrow to the right of the Save button and
then click Save As in the download dialog.

10. In the Save As dialog that appears, do the following:


11. Navigate to the AllFiles (E:) E:\Mod10\Labfiles directory.

12. In the File Name dialog, provide the value 20532.

13. In the Save as type dialog, ensure that the PUBLISHSETTINGS File option is selected.

14. Click the Save button.

15. Close the Internet Explorer application.

16. Switch to the Windows Azure PowerShell application.


17. To import your publish settings file, type the following command in the console and press Enter:

Import-AzurePublishSettingsFile E:\Mod10\Labfiles\20532.publishsettings

18. To view your account details, type the following command in the console and press Enter:

Get-AzureAccount

Note: If you have multiple Azure subscriptions, you can use Select-AzureSubscription to
select the correct subscription to use.
If your Azure subscription was provided by a Learning Partner it may be an auto-generated
account without any “details”. In this case, this command would return an empty result.

Results: After completing this exercise, you will be able to setup a development environment to use
PowerShell for Azure service automation.
MCT USE ONLY. STUDENT USE PROHIBITED
L10-3

Exercise 2: Use PowerShell to Create and Access a Web Site Instance


 Task 1: Create a new Web Site Instance using PowerShell
1. To create a new Website, type the following command in the console and press Enter providing the
unique name selected for your website:

New-AzureWebsite [Unique Name]

Note: It is possible to get an error message that your Website’s name is not unique. If
this occurs, just select a new name until your Website is created.

2. To get your list of Websites, type the following command in the console and press Enter:

Get-AzureWebsite

3. To get the details for your new Website, type the following command in the console and press Enter
providing the unique name selected for your website:

Get-AzureWebsite –Name [Unique Name]

4. Record the hostname value from the list of key-value pairs generated by the previous command.
5. To view the new Website in Internet Explorer, type the following command in the console and press
Enter:

Invoke-Expression “cmd.exe /C start http://[Host Name]”

6. Verify that new Website is running.


7. Close the Internet Explorer application.

8. Switch to the Windows Azure PowerShell application.

 Task 2: Remove a Web Site Instance using PowerShell


1. To stop your new Website, type the following command in the console and press Enter providing the
unique name selected for your website:

Stop-AzureWebsite –Name [Unique Name]

2. To get your list of Websites, type the following command in the console and press Enter:

Get-AzureWebsite

3. To remove your new Website, type the following command in the console and press Enter providing
the unique name selected for your website:

Remove-AzureWebsite –Name [Unique Name]

4. Type Y to indicate that you want to remove the website and then press Enter.
5. To verify that your Website was removed, type the following command in the console and press
Enter providing the unique name selected for your website. The result should be empty:

Get-AzureWebsite –Name [Unique Name]


MCT USE ONLY. STUDENT USE PROHIBITED
L10-4 Developing Microsoft Azure™ Solutions

Results: After completing this exercise, you will be able to use PowerShell to manage instances of an
Azure service.
MCT USE ONLY. STUDENT USE PROHIBITED
L10-5

Exercise 3: Use a Resource Template to Create Multiple Pre-Configured


Resources
 Task 1: Switch to the Azure Resource Manager PowerShell Modules
1. To switch modules, type the following command in the console and press Enter:

2. Switch-AzureMode AzureResourceManager

 Task 2: Import your Azure Subscription using Azure Active Directory


1. To login to Azure, type the following command in the console and press Enter:

Add-AzureAccount

2. In the Sign in to Windows Azure dialog, do the following:

3. Enter your Microsoft Account e-mail.


4. Click the Continue button.

5. Enter your Microsoft Account password.

6. Click the Sign In button.


7. To view your account details, type the following command in the console and press Enter:

Get-AzureAccount

Note: If you have multiple Azure subscriptions, you can use Select-AzureSubscription to
select the correct subscription to use.

 Task 3: Create a Resource Group using PowerShell


1. To view the description of the resource group template, type the following command in the console
and press Enter:

Get-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSiteSQLDatabase.0.2.0-


preview

2. To create a new instance of a resource group from the template, type the following command in the
console and press Enter:

New-AzureResourceGroup –Name rga20532a –Location “West Us” -GalleryTemplateIdentity


Microsoft.WebSiteSQLDatabase.0.2.0-preview

3. To supply the parameters for the template, do the following:

4. For the siteName prompt, supply the value rs20532a[Your Name Here] and press Enter.

5. For the hostingPlanName prompt, supply the value rp20532a[Your Name Here] and press Enter.
6. For the siteLocation prompt, supply the value West US and press Enter.

7. For the serverName prompt, supply the value rv20532a[Your Name Here] and press Enter.

8. For the serverLocation prompt, supply the value West US and press Enter.
9. For the administratorLogin prompt, supply the value testuser and press Enter.

10. For the administratorLoginPassword prompt, supply the value TestPa$$w0rd and press Enter.
MCT USE ONLY. STUDENT USE PROHIBITED
L10-6 Developing Microsoft Azure™ Solutions

11. For the databaseName prompt, supply the value rd20532a[Your Name Here] and press Enter.

Note: Please wait for the provisioning process to complete. Status messages will be
displayed periodically and a final details message will be shown when provisioning is complete.

12. To get the details for your new Resource Group, type the following command in the console and
press Enter providing the unique name selected for your website:

Get-AzureResourceGroup –ResourceGroupName rga20532a

13. To get the details for your new Website, type the following command in the console and press Enter
providing the unique name selected for your website:

Get-AzureResource -Name rs20532a[Your Name Here] -ResourceGroupName rga20532a -


ResourceType "Microsoft.Web/sites" -ApiVersion 2014-04-01

14. Record the single value in the hostNames array from the JSON data generated by the previous
command.
15. To view the new Website in Internet Explorer, type the following command in the console and press
Enter:

Invoke-Expression “cmd.exe /C start http://[Host Name]”

16. Verify that new Website is running.


17. Close the Internet Explorer application.

18. Switch to the Windows Azure PowerShell application.

 Task 4: Remove the Resource Group using PowerShell


1. To remove your new Resource Group, type the following command in the console and press Enter:

Remove-AzureResourceGroup –Name rga20532a

2. Type Y to indicate that you want to remove the website and then press Enter.

Note: Since removing a Resource Group involves removing multiple resources, this process
can take anywhere from 10-15 minutes.

Results: After completing this exercise, you will be able to use Azure to interact with the Resource
Manager, resource groups and resource group templates.
MCT USE ONLY. STUDENT USE PROHIBITED
L11-1

Module 11: Implementing Security in Web Applications


using Azure
Lab: Integrating Azure Active Directory with
the Events Administration Portal
Exercise 1: Create an Azure AD Directory
 Task 1: Login to the Azure Management Portal

Note: For this lab, we will use the Management Portal since the functionality to create new
Azure Active Directory domains is not available in the Preview Portal.

1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://manage.windowsazure.com

1. Enter your Microsoft Account e-mail and password and then click Sign In.

 Task 2: Create a Directory using the Management Portal


1. In the navigation pane on the left side, scroll down and click ACTIVE DIRECTORY.
2. Click the DIRECTORY tab at the top of the page.

3. At the bottom of the screen, click the ADD DIRECTORY button.


4. In the Add Directory dialog, do the following:
5. In the Directory list, select the value Create new directory.

6. In the Name dialog box, provide the value 20532.


7. In the Domain Name dialog box, provide the value ad20532[Your Name].
8. In the Country or Region list, select your current location.

9. Click the checkmark button to add the directory.

 Task 3: Create a Global Administrator in the Directory


1. In the list of directories, click the name of the directory 20532.

2. Click the USERS tab at the top of the page.

3. At the bottom of the screen, click the ADD USER button.


4. In the ADD USER dialog, do the following:

5. In the TYPE OF USER list, select the value New user in your organization.

6. In the USER NAME dialog box, provide the value admin.


7. In the DOMAIN list, ensure that your only domain (ad20532[Your Name]) is selected.

8. Click the right arrow to move to the next step in the wizard.

9. In the FIRST NAME dialog box, provide the value Admin.


10. In the LAST NAME dialog box, provide the value User.
MCT USE ONLY. STUDENT USE PROHIBITED
L11-2 Developing Microsoft Azure™ Solutions

11. In the DISPLAY NAME dialog box, provide the value Admin User.

12. In the ROLE list, select the value Global Administrator.

13. In the Alternate Email Address dialog box, provide the value example@contoso.com.

14. Ensure the Enable Multi-Factor Authentication checkbox is unselected.


15. Click the right arrow to move to the next step in the wizard.

16. On the Get Temporary Password screen, click the Create button to create the user.
17. Record the temporary password that was generated for the user.

18. Click the checkmark button to complete the wizard.

 Task 4: Create a User in the Directory


1. At the bottom of the screen, click the Add User button.

2. In the Add User dialog, do the following:


3. In the Type of User list, select the value New user in your organization.

4. In the User Name dialog box, provide the value standard.


5. In the Domain list, ensure that your only domain (ad20532[Your Name]) is selected.

6. Click the right arrow to move to the next step in the wizard.

7. In the First Name dialog box, provide the value Standard.


8. In the Last Name dialog box, provide the value User.
9. In the Display Name dialog box, provide the value Standard User.

10. In the Role list, select the value User.

11. Ensure the Enable Multi-Factor Authentication checkbox is unselected.


12. Click the right arrow to move to the next step in the wizard.

13. On the Get Temporary Password screen, click the Create button to create the user.
14. Record the temporary password that was generated for the user.
15. Click the checkmark button to complete the wizard.

Results: After completing this exercise, you will be able to create an Azure AD Directory and populate
that directory with users.
MCT USE ONLY. STUDENT USE PROHIBITED
L11-3

Exercise 2: Secure an Existing ASP.NET Web Application


 Task 1: Add the Authorize Attribute to the HomeController
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod11\Labfiles\Starter\Contoso.Events, and
then double-click Contoso.Events.sln.

4. In the Solution Explorer pane, expand the Administration folder.

5. Expand the Contoso.Events.Management.Old project.

6. Expand the Controllers folder.

7. Double-click the HomeController.cs file.


8. Locate the class definition near the top of the file:

public class HomeController : Controller

9. In the line above the class definition add the Authorize attribute:

[Authorize]

10. Save the HomeController.cs file.

 Task 2: Debug the Web Application


1. In the Solution Explorer pane, right-click the Contoso.Events.Management.Old project and then
click Set as Startup Project.
2. On the DEBUG menu, click Start Debugging.

3. Wait for Internet Explorer to open.

4. Verify that the website returns a 401 – Unauthorized error message.


5. Switch back to the Contoso.Events – Microsoft Visual Studio window.

6. On the DEBUG menu, click Stop Debugging.

Results: After completing this exercise, you will be able to use MVC to require a user to be logged in
before accessing a controller or action.
MCT USE ONLY. STUDENT USE PROHIBITED
L11-4 Developing Microsoft Azure™ Solutions

Exercise 3: Integrate Azure AD with ASP.NET Identity


 Task 1: Repair the IIS 8.0 Express Installation

Note: The original IIS 8.0 Express installation with Visual Studio 2013 Update 3 can be
corrupted when you image your machine and recreate the machine with a new user. IIS Express
depends on configuration files that are located in your user’s Documents folder. When the
machine is imaged, the old user account is lost and a new user account is created when you
create a new VM from the image. Repairing the installation will create the configuration files for
your new user.

1. In the Windows start screen, click the down arrow and then click the Run tile.
2. In the Run dialog, do the following:

3. In the Open dialog box, provide the value appwiz.cpl.

4. Click the OK button.


5. In the Programs and Features window, do the following:

6. Locate the IIS 8.0 Express item in the list of Currently installed programs.

7. Right-click the IIS 8.0 Express item and then click Repair.
8. Wait for the Repair process to complete. The process is complete when the popup window closes.

9. Close the Programs and Features window.

 Task 2: Create a New Management Web Application using Azure AD as the Identity
Provider
1. In the Solution Explorer pane, right-click the Administration solution folder, hover over Add and
then click New Project….

2. In the Add New Project dialog, do the following:

3. Expand Installed, Visual C# Items, and then click Web.


4. Click the ASP.NET Web Application project type.

5. In the Name dialog box, specify the value Contoso.Events.Management.

6. Ensure the Location dialog box has the value E:\Mod11\Labfiles\Starter\Contoso.Events.


7. Click OK.

8. In the New ASP.NET Project – Contoso.Events.Management dialog, do the following:


9. Click the MVC template.

10. Ensure the Microsoft Azure – Host in the Cloud checkbox is unselected.

11. Leave the remaining fields to their default values.

12. Click the Change Authentication button.

13. In the Change Authentication dialog, select the Organizational Accounts option.

14. In the Domain dialog box, provide the value ad20532[Your Name].onmicrosoft.com.

15. Leave the remaining fields to their default values.


MCT USE ONLY. STUDENT USE PROHIBITED
L11-5

16. Click the OK button.

Note: The screens shown during login may vary depending on whether you have logged in
using that domain lately or have set up IE to remember a specific login.

17. Login using the Admin User account (admin@ad20532[Your Name].onmicrosoft.com) and
temporary password created earlier in this lab.

18. In the Change Password dialog, update your password to Pa$$w0rd.

19. Back in the New ASP.NET Project – Contoso.Events.Management dialog, click the OK button.

20. In the Solution Explorer pane, expand the Administration folder.

21. Right-click the Contoso.Events.Management project and click Set as StartUp Project.

22. In the Solution Explorer pane, expand the Administration folder.


23. Right-click the Contoso.Events.Management project, hover over Add and then click Reference….

24. In the Reference Manager – Contoso.Events.Management dialog, do the following:


25. On the left, expand the Solution tab and then click the Projects option.

26. Double-click the Contoso.Events.Models reference.

27. Double-click the Contoso.Events.ViewModels reference.


28. Click the OK button.
29. In the Solution Explorer pane, expand the Administration folder.

30. Expand the Contoso.Events.Management.Old project.

31. Copy the following folders:


o App_Start

o Content
o Controllers

o Fonts

o Scripts

o Views

Note: You can copy all of the folders at once by holding the Shift key and clicking the
App_Start folder and then the Views folder. This will select all six folders at the same time. You
can then use the context menu or Ctrl+C shortcut keys to copy the folders.

32. Paste all of the copies folders into the Contoso.Events.Management project.
33. When prompted to Merge Folders, click Apply to all items and then click Yes.

34. When prompted with Destination File Exists, click Apply to all items and then click Yes.
MCT USE ONLY. STUDENT USE PROHIBITED
L11-6 Developing Microsoft Azure™ Solutions

 Task 3: Verify that the Management Web Application Requies Login using a
Organizational Account
1. In the Solution Explorer pane, right-click the Contoso.Events.Management project and click Set as
Startup Project.

2. On the DEBUG menu, click Start Debugging.


3. When the Internet Explorer browser opens, you will see a message stating that There is a problem
with this website’s security certificate.

4. Click the Continue to this website (not recommended) option.

5. Login using the Standard User account and temporary password created earlier in this lab.
6. In the Change Password dialog, update your password to Pa$$w0rd.

7. View the homepage for the Contoso.Events.Management web application.


8. Click the Go To Events List button to view the list of events.

Results: After completing this exercise, you will be able to use an Azure AD domain with the ASP.NET
Identity framework.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-1

Module 12: Deploying Web Applications to Azure


Lab: Deploying the Events Web Application
to Azure
Exercise 1: Create the Target Azure Services for Deployment
 Task 1: Login to the Azure Preview Portal
1. On the Start screen, click the Internet Explorer tile.

2. Browse to https://portal.azure.com

3. Enter your Microsoft Account e-mail

4. Click the Continue button


5. Enter your Microsoft Account password

6. Click the Sign In button.

 Task 2: Create a SQL Database Instance


1. In the navigation pane on the left side, scroll down and click Browse.
2. In the Browse blade that appears, click SQL databases.

3. In the bottom left corner of the portal, click the New button.
4. In the New blade that appears, click the SQL Database link.
5. In the SQL database blade that appears, do the following:

6. In the Name dialog box, provide the value dp20532a[Your Name Here].
7. Click the Pricing Tier link.
8. In the Recommended pricing tier blade that appears, select the Web option.

9. Click the Select button to close the blade.

10. In the SQL database blade, click the Server link.


11. In the Server blade that appears, click the Create a new server link.

12. In the New Server blade that appears, locate the Server Name dialog box.
13. In the Server Name dialog box, provide the value sp20532a[Your Name Here].

14. In the Server Admin Login dialog box, provide the value testuser.

15. In the Password dialog box, provide the value TestPa$$w0rd.


16. In the Confirm Password dialog box, provide the value TestPa$$w0rd.

17. Click the Location link.

18. In the Location blade that appears, select the region that is closes to your location.
19. In the New server blade, click the OK button.
20. In the SQL database blade, click the Create button to create the SQL Database and Server.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-2 Developing Microsoft Azure™ Solutions

Note: Once your SQL Database instance is created, a tile will appear on your Startboard
(home screen) to access the blade for your database.

21. Click the tile for the new SQL Database on the Startboard.
22. In the dp20532a[Your Name Here] blade that appears, click the Properties tile.

23. In the Properties blade that appears, click the Show database connection strings link.

24. In the Database connection strings blade that appears, locate the ADO.NET dialog box.
25. Copy the connection string.

26. On the Start screen, type Notepad.

27. Click the Notepad tile.

28. Paste the connection string in the Notepad application.

29. In the Notepad application, replace the text {Your_password_here} with the text TestPa$$w0rd.

30. Switch back to the Microsoft Azure - Internet Explorer window.

31. Close the dp20532a[Your Name Here] blade by clicking the x button at the top of the blade.

 Task 3: Create a Storage Instance


1. In the navigation pane on the left side, scroll down and click Browse.

2. In the Browse blade that appears, click Storage.

3. In the Storage blade that appears, view your list of Storage instances.
4. At the bottom left corner of the screen, click New.

5. In the New blade that appears, click the Storage link near the bottom.

6. In the Storage account blade that appears, do the following:


7. In the Storage dialog box, provide the value sp20532a[Your Name Here].

8. Click the Location link.

9. In the Location blade, select the region closest to your current location.
10. Click the Pricing Tier link.

11. In the Recommended Pricing Tiers blade, select the L1 LRS option for local redundancy.

12. Click the Select button.


13. Click the Create button.

14. Note: Once your Storage instance is created, a tile will appear on your Startboard (home
screen) to access the blade for your storage instance.

15. Click the tile for the new Storage on the Startboard.

16. In the sp20532a[Your Name Here] blade that appears, click the Properties tile.

17. In the Properties blade that appears, copy the Name at the top of the blade.

18. Paste the Name into the Notepad application.

19. Close the Properties blade by clicking the x button at the top of the blade.

20. In the sp20532a[Your Name Here] blade, click the Keys tile.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-3

21. In the Manage keys blade that appears, copy the Primary Access Key.

22. Paste the Primary Access Key in the Notepad application.

23. Switch back to the Microsoft Azure - Internet Explorer window.

24. Close the sp20532a[Your Name Here] blade by clicking the x button at the top of the blade.

 Task 4: Switch to the Azure Management Portal


1. On the Startboard (home screen), click the Azure Portal tile.

2. Switch to the Windows Azure tab.

 Task 5: Create a Service Bus Namespace


1. In the navigation pane on the left side, scroll down and click Service Bus.

2. At the bottom of the screen, click the Create button.

3. In the Create a Namespace dialog, do the following:

4. In the Namespace Name dialog box, provide the value sp20532a[Your Name].
5. In the Region list, select the region that is closest to your location.

6. Click the checkmark button to create your namespace.

Note: Once your namespace is created, an item will appear on the list of Service Bus
namespaces.

7. Click the name of the newly created Service Bus namespace.

8. Click the Connection Information button at the bottom of the page.


9. Locate the ACS Connection String dialog box.

10. Copy the connection string and paste the connection string in the Notepad application.

11. Switch back to the Windows Azure - Internet Explorer window.


12. Close the Access Connection Information dialog by clicking the checkmark button in the
Management Portal.

Results: After completing this exercise, you will be able to create services that will be used for your
deployed web application.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-4 Developing Microsoft Azure™ Solutions

Exercise 2: Manage Configuration Settings for a Cloud Web Application


 Task 1: Modify the Cloud Configuration Settings
1. On the Windows Start screen, click Desktop.

2. On the taskbar, click the File Explorer icon.


3. In the Libraries window, navigate to Allfiles (E):\Mod12\Labfiles\Starter\Contoso.Events, and
then double-click Contoso.Events.sln.

4. In the Solution Explorer pane, expand the Contoso.Events.Cloud project, expand the Roles folder
and then double-click the Contoso.Events.Worker role.

5. On the left-hand side of the screen, click the Settings tab.


6. At the top of the page, ensure that the Service Configuration list is set to the All Configurations
value.

7. Find the setting with the name Microsoft.ServiceBus.ConnectionString.

8. Ensure that the setting has a type of String.


9. In the Value dialog box, provide the ACS Connection String recorded in the previous task.

10. Locate the Service Configuration list at the top of the page.
11. Select the value Cloud.
12. Locate the setting with the name Microsoft.WindowsAzure.Storage.ConnectionString.

13. In the Value dialog box, click the button on the right hand side with three ellipsis.

Note: If you have not previously saved your Microsoft Account credentials, you will be
required to login at this point.

14. In the Create Storage Connection String dialog, do the following:


15. Select the Manually entered credentials radio button.

16. In the Account name dialog box, provide the Storage Account Name value recorded in the
previous task.

17. In the Account key dialog box, provide the Primary Access Key value recorded in the previous task.

18. Leave the Connection option to the default setting: Use HTTPS (Recommended).

19. Click OK.

20. Copy the connection string from the Value dialog box.

21. Locate the setting with the name


Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString.
22. Paste the copied value into the Value dialog box.

23. Locate the setting with the name Microsoft.WindowsAzure.Storage.ConnectionString.

24. Copy the Value from the setting.

25. Paste the copied text to Notepad.

26. Locate the Service Configuration list at the top of the page.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-5

27. Select the value Local.

28. Verify that both of the storage settings have a value of UseDevelopmentStorage=true.

29. In the Solution Explorer pane, expand the Contoso.Events.Cloud project, expand the Roles folder
and then double-click the Contoso.Events.Web role.

30. On the left-hand side of the screen, click the Settings tab.

31. Locate the Service Configuration list at the top of the page.

32. Select the value Cloud.

33. Locate the setting with the name Microsoft.WindowsAzure.Storage.ConnectionString.

34. In the Value dialog box, click the button on the right hand side with three ellipsis.

35. In the Create Storage Connection String dialog, do the following:


36. Select the Manually entered credentials radio button.

37. In the Account name dialog box, provide the Storage Account Name value recorded in the
previous task.
38. In the Account key dialog box, provide the Primary Access Key value recorded in the previous task.

39. Leave the Connection option to the default setting: Use HTTPS (Recommended).

40. Click OK.


41. Copy the connection string from the Value dialog box.

42. Locate the setting with the name


Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString.

43. Paste the copied value into the Value dialog box.

44. Locate the Service Configuration list at the top of the page.
45. Select the value Local.
46. Verify that both of the storage settings have a value of UseDevelopmentStorage=true.

 Task 2: Modify the Web.config Transformation File for the Administration Project
1. In the Solution Explorer pane, expand the Administration solution folder, expand the
Contoso.Events.Management project, expand the Web.config files and then double-click the
Web.Debug.config file.

2. Locate the appSettings xml element.

3. Locate the add child xml element with a key attribute of


Microsoft.WindowsAzure.Storage.ConnectionString.

4. Update the value attribute of the element to the storage connection string recorded in the previous
task.
5. Locate the appSettings xml element.

6. Locate the add child xml element with a key attribute of Microsoft.ServiceBus.ConnectionString.

7. Update the value attribute of the element to the ACS Connection String recorded in the first task.
8. Locate the connectionStrings xml element.

9. Locate the add child xml element with a name attribute of EventsContextConnectionString.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-6 Developing Microsoft Azure™ Solutions

10. Update the connectionString attribute of the element to the ADO.NET Connection String recorded
in the first task.

 Task 3: Modify the app.config File for the Worker Role Project
1. In the Solution Explorer pane, expand the Roles solution folder, expand the
Contoso.Events.Worker project and then double-click the app.config file.

2. Locate the connectionStrings xml element.

3. Locate the add child xml element with a name attribute of EventsContextConnectionString.

4. Update the connectionString attribute of the element to the ADO.NET Connection String recorded
in the first task.

 Task 4: Modify the Web.config Transformation File for the Web Role Project
1. In the Solution Explorer pane, expand the Roles solution folder, expand the Contoso.Events.Web
project, expand the Web.config file and then double-click the Web.Release.config file.
2. Locate the connectionStrings xml element.

3. Locate the add child xml element with a name attribute of EventsContextConnectionString.
4. Update the connectionString attribute of the element to the ADO.NET Connection String recorded
in the first task.

Results: After completing this exercise, you will be able to make changes to your web applications so that
they will use different settings and connection strings after they are deployed to the cloud.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-7

Exercise 3: Deploy the Web Applications to Azure


 Task 1: Deploy the Cloud Service Project to a Cloud Service Production Environment
1. In the Solution Explorer pane, right-click the Contoso.Events.Cloud project and then click Publish.

2. On the Sign in page of the wizard, select your subscription.


3. Click the Next button to move to the Settings page of the wizard.

4. Locate the Cloud Service list and select the Create New value.

5. In the Create Cloud Service dialog, do the following:


6. In the Name dialog box, provide the value cs20532[Your Name].

7. In the Region or Affinity Group dialog box, select the region that is closest to your location.

8. Click the Create button.


9. In the Environment list, select the Production value.

10. In the Build configuration list, select the Release value.

11. In the Service configuration list, select the Cloud value.


12. Leave the remaining fields set to their default values.

13. Click the Publish button

 Task 2: Deploy the ASP.NET Web Application Project to a Web Site Instance
1. On the View menu, click Server Explorer.
2. Locate the Windows Azure node and click the arrow immediately to the left.

3. Right-click the Web Sites node under the Windows Azure node and click “Create New Site”.
4. In the Site name dialog box, create a unique name for your website using this format:
ws20532[Your Name].

5. In the Region list, select the region that is closest to your location.

6. In the Database server list, ensure that the No database value is selected.
7. Click Create.

8. In the Solution Explorer pane, expand the Administration solution folder, right-click the
Contoso.Events.Management project and then click Publish.

9. On the Profile page of the wizard, select Windows Azure Web Sites as the publish target.

10. In the Select Existing Web Site dialog, do the following:

11. Select your new website from the Existing Web Sites list with the prefix ws20532.

12. Click OK.

13. You will be prompted with a dialog to save changes to your current publish profile. Click Yes to save.

14. On the Connection page of the wizard, click the Next button to move to the Settings page of the
wizard.

15. On the Settings page of the wizard, change the Configuration list’s value to Debug – Any CPU.

16. Click the Publish button.


MCT USE ONLY. STUDENT USE PROHIBITED
L12-8 Developing Microsoft Azure™ Solutions

17. After the publish process is complete, verify that Internet Explorer opens up and navigates to the new
website.

 Task 3: Verify that the Application was Successfully Published


1. In Internet Explorer, view the Contoso Events Administration homepage and then click the Go to
Events List button.

2. Verify that there are events listed with no registrants.

3. Close the Internet Explorer application.

Results: After completing this exercise, you will be able to deploy projects to both Azure Web Sites and
Cloud Services.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-9

Exercise 4: Monitor the Web Applications in Azure


 Task 1: View Streaming Logs for the Administration Application
1. On the View menu, click Server Explorer.

2. Locate the Windows Azure node and click the arrow immediately to the left.
3. Expand the Web Sites node under the Windows Azure node.

4. Right-click the website node beginning with the prefix ws20532 and then click View Settings.

5. Locate the Application Logging (File System) setting.


6. Change the value in the list from Off to Verbose.

7. Click the Save button at the top of the page.

8. Locate the WebSite node in Server Explorer beginning with the prefix ws20532.
9. Right-click the website node beginning with the prefix ws20532 and then click View Streaming
Logs.

10. Locate the WebSite node in Server Explorer beginning with the prefix ws20532.
11. Right-click the website node beginning with the prefix ws20532 and then click View in Browser.

12. In Internet Explorer, view the Contoso Events Administration homepage and then click the Go to
Events List button.

13. Switch back to the Contoso.Events – Microsoft Visual Studio window.

14. Verify that the Console pane has two entries, one from viewing the Index page of the website and
one from viewing the Events page of the website.
15. Close the Internet Explorer application.

16. Switch to the Contoso.Events – Visual Studio window.


17. On the DEBUG menu, click Stop Debugging.

18. Close the Contoso.Events - Visual Studio application.

Results: After completing this exercise, you will be able to view a live stream of the Trace logs for an
Azure Web Site.
MCT USE ONLY. STUDENT USE PROHIBITED
L12-10 Developing Microsoft Azure™ Solutions
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes
MCT USE ONLY. STUDENT USE PROHIBITED
Notes