Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Learning Microsoft Azure
Learning Microsoft Azure
Learning Microsoft Azure
Ebook789 pages5 hours

Learning Microsoft Azure

Rating: 4 out of 5 stars

4/5

()

Read preview

About this ebook

This book guides you through the process of building a Microsoft Azure system based around a case study for an industrial bakery with three business domains. Starting with the system design and selection of the correct Azure services, the book progresses by building the system in scalable, decoupled tiers. The book will teach you how to implement a scalable architecture using Azure Service Bus topics, allowing customer orders to be sent between decoupled business domains and processed by scalable worker roles. Azure Active Directory is implemented across all internal systems in the case study including websites, client applications, and mobile applications to create a unified authentication experience.

This book will take you through the processes of developing, deploying, and maintaining Microsoft Azure hosted systems.

LanguageEnglish
Release dateOct 16, 2014
ISBN9781782173380
Learning Microsoft Azure

Related to Learning Microsoft Azure

Related ebooks

Computers For You

View More

Related articles

Reviews for Learning Microsoft Azure

Rating: 3.8 out of 5 stars
4/5

5 ratings1 review

What did you think?

Tap to rate

Review must be at least 10 words

  • Rating: 3 out of 5 stars
    3/5
    Well structured but an anti-climax without demonstrating the final solution. Perhaps add a youtube link ?

Book preview

Learning Microsoft Azure - Geoff Webber-Cross

Table of Contents

Learning Microsoft Azure

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Instant updates on new Packt books

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Getting Started with Microsoft Azure

An overview of cloud computing

Microsoft Azure overview

Selecting a Microsoft Azure solution

Infrastructure capabilities

Platform capabilities

Cost

Decision flow diagrams

Administration of Microsoft Azure systems

Choosing a subscription

Creating a Microsoft Azure account

Adding a subscription

Exploring the portal

The top toolbar

The side toolbar

The bottom toolbar

Examining Microsoft Azure Services

Compute services

Websites

Virtual machines

Mobile services

Cloud services

Data services

SQL Server Database

Storages

HDInsight

Cache

Recovery services

App services

Media services

Service Bus

Visual Studio Online

BizTalk Services

Scheduler

Active Directory (AD)

Network services

Virtual Network

Traffic Manager

Summary

Questions

Answers

2. Designing a System for Microsoft Azure

Designing scalable and resilient systems

Systems architecture

A case study of a small business system

System requirements

Identifying subsystems

Customer website design

Administration system design

System integration

Identifying critical systems

Selecting services

Conclusion of the small business case study

A case study of an enterprise system – Azure Bakery

System requirements

Sales requirements

Production requirements

Supply requirements

Identifying subsystems

Sales subsystems

Production subsystems

Supply subsystems

System design

System design – the sales customer phone app

System design – sales order processor

Sales system integration

Identifying critical services

Selecting Microsoft Azure Services

Selecting common services

Messaging services

Authentication

Selecting sales services

Selecting production services

Selecting supply services

Conclusion of an enterprise system case study – Azure Bakery

Designing platform environments

Common environment roles

Example environment sets

Using website deployment slots

Using cloud service staging environments

Summary

Questions

Answers

3. Starting to Develop with Microsoft Azure

Preparing our development environment

Setting up software

Mobile development

The Microsoft Azure SDK

Checking for Visual Studio updates

Creating a website

Configuring a website in the portal

Creating a Visual Studio Online project

Creating a Visual Studio Online account

Creating a Visual Studio Online project

Setting up continuous deployment

Adding a solution to source control

Configuring continuous deployment

Examining the build definition

Setting up alerts

Summary

Questions

Answers

4. Creating and Managing a Windows Azure SQL Server Database

Creating a database using the Azure management portal

Building a database using Entity Framework (EF) Code First Migrations

Creating the data model

Configuring a database context

Linking an authenticated user to the model

Configuring the connection string

Enabling migrations and updating the database

Publishing with migrations

Managing SQL Azure Servers and databases

Managing a database through the portal

Features of the management portal

Managing a database using SSMS

Managing a database through Visual Studio

Using the table designer

Using Azure PowerShell

Choosing a management tool

Backing up and restoring databases

Automated exports

Summary

Questions

Answers

5. Building Azure MVC Websites

Implementing OAuth authentication

Creating a Twitter application

Modifying the external login

Testing the Twitter login

Completing the customer sales website

Modifying the user account panel

Temporary PayConfirm action

Final activities

Adding a custom domain name to a website

Implementing an SSL certificate

Creating CER files

Using OpenSSL to create a PFX certificate

Uploading the certificate

Redirecting all HTTP traffic to HTTPS

Adding Azure AD single sign-on to a website

Configuring AD

Configuring an MVC website for AD single sign-on

Publishing the website with AD single sign-on

Implementing Azure AD group authorization

Creating an AD group

Modifying the application service principal

Implementing AzureAdAuthorizeAttribute

Completing the admin sales website

Summary

Questions

Answers

6. Azure Website Diagnostics and Debugging

Enabling diagnostics

Working with logfiles

Viewing logfiles in Visual Studio

Streaming logs

Filtering stream logs

Downloading logs

Accessing files using FTP

Application logging

Implementing tracing in the application

Application logging to table storage

Querying table data

Application logging to blob storage

Diagnosing a real bug

Setting up the website

Producing an error

Site diagnostics

Extra filesystem settings

Site diagnostics using blob storage

Kudu

Remote debugging

When to use remote debugging

Summary

Questions

Answers

7. Azure Service Bus Topic Integration

Introducing Azure Service Bus and topics

Dead-letter queues

Creating a Service Bus topic

Connecting a website to the Service Bus topic

Preparing the website

Creating messaging logic

Sending a message from the controller

The messaging simulator

Setting up the project

Creating a data service

Creating a messaging service

Completing the simulator

Running the simulator

Exploring the topic workspace

The MONITOR tab

The CONFIGURE tab

The SUBSCRIPTIONS tab

Summary

Questions

Answers

8. Building Worker Roles

Introducing cloud services

Exploring worker roles

Creating a worker role

Examining the worker role

Examining the cloud service

Running locally

The compute emulator UI

The storage emulator UI

Publishing a worker role

Building the production order processor

Adding an entity model

Preparing the Service Bus topic

Adding an order processor task

Creating TopicProcessorBase

Implementing TopicProcessorBase

Using OrderTopicProcessor in the worker role

Creating a scheduled work activity

Creating a scheduled job and queue

Configuring a connection string

Adding batch processor tasks

Creating a storage queue processor base

Implementing StorageQueueProcessorBase

Completing the worker role

Testing the production order processor

Testing a single instance

Testing multiple instances

Deleting idle cloud services

Summary

Questions

Answers

9. Cloud Service Diagnostics, Debugging, and Configuration

Configuring diagnostics

Adding local diagnostics

Configuring Azure storage diagnostics

Remote debugging

Stopping the debugger

Examining how remote debugging works

Debugging with IntelliTrace

Remote desktop connection

Downloading a Remote Desktop Protocol (RDP) file

Establishing an RDP connection

Firewall issues

Detecting configuration changes in code

Start-up tasks

Creating a batch script

Adding the task

Environmental variables

Summary

Questions

Answers

10. Web API and Client Integration

Introducing a Web API

Introducing SignalR

Building a Web API service

Creating a Web API project

Creating API controllers

Creating a SignalR hub

Publishing a Web API

Modifying the Web API AD manifest

Adding a client application to AD

Building a client application

Preparing the WPF project

Creating an authentication base class

Creating a data service

Creating a SignalR service

Completing the application

Testing the application

Summary

Questions

Answers

11. Integrating a Mobile Application Using Mobile Services

Introducing Azure mobile services

Creating the customer Azure mobile service

Creating a mobile services project

Exploring the mobile service sample project

The sample table controller

The sample data entity

A sample scheduled job

Mobile service DbContext

WebApiConfig

Cleaning up the project

Integrating with the sales database

Configuring development app settings

Integrating authentication with the sales website

Adding a channel registration API controller

Adding an order controller

Publishing the mobile service

Creating a Windows Phone application

Adding data services

The DataServiceBase class

The DataService class

Setting up push notifications

Modifying the manifest

Adding a channel helper

Notifications debug

Completing the app

Updating the order processor

Updating the admin website

Creating the supply mobile service

Configuring a mobile service for Azure AD auth

Creating the barcode controller

Creating the order controller

Creating the supply Windows Store application

Configuring the Store app for AD authentication

Creating a DataServiceBase class

Summary

Questions

Answers

12. Preparing an Azure System for Production

Project configurations for multiple environments

Adding build configurations to a solution

Website configuration transforms

Application configuration transforms

Cloud configuration

Building website deployment packages

Manually publishing websites to the filesystem

Building web packages on a build server

Building cloud service deployment packages

Building cloud service deployment packages manually

Building cloud service deployment packages on a build server

Deploying web packages to Azure

Deploying cloud packages to Azure

Creating database scripts from Entity Framework Code First Migrations

The go-live checklist

Monitoring live services

The Microsoft Azure portal

The Service Management REST API

Management services alerts

Azure PowerShell

Azure daily service checks

Azure periodic service activities

Azure tool list

Summary

Questions

Answers

Index

Learning Microsoft Azure


Learning Microsoft Azure

Copyright © 2014 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: October 2014

Production reference: 1091014

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78217-337-3

www.packtpub.com

Credits

Author

Geoff Webber-Cross

Reviewers

Debarchan Sarkar

Jignesh Gangajaliya

Zhidong Wu

Commissioning Editor

Amarabha Banerjee

Acquisition Editor

Sonali Vernekar

Content Development Editor

Anila Vincent

Technical Editor

Mrunal M. Chavan

Copy Editors

Sayanee Mukherjee

Alfida Paiva

Project Coordinator

Neha Bhatnagar

Proofreaders

Mario Cecere

Maria Gould

Lawrence A. Herman

Indexers

Mariammal Chettiyar

Monica Ajmera Mehta

Rekha Nair

Tejal Soni

Graphics

Ronak Dhruv

Valentina D'silva

Disha Haria

Abhinash Sahu

Production Coordinators

Aparna Bhagat

Manu Joseph

Shantanu N. Zagade

Cover Work

Manu Joseph

About the Author

Geoff Webber-Cross has over 10 years' experience in the software industry, working in manufacturing, electronics, and other engineering disciplines. He has experience of building enterprise and smaller .NET systems on Azure and other platforms. He also has commercial and personal experience of developing Windows 8 and Windows Phone applications. He has authored Learning Windows Azure Mobile Services for Windows 8 and Windows Phone 8, Packt Publishing.

I'd like to thank my wife and two boys for keeping me motivated throughout the book-writing process.

About the Reviewers

Debarchan Sarkar is a Support Escalation Engineer in the Microsoft HDInsight team and a technical author of books on SQL Server BI and Big Data. His total tenure at Microsoft is 7 years, and he was with the SQL Server BI team before diving deep into Big Data and the Hadoop world. He is an SME in SQL Server Integration Services (SSIS) and is passionate about the present-day Microsoft self-service BI tools and data analysis, especially social-media brand sentiment analysis. He hails from the City of Joy Kolkata, India, and is presently located in Bangalore, India, for his job in Microsoft Global Technical Support Center. He owns and maintains his Big Data Learnings group on Facebook and is a speaker at several of Microsoft's internal and external community events. His Twitter handle is @debarchans.

He is the author of Microsoft SQL Server 2012 with Hadoop, Packt Publishing and Pro Microsoft HDInsight: Hadoop on Windows, Apress Media LLC.

I want to thank my father, Mr. Asok Sarkar, for his continued encouragement and all the hard work he has done throughout his life to see us happy. I feel better today because I'm able to acknowledge that I'm proud to have you as my father, from the core of my heart.

Jignesh Gangajaliya is a principal technical architect with over 11 years of core technology and global business leadership experience in defining solutions and technology architectures.

His expertise is in design, development, and deployment of large-scale software systems and solutions across various industry verticals. His core strengths are wide and deep hands-on technological expertise, strategic thinking, comprehensive analytical skills, creativity in solving complex problems, and the ability to quickly understand complex business problems and come up with pragmatic solutions.

He is passionate about creating a strategic vision, and building and transforming organizations to accelerate growth and value creation by leveraging new technologies, trends, and emerging opportunities.

He specializes in enterprise architecture, solution architecture, Microsoft server products and technologies, cloud computing, SaaS, Microsoft Azure, and Amazon Web Services.

Zhidong Wu received his M.S. degree in Computer Science from Brown University. He has worked at Microsoft Corporation and Baidu in the past. He is an enthusiast in Big Data and has experience in Apache Hadoop, Microsoft Azure HDInsight, and Microsoft Cosmos. He can be contacted at <[email protected]>. You can find out more about him at http://www.linkedin.com/in/wuzhidong1122.

www.PacktPub.com

Support files, eBooks, discount offers, and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print and bookmark content

On demand and accessible via web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Instant updates on new Packt books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.

Preface

Learning Microsoft Azure is a practical, hands-on book for learning how to build systems for Microsoft Azure. This book is themed around an enterprise case study based on a fictional industrial bakery called Azure Bakery, which spans three business units: sales, production, and supply. The entire system is built on the Microsoft Azure technology that utilizes a broad range of services.

The sales business unit is responsible for selling products to customers through the MVC 5 customer website, where customers can place orders and view their status as the order moves through the system. Products are managed through another administrator website that implements Azure Active Directory authentication. A Windows Phone app with .NET mobile service and Twitter authentication integrated with the customer website allows customers to view the order status on their phone and receive push notifications via the notifications hub when the order status changes and new products are created. The sales system has its own dedicated SQL Azure Database and communicates with the other systems via a Service Bus topic. A worker role is implemented to keep the sales system updated as orders are processed through the enterprise system.

The production business unit is responsible for manufacturing the products for the customer orders and has a worker role at the core of it, which consumes customer orders from the Service Bus topic, enters the orders into the production SQL Azure Database, creates batch schedules to bake products, and allocates stock in the system. Production staff uses an on-premises WPF client application with Azure Active Directory authentication to view batch schedules and manage stock via a Web API 2 service with SignalR hub and Azure Service Bus backplane, allowing client applications to update in real time.

The supply business unit is responsible for picking up and packing orders from the production business unit and delivering them to customers. A worker role consumes orders from the Service Bus topic and stores customer details in a table storage, and automatically creates barcode labels stored in a blob storage. Supply staff interacts with the system via an Enterprise Windows Store app, which is authenticated with Azure Active Directory and has a .NET mobile service backend.

As we're building the system, we learn about the topic we're exploring and apply it to our system with detailed walk-throughs and relevant code samples. There are complete working code samples for the entire system that are broken down chapter-wise.

What this book covers

Chapter 1, Getting Started with Microsoft Azure, gives an introduction to cloud computing and Microsoft Azure followed by how to choose a subscription and signing up for a subscription. We finish this chapter by taking a look around the portal, and then start looking at the different services Microsoft Azure has to offer.

Chapter 2, Designing a System for Microsoft Azure, covers designing scalable, resilient systems for Microsoft Azure by looking at methodologies for breaking systems into subsystems and selecting appropriate Azure services to build them. This process will be applied to design a small system for an independent station that requires a website and a basic administration system; it is then extended to a full enterprise system, where will we introduce the Azure Bakery case study.

Chapter 3, Starting to Develop with Microsoft Azure, gives you the first taste of developing for Microsoft Azure, where you will prepare their development environment with the required tools and sign up for a Visual Studio Online account. We'll create the foundations of the sales customer website and publish it to the cloud, and then set up continuous deployment using the Visual Studio Online Team Foundation build server.

Chapter 4, Creating and Managing a Windows Azure SQL Server Database, creates a database for the sales business unit and builds it using Entity Framework Code First Migrations. This chapter will examine different tools for working with the database from a developer and administrator point of view, and look at options for database backup.

Chapter 5, Building Azure MVC Websites, builds the sales customer website and administrator website, with Twitter authentication for the customer site and Azure Active Directory authentication for the administrator site. We will learn how to apply custom domain names and SSL certificates to Azure websites and learn how to perform Azure AD group authorization in an MVC website.

Chapter 6, Azure Website Diagnostics and Debugging, follows on from the previous chapter, exploring techniques and tools to help diagnose problems and debug Azure websites. We'll look at enabling diagnostics in websites, working with logfiles, and examining application logging and site diagnostics. Finally, we'll look at the Kudu service and remote debugging Azure websites.

Chapter 7, Azure Service Bus Topic Integration, starts with an overview of the Service Bus topics and creates a topic for handling order messaging between the three business tiers. We'll integrate the sales customer website into the topic with a subscription, allowing the newly-created orders to be sent across the system, where they will be collected by the production system for manufacturing, and the supply system for producing address labels and planning deliveries. We'll also create a messaging simulator to allow the topic to be loaded up with high volumes of orders to help test the scalability and capacity of the system. Finally, we'll look at the features in the portal to help us monitor and manage our Service Bus topic.

Chapter 8, Building Worker Roles, gives an introduction to cloud services and creating a worker role. Then, we'll create and run a basic cloud service locally on the compute emulator, and publish and run it in the cloud. The production order processor is created next, which is responsible for receiving orders from the Service Bus topic, saving them to the production database, creating product batch schedules, and allocating stock. Finally, we'll test the cloud service in a scaled deployment using the simulator created in Chapter 7, Azure Service Bus Topic Integration.

Chapter 9, Cloud Service Diagnostics, Debugging, and Configuration, continues on from the previous chapter and covers diagnostics, remote debugging, and IntelliTrace. We'll learn how to deal with configuration changes made in the portal at runtime and implement start-up tasks for performing customizations to prepare the server environment for the service.

Chapter 10, Web API and Client Integration, provides an introduction to the Web API and SignalR with an Azure Service Bus backplane followed by building a Web API service and a SignalR hub, to allow the production management application to interact with the production database and Service Bus topic. The system will be authenticated with Azure AD authentication, allowing production staff to log in to the WPF client application using their Azure AD credentials.

Chapter 11, Integrating a Mobile Application Using Mobile Services, brings the whole system together with the addition of a mobile service and a Windows Phone 8 application for the sales system, which allows users to log in with the same credentials as the customer website, view orders, and receive order updates and product news via the notifications hub. The sales mobile service provides APIs for the admin website and order processor to interact with the notifications hub. Finally, the chapter looks at building an Azure AD authenticated mobile service for the supply Windows Store application to view orders and retrieve address labels from a blob storage created by the supply order processor.

Chapter 12, Preparing an Azure System for Production, is the final chapter, and looks at configuring systems for various environments including production, and creating publishing packages using the Visual Studio Online Team Foundation build server and producing database scripts in order to manage the system deployments in a controlled way by systems administrators or developers. We'll learn how to monitor the different services implemented throughout the book once they are live, and also cover guidelines for publishing web-connected mobile applications.

What you need for this book

You need a good spec machine with Windows 8.1 installed as a starting point. A premium version of Visual Studio 2013 is ideal but not necessary as multiple versions of Visual Studio Express (which are free) can be used instead. You will sign up for a Microsoft Azure subscription at the start of the book if you have not already got one; there are various paid options, but a free 3-month trial is available. To work on Windows Store applications, a Store account is needed, which is covered in Chapter 11, Integrating a Mobile Application Using Mobile Services.

Who this book is for

This book is aimed at .NET developers interested in building systems for Microsoft Azure. Good knowledge of Microsoft .NET is essential; knowledge of building websites, Windows applications, and Windows Phone or Windows 8 applications is helpful but not essential.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: In the website project, open the Views/Home/Index.cshtml file and make some changes to the markup.

A block of code is set as follows:

public class AuthHelper

{

    public static async Task GetCustomer(ServiceUser serviceUser, CustomerMobileServiceContext ctx)

    {

        // Find Twitter Id, of form Twitter:123456789

        var idParts = serviceUser.Id.Split(':');

        var key = idParts[1];

        var provider = idParts[0];

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public class AuthHelper

{

    public static async Task GetCustomer(ServiceUser serviceUser, CustomerMobileServiceContext ctx)

    {

        // Find Twitter Id, of form Twitter:123456789

        var idParts = serviceUser.Id.Split(':');

       

var key = idParts[1];

 

        var provider = idParts[0];

Any command-line input or output is written as follows:

Install-Package WindowsAzure.MobileServices

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: Enter Project name and Description and select the Team Foundation Version Control option (this is the default option), and then click on Create project.

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright

Enjoying the preview?
Page 1 of 1