You are on page 1of 252

Programming Azure

Better,
Best Practices & DevOps
Subhasish Ghosh
Director, CloudCover.In
@nerdometer
Programming Azure Better, Best Practices & DevOps
+91-9916043731

Dec 8-12 2014


Microsoft,
Hyderabad
subhasishghosh2013@hotmail.com

Contact
e: subhasishghosh2013@hotmail.com, sghosh.oxon@yahoo.co.uk
m: +91-9916043731
LinkedIn: https://www.linkedin.com/in/sghosh2011
Skype: pink_floyd2008

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Objective of the Workshop:


Learn how to leverage Microsoft Azure features coupled with best
practices in VS2013 for architecting and developing highly-scalable
n-tier Web Applications

10:00am 12:00pm Session 2 hrs


12:00pm 12:30pm Lunch Break
12:30pm 2:30pm Session 2 hrs

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
- Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Laboratories 1,2,3,4,5,6,7,8,9
1. SETUP: Install Microsoft Azure SDK for .NET (vs2013) - 2.5, Install Visual Studio Express 2013 for Web with Microsoft Azure SDK
2.5, Microsoft Azure PowerShell, Open Microsoft Azure Subscription TRIAL 30-day account. Create a VM, stop & stop-deallocate using
Azure PowerShell
2. SECURITY: Creating an ASP.NET MVC application and then adding Single Sign-On (SSO) to your application using Azure Active
Directory (AAD)
3. CLOUD SERVICES: Creating a Cloud Services (Web & Worker Roles) application. Publishing to Microsoft Azure associated with a
Microsoft Azure Storage Account; Configure Auto-scaling
4. AZURE MANAGED CACHE SERVICE: Creating a Cache for Azure Managed Cache Service using Azure PowerShell cmdlets.
Connecting to this MCS from a client application.
5. AZURE REDIS CACHE: Creating and configuring Azure Redis Cache, configuring cache clients, adding and removing objects from
the cache, and storing ASP.NET session state in the cache.
6. MONITORING CODE: Creating a New Relic account, integrating it with an Azure Web Sites application and then publishing to Azure;
and checking out the tool
7. SOURCE CONTROL: Using Git in VS2013, Exploring features (branches, merging, comments etc.)
8. DEVOPS AUTOMATION: Using Microsoft Azure PowerShell installation, cmdlets, Azure Subscription details and Runbooks
Introduction
9. STAGED PUBLISHING: Staged Publishing feature of Azure Web Sites along with GitHub Integration
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

2 Take Home Challenges!


End of Day 1 & Day 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Assessment
End of Day 5
20 Multiple Choice Questions, 40 Minutes
- Each Correct answer = 5 points
- Each Incorrect answer = 0
- Maximum Score = 20 * 5 = 100/100
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

DAY #1
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Demo #1
Web Platform Installer (Web PI) &
WebMatrix3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #2
VS2013 Latest
Features

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #3
MyFixIt Application

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Current Trends
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

We are gonna talk about

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Microsoft Open Technologies

http://msopentech.com/

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

https://vmdepot.msopentech.com/

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #4
Tinkering around with VM Depot

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

http://katanaproject.codeplex.co
m/
Microsoft via Katana is building a set of components around hosting
abstraction for your applications. That hosting abstraction is 'OWIN'.
OWIN is a specification. Not a code // library // framework.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Katana Architecture

http://msopentech.com
/

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #5
Tinkering around with Katana Project

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Quick Demo
Blank Application

PM> Install-Package
Microsoft.Owin.Host.SystemWeb
PM> Install-Package
Microsoft.Owin.Diagnostics
Programming Azure Better, Best Practices & DevOps
subhasishghosh2013@hotmail.com
+91-9916043731 PM> Install-Package

http://msopentech.com
/

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Inside the OWIN Startup class, enter:


app.UseWelcomePage();

Press F5
Runs OWIN app using
System.Web
(IIS/ASP.NET)

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Project Katana
DEMO:
. How to run same program using OWIN default
server, HttpListener?
http://msopentech.com
/

HINT: Tinker with


Microsoft.Owin.Host.HttpListener

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #1
WPI 5.0, Install Microsoft Azure SDK for .NET (vs2013) - 2.5
Install Visual Studio Express 2013 for Web with Microsoft Azure SDK
2.5
Microsoft Azure PowerShell, Open Microsoft Azure Subscription TRIAL 30day account
Create a VM, stop & stop-deallocate using PowerShell
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Azure Portal
Walkthrough
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Take Home Challenge!


Enabling Trace Warning on Cloud using VS2013

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DAY #2
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
& Docker - Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Take Home Challenge! Solution


Enabling Trace Warning on Cloud using VS2013

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Cloud Development Best


Practices

Stateless WebScale-Out Web Tier


No Session State;
Use CDN for
Based on
Tier Behind an
Use Cache
Static Objects/Files
Actual Demand
astic Load Balancer

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Microsoft Azure
Compute
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Azure Cloud Services

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Workloads for Cloud Services

VM is explicitly IaaS, Cloud Services is explicitly PaaS, Web Sites is explicitly


hosting.

Cloud Services gives you administrative access to your application's VMs.


Web Sites do not provide this. This lets you install arbitrary software that
your application needs, something that's not possible with Web Sites.

N-tier stateless applications is perfect for Cloud Services. Offers both web
roles and worker roles (requirement for separate VMs for their business
logic).

Cloud Services provides separate staging and production environments,


making application updates somewhat smoother than Web Sites.

Cloud Services lets you use networking technologies such as Azure Virtual
Network and Azure Connect to hook on-premises computers to Cloud
Services applications. No such thing on Web Sites.

Cloud Services lets you use Remote Desktop to connect directly to an


application's VMs. No such thing on Web Sites.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Microsoft Azure Service Model


Example cloud service configuration with a single web role and a
single worker role

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Mixing Virtual Machines &


Stateless Roles
Multiple cloud services with stateless and virtual machines

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #6
Creating Cloud Service, creating a VM and attaching VM inside a Cloud
Service.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

VIPs in Cloud Services


- Public IP address
pointing to Azure
Cloud Service where
VM is deployed.
- Every Cloud Service
has a VIP and every
Cloud Service can
have several VMs.
- A VIP assigned to
Cloud Service wont
be released until last
VM on that Cloud
Service is Stopped
(De-allocated) or
Deleted
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Connecting Cloud Services via


VIPs

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Connecting Cloud Services via


VNET

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Azure Web Sites

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

PaaS

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #7
Azure Web Sites

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Under the Hood

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Under the Hood

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Load Balancing at Layer 7


Smart
Routes Traffic to Distinct Fault Domains
subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #8
Auto-Scaling Options in Azure

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

async Support in .NET 4.5

Anyone using async


in
.NET 4.5 today?
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

async Support in .NET 4.5


- async language support to build non-blocking,
asynchronous, server-side applications
- ASP.NET MVC, Web API and WebForms have built-in
async language keyword support as of .NET 4.5

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

What happens in async?

1. An event handler calls and awaits


the AccessTheWebAsync async
method.
2. AccessTheWebAsync calls the
GetStringAsync asynchronous
method to download the contents of
a website as a string.
3. Something happens; to avoid
blocking resources, GetStringAsync
yields control to its caller,
AccessTheWebAsync.
4. DoIndependentWork is a
synchronous method that does its
work and returns to its caller.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

5. AccessTheWebAsync uses an
await operator to suspend its
progress and to yield control to the
subhasishghosh2013@hotmail.com
method that called

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Properties
- async code is NOT multi-threaded code
- by default, code written within async & await are
single-threaded.
- async & await lets us run methods
asynchronously & not code multi-threaded manner

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

3 Best Practices for async


- async void only for top-level event
handlers
- The threadpool is for CPU-bound code,
not IO-bound code
- Your methods cannot lie
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Best Practice #1
Use Case 1

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Code in the application

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Control Flow

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Which await returns


earlier?
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Convert the async


void to Task
returning method
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Best Practice #2
Use Case 2

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Code in the application

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Control Flow

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Replace for with Parallel.For

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Things should
become Faster?
Right?

Poll:

Yes | No

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

What happens

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

On my laptop, it is 2
cores.
So 2 threads are
allocated for the
job.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Response time 300


Ms is better than 500
Ms.
Right?
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

WRONG!
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

What actually
happens
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Is it CPU-bound OR
IO-bound that is
faster?
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Parallel.For keeps on allocating new threads. Start1 and Start2 are waiting,
so Start3 and Start4 are spawned. But the issue is
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Threadpool is
Application-Global
resource.
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

This is how it should be

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Do not use CPUbound. Use async for


IO-bound.
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practice #3
Use Case 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Your methods cannot lie


- A synchronous method should execute
synchronously
- An asynchronous method should execute
asynchronously
- Do not expose asynchronous
wrappers around synchronous
methods
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

2 methods

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

3 types of methods

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Cloud Identity | Synchronized |


ADFS

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

PaaS

Azure Active Directory (AAD)

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Classic Use Case


There are two apps on the web and the user has a plain-old browser.
Since the two apps never talk to each other directly, a mechanism would
need to be devices where the user logs onto App A, receives and access
token into their browser and passes it through to App B with then calls
back to App A via some API to make sure the access token is valid.
If we passed the access token into the users browser so its possible it
could be snatched (perhaps by some malicious javascript). This is why
most developers stick to the standard SSO protocols like SAML, OpenID
and WS-Federation for the classic web-app to web-app single sign-on.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #9
Active Directory Options in Azure

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #2
Creating an ASP.NET MVC application that utilizes SSO with Azure AD

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

4 steps:
. Creating an AD user using Microsoft Azure
Management portal
. Creating an ASP.NET MVC application using VS2013
. Ensuring AD user has Global Rights and correctly set
permissions for logging-in using Azure AD
. Connecting the application to Azure AD
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Ensure new user has Global_Admin rights


Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Open VS2013 as admin New Project Visual C# ASP.NET Web Application, call it ExpenseReports.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Now go back to Azure


Management portal, open the
AD we created earlier and then
go to Applications tab. You will
find ExpenseReports added
there.

Inside ExpenseReports go to Users and then select Iam (i.e. test@ContosoEngineeringHyd.onmicrosoft.com) and ASSIGNED
= YES.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Now go back to VS2013 and build the application. Then press F5. This will open up the application and redirect to the sign-in
page.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DAY #3
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
& Docker - Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Recap
Day 1 & Day 2

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Data Storage Options


Case Study:
Organization based in Mumbai. Has developed HRMS
application using .NET on Azure. Scaled faster than
expected. Have issues with storing data, processing
data, reporting and also scaling app.

MISSING
SQL DB (PAAS)SQL VM (IAAS)

Programming Azure Better, Best Practices & DevOps


+91-9916043731

SQL vs.
NoSQL

Balancing
Priorities
subhasishghosh2013@hotmail.com

Data Storage Options

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practices

Data Storage Options


1

No "one-size fits all"

2As applications scale,


consider
NoSQL along with SQL

3Single App with


Multiple Data
Storage Options

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Questions to Ask

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Azure SQL Db Vs. SQL Server


in VM

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Why No-SQL?
- Huge Data Sets
- Denormalized Data Sets
- Need fast access to
unstructured data
- Example use cases:
- Social Media, Analytics,
Security, and Compliance
- Analyse and search data of all
types, such as text, images,
videos, music.
- High-performance core data
processing and analytics.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Brief Intro Mongo DB


- Mongo DB stores data in the form of documents, which are
JSON-like field and value pairs.
- Documents are analogous to structures in programming
languages that associate keys with values (e.g. dictionaries,
hashes, maps, and associative arrays).
- Formally, Mongo DB documents are BSON documents. BSON is a
binary representation of JSON with additional type information.
In the documents, the value of a field can be any of the BSON
data types, including other documents, arrays, and arrays of
documents.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Brief Intro Mongo DB


- Mongo DB stores all documents in collections. A collection is a
group of related documents that have a set of shared common
indexes. Collections are analogous to a table in relational
databases.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Example
- Storing blog posts and related info. SQL Schema:

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Example
- Storing blog posts and related info. Mongo DB Schema:

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Data Partitioning Strategies

Vertical
Partitioning

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Horizontal
Partitioning
(SHARDING)

subhasishghosh2013@hotmail.com

Vertical Partitioning

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Sharding

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

BRAIN TEASER!!!!!!!!!
Hybrid Partitioning

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Plan BEFORE Architecting &


Coding
Semantics
Scale
Queries
Analytics
Real-time

Average Usage

Time

Predictable Bursting

Compute

Compute

Growing Fast

Average Usage

Time

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Using Blob Storage (Binary


Large OBject)

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #10
- Creating Image for DB, creating VM from Image
- VS2013 Code Review of SQL DB & EF

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #10: Understanding the


Code

Open VS2013 MyFixIt.Persistence


MyFixItContext.cs
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Demo #10: Understanding the


Code
The FixItContext class derives
from Entity Framework,
DbContext class, identifies the
database and specifies the
tables in the database.

The connection string in the


Web.config file is called
appdb. Here, points to the
local development database.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #10: Understanding the


Code

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #10: Understanding the


Code
The Entity Framework creates a
FixItTasks table based on the
properties included in the
FixItTask entity class.
This is POCO (Plain Old CLR
Object) class. EF creates a
table and executes a CRUD
(create-read-update-delete)
ops.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Server Explorer appdb FixItTasks Right-click and Show Table Data

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #11
- Creating Storage Account from Azure Portal
- VS2013 Code Review of Blob creation

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #3
Creating HelloWorldHYD2014 Cloud Services (Web & Worker Roles)
application and Publishing to Microsoft Azure; Storage Account;
Configure Auto-scaling.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lets go step by step to build this application.


Open Azure Storage Emulator. Open VS2013 as administrator.
New Project Templates Visual C# Cloud Azure Cloud Service name it HelloWorldHyderabad

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Select Visual C# one ASP.NET Web Role and Worker Role. Call it HelloWorldWeb and
HelloWorldWorker.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Select MVC, OK
This creates the project

subhasishghosh2013@hotmail.com

Right-click and Build the solution. The press F5.

Let us now add a


HelloWorld
controller.
HelloWorldWeb
Controller Right-click
and Add Controller.
It opens a new dialog
box. Select the Empty
Controller.
Name it
HelloWorldHyderabad
Controller.
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Open App_Start RouteConfig.cs


Controller = should be same as
controller name in .cs

Build All Press F5 to


run. You should see
Hello World! on your
browser.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Right-click the cloud service, and then select Publish.


Sign-in into your Azure Subscription account; which you need to
select; and then settings where you can either select an existing
storage account in same region OR create a new one in same region.
Proceed next stage for provisioning this Cloud Service on Azure.
While provisioning, you can switch to Azure Management Portal and
see the VMs (Web & Worker Roles) getting created, Storage Account
getting created as well.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Take Home Challenge!


Create an Azure Web Site and I want to set up Auto-scaling such that
when the load increases greater than 32% on target CPU till 73%; I
will have at least 2 CPUs at the lowest point and 5 at the highest
point.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DAY #4
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
& Docker - Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Take Home Challenge! Solution


Create an Azure Web Site and I want to set up Auto-scaling such that
when the load increases greater than 32% on target CPU till 73%; I
will have at least 2 CPUs at the lowest point and 5 at the highest
point.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Caching on Azure
- Excellent for Read-Only Pattern when
underlying services of a Distributed
System is having issues
- Do not hit data source every time
- Cached data works well if customer
experience is taking a hit
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

3 Types of Cache
- Azure Managed Cache Service
- Azure Redis Cache
- Azure In-Memory Cache
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Azure Managed Cache Service


(MCS)
-

Must use for building fast, highly scalable n-tier web


applications

Secure, Dedicated Cache, SLA 99.9% availability

3 offerings:
Basic - 128MB to 1GB cache sizes, non-HA, 128GB
increments

Standard - 1GB to 10GB cache sizes, non-HA, 1GB


increments

Premium - 5GB to 150GB cache


sizes, HA, 5GB
subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Lab #4
Creating a Cache for Azure Managed Cache Service using Azure
PowerShell cmdlets. Connecting to this MCS from a client application.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Open Azure PowerShell


as administrator

Type in Add-AzureAccount
which enters a dialog. Add
your Hotmail id associated
with Azure subscription
account and proceed.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

NewAzureManagedCache
-Name HydDemoCache
-Location "South
Central US" -Sku Basic
-Memory 128MB

subhasishghosh2013@hotmail.com

Go to Configure and Scale options to review the options available.

Open VS2013 as admin; add a project; right-click and


then click Manage NuGet packages. Search for
WindowsAzure.Caching and then from the search
items, select Windows Azure Caching.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Open web.config file.

Identify this line: <autoDiscover isEnabled="true" identifier="[Cache role name or


Service Endpoint]" />

Replace [Cache role name or Service Endpoint] with the endpoint URL which is displayed on the Cache
Dashboard in the Management Portal. In our example:
<autoDiscover isEnabled="true" identifier="hyddemocache.cache.windows.net" />

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Uncomment the securityProperties section, and replace [Authentication


Key] with the authentication key from the Azure portal Manage Keys
Primary Key

To use this programmatically:

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Redis
-

In-memory Cache key/value store but


took one step further.

Excellent replacement for memCached

But not a replacement for persistent


storage ( e.g. SQL server )

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Redis Tutorial
-

http://try.redis.io/

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Azure Redis Cache


-

Secure, dedicated Redis cache, managed


by Microsoft. A cache created using Azure
Redis Cache is accessible from any
application within Microsoft Azure.

Microsoft Azure Redis Cache will be


available in two tiers:
- Basic Single node. Multiple sizes up to
53GB
- Standard Two-node Master/Slave.
Includes 99.9% SLA and replication
support. Up to 53 GB

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #5
Creating and configuring a cache, configuring cache clients, adding and
removing objects from the cache, and storing ASP.NET session state in
the cache.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

3 steps
- Create the cache
- Configure the cache
- Configure the cache clients

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Azure Management portal


Cache

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Now, we will configure the cache clients.


- Open VS2013, create an ASP.NET application, and then install using
NuGet Powershell

#install-package StackExchange.Redis
#install-package
StackExchange.Redis.StrongName

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Using Redis Cache in Code


Reference to the cache
-

In order to programmatically work with a cache, you


need a reference to the cache. Add the following to the
top of any file from which you want to use the
StackExchange.Redis client to access an Azure Redis
Cache:

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Using Redis Cache in Code


Connect to the cache

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Using Redis Cache in Code


Set expiration to items in cache
-

To specify the expiration of an item in the cache, use the


TimeSpan parameter of StringSet.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Using Redis Cache in Code


Store ASP.NET Session State in cache
-

Azure Redis Cache provides a session state provider that


you can use to store your session state in a cache rather
than in-memory or in a SQL Server database. To use the
caching session state provider, first configure your
cache, and then configure your ASP.NET application for
cache using the Redis Cache Session State NuGet
package.

#install-package
Microsoft.Web.RedisSessionStateProvider
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Using Redis Cache in Code


Check Web.config file

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Queuing on Azure
-

Enable more loose-coupling between web tier


& back-end
Enable asynchronous message processing in
case of failures
4
-

Key use cases to Identify:


High CPU
High Latency
Frequent / In-frequent Load Bursts
Service requiring a 3rd-Party Input

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Use Cases (Application


Developer)
-

Your application must store over 80 GB of messages


in a queue, where the messages have a lifetime
shorter than 7 days.

Your application wants to track progress for


processing a message inside of the queue. This is
useful if the worker processing a message crashes.
A subsequent worker can then use that information
to continue from where the prior worker left off.

You require server side logs of all of the


transactions executed against your queues.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Tightly Coupled

MyFixIt Application
Web Server

Programming Azure Better, Best Practices & DevOps


+91-9916043731

MyFixIt DB

subhasishghosh2013@hotmail.com

Loosely Coupled

MyFixIt DB

MyFixIt Application
Web Server
Programming Azure Better, Best Practices & DevOps
+91-9916043731

Queue Listener
subhasishghosh2013@hotmail.com

Loosely Coupled, 1 Web Tier

Task Queue

MyFixIt Application
Web Server
Programming Azure Better, Best Practices & DevOps
+91-9916043731

Queue Listener

subhasishghosh2013@hotmail.com

Loosely Coupled, n Web Tier

Task Queue

Queue Listener
Queue successfully handles
burst
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Demo #12
How to leverage Queues in VS2013

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

How to use it?

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

How to use it?

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Old code

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

New code

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DAY #5
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
& Docker - Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Design to Survive Failures

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Failures will happen.


You either gracefully
handle it, or die.
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Types

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Understanding Scope

3
2
1
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Application SLA = ?

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Buy a Good Telemetry Service

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #6
Creating a New Relic account, integrating it with an Azure Web Sites
application and then publishing to Azure; and checking out the tool

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Open web site, go to CONFIGURE, app settings

Open web site in WebMatrix, and then edit using VS2013.


Go to NuGet Package Manager Console:

Go into the newrelic.config file, and


copy in thelicense key from
Connection Info
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Build in VS2013, save all files and exit. Close V2013, open WebMatrix and
then Publish. It shows the new files to publish, click OK and proceed.

Go back to Azure portal, and


then NewRelic and then click
on Manage your application
and service. Takes you to the
NewRelic website and then
after accepting TOS.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DevOps

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DevOps

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DevOps on Cloud

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

DevOps Principles
Use Source Control

Automate Repetitive
Tasks using Runbooks

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Source Control

Use It

Branch out sources


Treat Automation No check-in
for DevOps processes
Scripts as of secrets (passwords,
& workflows
Source Control
settings)

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Create sub-branches
Production
Code in final
testing
Features being
Integrated

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Need a Hotfix/Bugfix?
Production
Code in final
testing

Confidence
Agility
Less Prone to
Errors
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Using Distributed Source


Control
Git
Mercurial
TFS

Visual Studio 2013 supports Git


Git-tooling built in
TFS Server & TFS Online Service
now supports publishing Git
repository
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Store Sensitive Data in Azure


Connection Strings in Azure

Microsoft Azure

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Web.config stores 2
connection strings for
password and the key to an
Azure storage account

subhasishghosh2013@hotmail.com

Lab #7

Using Git in VS2013


Add Solution to Source Control
Git, OK, creates Git repository in solution folder
Right-click Solution Explorer, Commit
Enter commit comment, and click Commit
Compare with Modified, to see changes that were
made
Explore Branches, Merging etc.

Using Git in VS2013

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Automation in Microsoft Azure

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Automation in Microsoft Azure

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Demo #13
How to leverage Automation in Azure Management
Portal

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

What are Cmdlets?


A cmdlet is a lightweight command that is used in the Windows
PowerShell environment. The Windows PowerShell runtime invokes
these cmdlets within the context of automation scripts that are
provided at the command line. The Windows PowerShell runtime also
invokes them programmatically through Windows PowerShell APIs.
Cmdlets perform an action and typically return a Microsoft .NET
Framework object to the next command in the pipeline. To write a
cmdlet, you must implement a cmdlet class that derives from one of
two specialized cmdlet base classes.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Lab #8
Playing around with PowerShell Cmdlets & Run Books

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

A few common Cmdlets:

Set-ExecutionPolicy
Add-AzureAccount
Get-AzureSubscription
Set-AzureSubscription
Get-AzurePublishSettingsFile
Import-AzurePublishSettings File
Get-AzureLocation
New-AzureAffinityGroup
New-AzureStorageAccount

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Open PowerShell as admin

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Before assigning CurrentStorageAccountName


to AzureSubscription

Programming Azure Better, Best Practices & DevOps


+91-9916043731

After assigning CurrentStorageAccountName to


AzureSubscription

subhasishghosh2013@hotmail.com

Before assigning CurrentStorageAccountName


to AzureSubscription

Programming Azure Better, Best Practices & DevOps


+91-9916043731

After assigning CurrentStorageAccountName to


AzureSubscription

subhasishghosh2013@hotmail.com

Staged Deployment & GitHub


Integration
When you deploy your application to Azure Web Sites, you can deploy to a separate
deployment slot instead of the default production slot, which are actually live sites with
their own hostnames. This option is available in the Standard web hosting plan.
Furthermore, you can swap the sites and site configurations between two deployment
slots, including the production slot.
Deploying your application to a deployment slot has the following benefits:
1. After a swap, the slot with previously staged site now has the previous production
site. If the changes swapped into the production slot are not as you expected, you
can perform the same swap immediately to get your "last known good site" back.
2. Deploying a site to a slot first and swapping it into production ensures that all
instances of the slot are warmed up before being swapped into production. This
eliminates downtime when you deploy your site.
3. The traffic redirection is seamless, and no requests are dropped as a result of swap
operations.
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

Lab #9
Staged Deployment in Azure Web Sites with GitHub
Integration

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Go inside Staging Web


Site and Quick Glance.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

- Inside VS2013, right-click project and Add to Source Control


- Team Explorer Changes Commit the changes with a comment

- We then need to choose which Repository you wish to connect. Give URL for your GitHub
repository from the Azure Management Portal. And then connect in dialog and commit.
- Go to GitHub account repository, you will see the project has been pushed to GitHub.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

- Go to Make a change in the Startup script (add a comment for example), and Included
Changes will appear.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Now make one more change in Startup file in VS2013; commit the changes, and then sync.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Day1

Day2

Introduction

WPI & WebMatrix3


- Demo

MyFixIt Application
- Demo

One ASP.NET &


Microsoft Open
Technologies

Cloud
Development
Best Practices

Day3

Data Storage
Options

VM, Cloud Services


& Web Sites
Analysis

Why No-SQL?

Web Sites &


AutoScale Demo

Data Partitioning
Strategies

async in .NET 4.5

Blob Storage

VM Depot & Katana


walkthrough Demos

Code Review & 3


Best Practices

Code Review in
VS2013

Lab 1

Azure AD & SSO

Demos

Azure
Management
portal walkthrough

Lab 2

Lab 3

Programming Azure Better, Best Practices & DevOps


+91-9916043731

Day4

Day5

Designing for
Withstanding Failure

Lab 6

DevOps: Source
Control

Lab 7

PowerShell Cmdlets
& Docker - Demos

Using Queues on
Azure

Lab 8 & Lab 9

Code Examples

ASSESSMENT

Caching on Azure

Using Managed
Cache Service

Lab 4

Using Azure Redis


Cache

Lab 5

subhasishghosh2013@hotmail.com

Assessment
End of Day 5
20 Multiple Choice Questions, 40 Minutes
- Each Correct answer = 5 points
- Each Incorrect answer = 0
- Maximum Score = 20 * 5 = 100/100
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

24 BEST PRACTICES
Advanced Techniques.
Consider these ones before migrating applications to Cloud.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

24 Architectural Best Practices to follow before Migrating Line-ofBusiness (LOB) Applications to Cloud.
Download:
http://msdn.microsoft.com/en-us/library/dn568099.aspx

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

FRE
Recommended
E
eBooks
Download & Print.

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practices to follow:


-

Developer
IT Professional
Solutions Architect
Recommended for ALL

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Introduction to Azure:
- Coming from Infra
background

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Introduction to Azure:
- Coming from Developer
background

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practices while dealing with


Hybrid Cloud
- Coming from Senior Solutions
Architect // IT background

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Introducing Microsoft Azure


HDInsight
- Coming back Developer / Big
Data / BI backgrounds

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practices to Migrate


Applications to Microsoft Azure
- Coming back Developer /
Architect backgrounds

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Best Practices to Building /


Architecting Cloud Applications for
Scale
- Coming back Developer /
Architect backgrounds
- BUT first basics of Azure must
be very clear

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

Workshop Deck

http://bit.ly/12SrwVd
Programming Azure Better, Best Practices & DevOps
+91-9916043731

subhasishghosh2013@hotmail.com

How do you copy?

Programming Azure Better, Best Practices & DevOps


+91-9916043731

subhasishghosh2013@hotmail.com

You might also like