SlideShare a Scribd company logo
Windows Azure Web Sites
Things they don’t teach kids in school
Maarten Balliauw
@maartenballiauw
Who am I?
Maarten Balliauw
Technical Evangelist, JetBrains
AZUG
Focus on web
ASP.NET MVC, Windows Azure, SignalR, ...
MVP Windows Azure & ASPInsider
Big passion: Windows Azure
http://blog.maartenballiauw.be
@maartenballiauw
Shameless self promotion: Pro NuGet http://amzn.to/pronuget2
Saturday, March 29, 2014
http://global.windowsazurebootcamp.com
90+ locations last year, this year let’s go for a 100!
Possibly the largest community event ever

MVP’s

Speakers

Locations
Attendees

Sessions
Agenda
Windows Azure Web Sites
Architecture
Project Kudu
Kudu kung-fu
Application log streaming
Managing settings
Staging and Production
Multi-tier deployments
Customizing deployments
Running batch files / background processes (*)
Windows Azure Web Sites
Web Sites in Seconds
Start Simple

Your way

Go Live

start free, scale up and out
as you go, friction-free
and without the headaches

with asp.net, php or
node.js, develop on
Windows, OSX or
Linux

deploy live in seconds,
easily monitor
performance, rapidly
diagnose and
fix issues
demo

Windows Azure
Web Sites
Architecture
Load balancer
Layers
1st layer: Windows Azure load balancer
2nd layer: IIS + ARR
ARR (disclaimer: not
)
“Reverse proxy”
Verifies hosting database (plans, quotas, …)
Negotiates best node to run your site on
Site not used much? Put it on a highly loaded machine
Web servers
%SYSTEM32%inetsrvconfigapplicationHost.config is taken out of the loop
SQL Azure
No refreshing of all app pools when file is saved
Storage
“File share” hosted on other machines
Using “WA drive” on blob storage
Dynamic website activation service
Verifies runtime database (plans, quotas, …)
Site not used for a while? Remove it from the server
Web Sites are not in IIS. They only
are when a request comes in!
1st request (cold site)
Web Worker
IIS ARR
(LB)

Azure
LB

Runtime
DB

Other
databases

Storage
Controller
xth request (hot site)
Web Worker
IIS ARR
(LB)

Azure
LB

Other
databases

Storage
Controller
Your app not being used for a while?
Provisioning, publishing, metering
Provisioning and publishing
Storage and database
!= launching a website on web farm
Metering
By web servers once a site is loaded
Reported back to runtime database
Provisioning, publishing, metering
IIS ARR
(LB)

Web Worker

SQL Azure

Site
Site
(W3WP.exe)
Site
(W3WP.exe)
(W3WP.exe)

Runtime
DB
Metering

Azure
LB

DWAS

Blob storage

Other
databas
es

Provisioning /
API Frontend

Deployment
Server

Storage
Controller

X-Drive

Windows Azure Worker
Role
demo

Let’s find some
proof…
Need more
proof?
Windows Azure Pack
(http://www.microsoft.com/enus/server-cloud/windowsazure-pack.aspx)
Or:
http://blog.maartenballiauw.be/
post/2012/07/24/Hands-onWindows-Azure-Services-forWindows.aspx
Project Kudu
Project Kudu
“The engine behind git deployments on Windows Azure”
Open source (www.github.com/projectkudu/kudu)
Provides git deployments
Provides builds

Provides sandboxing
Provides hosting
demo

Project Kudu
Pointers from the Kudu repository
Website extensions (analytics?)
Job runner / “worker role”
“KuduCalf”
(A Kudu is an Antelope. Its baby is a calf. A Kudu Calf is deployed from
Kudu.)
Kudu kung-fu
demo

Application log
streaming
Log streaming
All logs from the LogFiles/Application folder
Or configure it when querying: azure log tail <site> -p http
Settings
DIAGNOSTICS_LASTRESORTFILE -> file to log to when diagnostics go
wrong
DIAGNOSTICS_LOGGINGSETTINGSFILE -> settings file (json)
DIAGNOSTICS_TEXTTRACELOGDIRECTORY -> default folder
DIAGNOSTICS_TEXTTRACEMAXLOGFILESIZEBYTES-> log rotation
(bytes)
DIAGNOSTICS_TEXTTRACEMAXLOGFOLDERSIZEBYTES -> max log
size (bytes)
and secrets!

demo

Managing settings
demo

Staging and
production
Deploying a specific project file

demo

Multi-tier
Multi-tier remarks…
One .deployment file per branch
[config]
project=MultiTier.WebApi/MultiTier.WebApi.csproj
How do I deploy all tiers in a separate website?
.deployment file per branch and every tier in a branch
or customize the build
How do I deploy all tiers in the same website?
No .deployment file, just use virtual directories
Customizing the build process
Check https://github.com/projectkudu/kudu/wiki/Deployment-hooks
.deployment file
[config]
command=<whatever command>
Write in batch file, bash script, PHP, JavaScript, …
An introduction

demo

Customizing
deployments
What can I do in scripts?
A lot :-) (but not too much… there’s a sandbox)
Environment variables:
DEPLOYMENT_SOURCE
DEPLOYMENT_TARGET
DEPLOYMENT_TEMP
WEBROOT_PATH
MSBUILD_PATH
+ everything you feed it through the management portal
Sample deployment script

demo

Customizing
deployments
Great… but why?
We’ve seen the multi-tier scenario
We can download stuff (NuGet package restore, pull in external Git repos
before build)
We can run stuff (msbuild, nuget.exe, curl, php, node, …)
What about running unit tests?

demo

Customizing
deployments
Note: only in Kudu at this time!

demo

Running background
processes (workers)
Need. Moar!
Moar out of the box
REST API
https://github.com/projectkudu/kudu/wiki/REST-API

Creating a custom handler
http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-withdjango/
Need. MOAR!!!
A private Kudu build in web sites?
A private Kudu build in web sites?
Build and FTP the artifacts/debug/KuduService to your website
Add USE_PRIVATE_KUDU=1 app setting
Enjoy the ride! (but don’t call support, you’re on your own)

See http://blog.davidebbo.com/2012/06/developing-kudu-locally-and-on-azure.html
Conclusion
Key takeaways
Windows Azure Web Sites are high density
Hosted on Cloud Services
Kudu is our best friend
Settings and secrets
Muliple environments
Multiple tiers
Build customization
Unit tests
Worker roles
Kudu-in-Kudu
http://blog.maartenballiauw.
be
@maartenballiauw
http://amzn.to/pronuget

Thank you!
Windows Azure Web Sites - Things they don’t teach kids in school - BuildStuffLT

More Related Content

Windows Azure Web Sites - Things they don’t teach kids in school - BuildStuffLT

  • 1. Windows Azure Web Sites Things they don’t teach kids in school Maarten Balliauw @maartenballiauw
  • 2. Who am I? Maarten Balliauw Technical Evangelist, JetBrains AZUG Focus on web ASP.NET MVC, Windows Azure, SignalR, ... MVP Windows Azure & ASPInsider Big passion: Windows Azure http://blog.maartenballiauw.be @maartenballiauw Shameless self promotion: Pro NuGet http://amzn.to/pronuget2
  • 3. Saturday, March 29, 2014 http://global.windowsazurebootcamp.com 90+ locations last year, this year let’s go for a 100!
  • 4. Possibly the largest community event ever MVP’s Speakers Locations Attendees Sessions
  • 5. Agenda Windows Azure Web Sites Architecture Project Kudu Kudu kung-fu Application log streaming Managing settings Staging and Production Multi-tier deployments Customizing deployments Running batch files / background processes (*)
  • 7. Web Sites in Seconds Start Simple Your way Go Live start free, scale up and out as you go, friction-free and without the headaches with asp.net, php or node.js, develop on Windows, OSX or Linux deploy live in seconds, easily monitor performance, rapidly diagnose and fix issues
  • 10. Load balancer Layers 1st layer: Windows Azure load balancer 2nd layer: IIS + ARR ARR (disclaimer: not ) “Reverse proxy” Verifies hosting database (plans, quotas, …) Negotiates best node to run your site on Site not used much? Put it on a highly loaded machine
  • 11. Web servers %SYSTEM32%inetsrvconfigapplicationHost.config is taken out of the loop SQL Azure No refreshing of all app pools when file is saved Storage “File share” hosted on other machines Using “WA drive” on blob storage Dynamic website activation service Verifies runtime database (plans, quotas, …) Site not used for a while? Remove it from the server
  • 12. Web Sites are not in IIS. They only are when a request comes in!
  • 13. 1st request (cold site) Web Worker IIS ARR (LB) Azure LB Runtime DB Other databases Storage Controller
  • 14. xth request (hot site) Web Worker IIS ARR (LB) Azure LB Other databases Storage Controller
  • 15. Your app not being used for a while?
  • 16. Provisioning, publishing, metering Provisioning and publishing Storage and database != launching a website on web farm Metering By web servers once a site is loaded Reported back to runtime database
  • 17. Provisioning, publishing, metering IIS ARR (LB) Web Worker SQL Azure Site Site (W3WP.exe) Site (W3WP.exe) (W3WP.exe) Runtime DB Metering Azure LB DWAS Blob storage Other databas es Provisioning / API Frontend Deployment Server Storage Controller X-Drive Windows Azure Worker Role
  • 19. Need more proof? Windows Azure Pack (http://www.microsoft.com/enus/server-cloud/windowsazure-pack.aspx) Or: http://blog.maartenballiauw.be/ post/2012/07/24/Hands-onWindows-Azure-Services-forWindows.aspx
  • 21. Project Kudu “The engine behind git deployments on Windows Azure” Open source (www.github.com/projectkudu/kudu) Provides git deployments Provides builds Provides sandboxing Provides hosting
  • 23. Pointers from the Kudu repository Website extensions (analytics?) Job runner / “worker role” “KuduCalf” (A Kudu is an Antelope. Its baby is a calf. A Kudu Calf is deployed from Kudu.)
  • 26. Log streaming All logs from the LogFiles/Application folder Or configure it when querying: azure log tail <site> -p http Settings DIAGNOSTICS_LASTRESORTFILE -> file to log to when diagnostics go wrong DIAGNOSTICS_LOGGINGSETTINGSFILE -> settings file (json) DIAGNOSTICS_TEXTTRACELOGDIRECTORY -> default folder DIAGNOSTICS_TEXTTRACEMAXLOGFILESIZEBYTES-> log rotation (bytes) DIAGNOSTICS_TEXTTRACEMAXLOGFOLDERSIZEBYTES -> max log size (bytes)
  • 29. Deploying a specific project file demo Multi-tier
  • 30. Multi-tier remarks… One .deployment file per branch [config] project=MultiTier.WebApi/MultiTier.WebApi.csproj How do I deploy all tiers in a separate website? .deployment file per branch and every tier in a branch or customize the build How do I deploy all tiers in the same website? No .deployment file, just use virtual directories
  • 31. Customizing the build process Check https://github.com/projectkudu/kudu/wiki/Deployment-hooks .deployment file [config] command=<whatever command> Write in batch file, bash script, PHP, JavaScript, …
  • 33. What can I do in scripts? A lot :-) (but not too much… there’s a sandbox) Environment variables: DEPLOYMENT_SOURCE DEPLOYMENT_TARGET DEPLOYMENT_TEMP WEBROOT_PATH MSBUILD_PATH + everything you feed it through the management portal
  • 35. Great… but why? We’ve seen the multi-tier scenario We can download stuff (NuGet package restore, pull in external Git repos before build) We can run stuff (msbuild, nuget.exe, curl, php, node, …)
  • 36. What about running unit tests? demo Customizing deployments
  • 37. Note: only in Kudu at this time! demo Running background processes (workers)
  • 39. Moar out of the box REST API https://github.com/projectkudu/kudu/wiki/REST-API Creating a custom handler http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-withdjango/
  • 41. A private Kudu build in web sites?
  • 42. A private Kudu build in web sites? Build and FTP the artifacts/debug/KuduService to your website Add USE_PRIVATE_KUDU=1 app setting Enjoy the ride! (but don’t call support, you’re on your own) See http://blog.davidebbo.com/2012/06/developing-kudu-locally-and-on-azure.html
  • 44. Key takeaways Windows Azure Web Sites are high density Hosted on Cloud Services Kudu is our best friend Settings and secrets Muliple environments Multiple tiers Build customization Unit tests Worker roles Kudu-in-Kudu

Editor's Notes

  1. Maarten
  2. https://myget-docs-prod-eu-west.scm.azurewebsites.net/Display in browser and go through “environment”COMPUTERNAME “RD….”NUMBER_OF_PROCESSORS -&gt; x-large instancesAll ARR___ variables (cookies for affinity and so on)WAWebSiteSID for determining the website SIDApparently C:\DWASFiles\Sites\WAWSdeepdive seems “da bomb”Browse through the portal and note:All URLS for FTP and SCM are different hostnames and thus potentially a different group of servers
  3. Clone from git, run buildWhile build runs, explain what’s happening (NPM stage, …)Run Kudu.Webas administratorCreate a site, show folders, …KuduExec! – browse the filesystem and so onExplore someCd .. Until no more is possible and dir – show \\10,x,x,x
  4. Show logging applicationExplain nothing special configuredEnable through portalShow stream: azure site log tailstackedlogging(other options are download)Configure verbosity
  5. Create an application and use ConfigurationManager.AppSettings[&quot;MyKey&quot;] tospecify a ‘dev’ variable or somethingShow environment variable printingUpdate setting in portalFTP into the system and note that the web.config is UNTOUCHED!We can use this for storing secrets
  6. Show Hg repository in which I have created two branches: the default one and a “staging” oneConfigure one production websiteConfigure one staging websiteExplain hostnames, scaling, configuration and so on
  7. Explain solution structure: two web projectsCreate .deployment fileAdd:[config]project = MultiTier.WebApi/MultiTier.WebApi.csproj
  8. Create .deployment fileAdd:[config]command=deploy.cmdAdd deploy.cmd@echo offecho Comday is TEH AWESOME!echo We are deploying to %MYENV%- Set environment variable in portal
  9. Too long for slides!Run azure site deploymentscript --basicOr azure site deploymentscript –aspWAPRun through script
  10. Explain unit test projectDeploy with successDeploy with failure