280 likes | 414 Views
Windows Azure Advanced Scenarios. Name Title Microsoft Corporation. Agenda. Startup tasks Elevated privileges Remote Desktop Network traffic rules VM role. Startup Tasks. What Are Startup Tasks?. Introduced with SDK 1.3 (PDC ‘10). Commands executed before your role is started.
E N D
Windows Azure Advanced Scenarios Name Title Microsoft Corporation
Agenda Startup tasks Elevated privileges Remote Desktop Network traffic rules VM role
What Are Startup Tasks? Introduced with SDK 1.3 (PDC ‘10) Commands executed before your role is started Generally “scripts” Useful for prepping the VM (install/Config) Add lots of flexibility to Windows Azure
Why Do We Have Startup Tasks? Sometimes setup is required before execution “At the top of the code” isn’t good enough Elevated startup task, non-elevated role Scripting often easier than C# Reusable startup tasks “Upload a VHD” is overkill Often just need to run an MSI, unzip files Want full PaaS experience, including patching VM images aren’t very reusable
Startup Task Options Defined in ServiceDefinition.csdef Can run elevated or not Three execution modes: Simple (default) Foreground Background synchronous asynchronous, block shutdown asynchronous, don’t block shutdown
Startup Task Tips Log everything: command >> %~dp0log.txt 2>> %~dp0err.txt /y everything: copy /y foo bar echo y| cacls … [Note no space after “y”] Use local storage (guaranteed space) Reboots are fine, but don’t enter an infinite loop Use “psexec -s” to test (“local system” is a weird user) Consider “exit /b 0”
When Not To Use Startup Tasks Long, manual, or fragile installations Use VM Role Things that require the IIS pool to exist already Use OnStart() in an elevated web role Processes that need to be monitored (for the most part) Easier to write proc.Start();proc.WaitForExit();
Elevated Privileges for the Role Entire role can run elevated <Runtime executionContext="elevated" /> For web roles, doesn’t affect web app (IIS)
Remote Desktop For diagnostics/debugging Changes are not persisted Works through the load balancer
Remote Desktop ROLE 1 ROLE 2 IN_0 IN_0 LB PORT 3389 IN_1 IN_1 IN_2 Internal Port 3389 Remote Forwarder
Specifying Traffic Rules • ServiceDefinition.csdef: • <NetworkTrafficRules> • <OnlyAllowTrafficTo> • <Destinations> • <RoleEndpointendpointName="ServiceEndpoint" roleName="WorkerRole1" /> • </Destinations> • <WhenSourcematches="AnyRule"> • <FromRoleroleName="WebRole1" /> • </WhenSource> • …
Only Two Differences Who handles OS servicing How you package/deploy your application
Punchline: When to Use VM Role Long running application installations Error-prone application installations Application installations requiring manual interaction
VM Roles are fully integrated in the Windows Azure Platform-as-a-Service model
WA Programming Model: Three Rules 1 A Windows Azure application is built from one or more roles 2 A Windows Azure application runs multiple instances of each role 3 A Windows Azure application behaves correctly when any role instance fails
Benefits of This Model Lower administrative costs More scalable applications More available applications VM Role has these same benefits (and constraints)
Windows Azure Application Platform • • • • • •
Platform Capabilities and App Contract Stateless Images Consistent updates Consistent configuration Multi-instance management Multiple Instance Scale-out High Availability Not all applications can be migrated! • • • • •
VM Role Doesn’t Mean Single-Instance 2 Rule #2: A Windows Azure application runs multiple instances of each role No high-availability without multiple instances
VM Role Doesn’t Mean “Stateful” 3 Rule #3: A Windows Azure application behaves correctly when any role instance fails Running a database? Think about how the data is replicated
The Tradeoff VM roles and web/worker roles can do the same things We’re back to the two differences: Who handles OS servicing How you package/deploy your application To choose, consider: Development cost/effort Operating cost (OS maintenance) VM startup time Skills/resources available
Summary Lots of flexibility Startup tasks + elevated privileges = EVERYTHING VM Role available for more control