Programming Microsoft Azure
Programming Microsoft Azure
Better,
Best Practices & DevOps
Subhasish Ghosh
Director, CloudCover.In
@nerdometer
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Contact
e: [email protected], [email protected]
m: +91-9916043731
LinkedIn: https://www.linkedin.com/in/sghosh2011
Skype: pink_floyd2008
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
- Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
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
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
DAY #1
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Demo #1
Web Platform Installer (Web PI) &
WebMatrix3
Demo #2
VS2013 Latest
Features
Demo #3
MyFixIt Application
Current Trends
Programming Azure Better, Best Practices & DevOps
+91-9916043731
http://msopentech.com/
https://vmdepot.msopentech.com/
Demo #4
Tinkering around with VM Depot
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.
Katana Architecture
http://msopentech.com
/
Demo #5
Tinkering around with Katana Project
Quick Demo
Blank Application
PM> Install-Package
Microsoft.Owin.Host.SystemWeb
PM> Install-Package
Microsoft.Owin.Diagnostics
Programming Azure Better, Best Practices & DevOps
[email protected]
+91-9916043731 PM> Install-Package
http://msopentech.com
/
Press F5
Runs OWIN app using
System.Web
(IIS/ASP.NET)
Project Katana
DEMO:
. How to run same program using OWIN default
server, HttpListener?
http://msopentech.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
Azure Portal
Walkthrough
Programming Azure Better, Best Practices & DevOps
+91-9916043731
DAY #2
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
& Docker - Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
Microsoft Azure
Compute
Programming Azure Better, Best Practices & DevOps
+91-9916043731
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 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.
Demo #6
Creating Cloud Service, creating a VM and attaching VM inside a Cloud
Service.
PaaS
Demo #7
Azure Web Sites
Demo #8
Auto-Scaling Options in Azure
5. AccessTheWebAsync uses an
await operator to suspend its
progress and to yield control to the
[email protected]
method that called
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
Best Practice #1
Use Case 1
Control Flow
Best Practice #2
Use Case 2
Control Flow
Things should
become Faster?
Right?
Poll:
Yes | No
What happens
On my laptop, it is 2
cores.
So 2 threads are
allocated for the
job.
WRONG!
Programming Azure Better, Best Practices & DevOps
+91-9916043731
What actually
happens
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Is it CPU-bound OR
IO-bound that is
faster?
Programming Azure Better, Best Practices & DevOps
+91-9916043731
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
Threadpool is
Application-Global
resource.
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Best Practice #3
Use Case 3
2 methods
3 types of methods
PaaS
Demo #9
Active Directory Options in Azure
Lab #2
Creating an ASP.NET MVC application that utilizes SSO with Azure AD
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
Open VS2013 as admin New Project Visual C# ASP.NET Web Application, call it ExpenseReports.
Inside ExpenseReports go to Users and then select Iam (i.e. [email protected]) and ASSIGNED
= YES.
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.
DAY #3
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
& Docker - Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
Recap
Day 1 & Day 2
MISSING
SQL DB (PAAS)SQL VM (IAAS)
SQL vs.
NoSQL
Balancing
Priorities
[email protected]
Best Practices
Questions to Ask
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.
Example
- Storing blog posts and related info. SQL Schema:
Example
- Storing blog posts and related info. Mongo DB Schema:
Vertical
Partitioning
Horizontal
Partitioning
(SHARDING)
Vertical Partitioning
Sharding
BRAIN TEASER!!!!!!!!!
Hybrid Partitioning
Average Usage
Time
Predictable Bursting
Compute
Compute
Growing Fast
Average Usage
Time
Demo #10
- Creating Image for DB, creating VM from Image
- VS2013 Code Review of SQL DB & EF
Demo #11
- Creating Storage Account from Azure Portal
- VS2013 Code Review of Blob creation
Lab #3
Creating HelloWorldHYD2014 Cloud Services (Web & Worker Roles)
application and Publishing to Microsoft Azure; Storage Account;
Configure Auto-scaling.
Select Visual C# one ASP.NET Web Role and Worker Role. Call it HelloWorldWeb and
HelloWorldWorker.
Select MVC, OK
This creates the project
DAY #4
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
& Docker - Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
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
3 Types of Cache
- Azure Managed Cache Service
- Azure Redis Cache
- Azure In-Memory Cache
Programming Azure Better, Best Practices & DevOps
+91-9916043731
3 offerings:
Basic - 128MB to 1GB cache sizes, non-HA, 128GB
increments
Lab #4
Creating a Cache for Azure Managed Cache Service using Azure
PowerShell cmdlets. Connecting to this MCS from a client application.
Type in Add-AzureAccount
which enters a dialog. Add
your Hotmail id associated
with Azure subscription
account and proceed.
NewAzureManagedCache
-Name HydDemoCache
-Location "South
Central US" -Sku Basic
-Memory 128MB
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" />
Redis
-
Redis Tutorial
-
http://try.redis.io/
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.
3 steps
- Create the cache
- Configure the cache
- Configure the cache clients
#install-package StackExchange.Redis
#install-package
StackExchange.Redis.StrongName
#install-package
Microsoft.Web.RedisSessionStateProvider
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Queuing on Azure
-
Tightly Coupled
MyFixIt Application
Web Server
MyFixIt DB
Loosely Coupled
MyFixIt DB
MyFixIt Application
Web Server
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Queue Listener
[email protected]
Task Queue
MyFixIt Application
Web Server
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Queue Listener
Task Queue
Queue Listener
Queue successfully handles
burst
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Demo #12
How to leverage Queues in VS2013
Old code
New code
DAY #5
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
& Docker - Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
Types
Understanding Scope
3
2
1
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Application SLA = ?
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
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.
DevOps
DevOps
DevOps on Cloud
DevOps Principles
Use Source Control
Automate Repetitive
Tasks using Runbooks
Source Control
Use It
Create sub-branches
Production
Code in final
testing
Features being
Integrated
Need a Hotfix/Bugfix?
Production
Code in final
testing
Confidence
Agility
Less Prone to
Errors
Programming Azure Better, Best Practices & DevOps
+91-9916043731
Microsoft Azure
Web.config stores 2
connection strings for
password and the key to an
Azure storage account
Lab #7
Demo #13
How to leverage Automation in Azure Management
Portal
Lab #8
Playing around with PowerShell Cmdlets & Run Books
Set-ExecutionPolicy
Add-AzureAccount
Get-AzureSubscription
Set-AzureSubscription
Get-AzurePublishSettingsFile
Import-AzurePublishSettings File
Get-AzureLocation
New-AzureAffinityGroup
New-AzureStorageAccount
Lab #9
Staged Deployment in Azure Web Sites with GitHub
Integration
- 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.
- Go to Make a change in the Startup script (add a comment for example), and Included
Changes will appear.
Now make one more change in Startup file in VS2013; commit the changes, and then sync.
Day1
Day2
Introduction
MyFixIt Application
- Demo
Cloud
Development
Best Practices
Day3
Data Storage
Options
Why No-SQL?
Data Partitioning
Strategies
Blob Storage
Code Review in
VS2013
Lab 1
Demos
Azure
Management
portal walkthrough
Lab 2
Lab 3
Day4
Day5
Designing for
Withstanding Failure
Lab 6
DevOps: Source
Control
Lab 7
PowerShell Cmdlets
& Docker - Demos
Using Queues on
Azure
Code Examples
ASSESSMENT
Caching on Azure
Using Managed
Cache Service
Lab 4
Lab 5
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
24 BEST PRACTICES
Advanced Techniques.
Consider these ones before migrating applications to Cloud.
24 Architectural Best Practices to follow before Migrating Line-ofBusiness (LOB) Applications to Cloud.
Download:
http://msdn.microsoft.com/en-us/library/dn568099.aspx
FRE
Recommended
E
eBooks
Download & Print.
Developer
IT Professional
Solutions Architect
Recommended for ALL
Introduction to Azure:
- Coming from Infra
background
Introduction to Azure:
- Coming from Developer
background
Workshop Deck
http://bit.ly/12SrwVd
Programming Azure Better, Best Practices & DevOps
+91-9916043731