Real World Windows Azure Development – Tips & Tricks Wade Wegner Windows Azure Technical Evangelist Microsoft Corporation.

Download Report

Transcript Real World Windows Azure Development – Tips & Tricks Wade Wegner Windows Azure Technical Evangelist Microsoft Corporation.

Real World Windows Azure
Development – Tips & Tricks
Wade Wegner
Windows Azure Technical Evangelist
Microsoft Corporation
Agenda
Role Enhancements
Using RDP with Windows Azure
Startup Tasks
Externalizing State
Full IIS Support
Dynamic Deployment
Virtual Machine Role
Windows Azure Toolkit for WP7
…
Demos, demos, demos!
Additional Information
I will post all code and details here:
http://www.wadewegner.com/
Role Enhancements
Additional control and flexibility on the Windows Azure environment and simplified migration of
existing Windows applications to Windows Azure.
Windows Server 2008 R2 & IIS 7.5
Admin Access: Full administrative access to your role instances
Reboot/Re-image support: Ability to easily reboot or re-image your instances
Remote Desktop: Ability to use Remote Desktop with any Role type (Web, worker, VM)
Network Modeling
Well Known Ports: Easier to bring your existing applications to Windows Azure
Port Ranges: for “inbound traffic” (as opposed to 5 in the past)
Network Filters: Enable traffic filtering between roles within a service
Improved Automation
Startup Tasks: Includes scripts that automate the preparation and configuration of roles
Role Plugins: Ability to easily include “plug-ins” in the service definition
(e.g., built-in: remote desktop, virtual network, diagnostics. More samples to come)
RDP with Windows Azure
Portal integrated Remote Desktop access to instances
within your deployment
Use standard Remote Desktop client
Support for all three role types – Web, worker, and VM
Dynamic configuration of Remote Desktop settings
Credentials
Enable/Disable
Expiration of credentials
Ability to take instances on/off the load balancer for
debugging
Configuring and Using RDP
DEMO
Startup Tasks
Simple way to run code during your Windows Azure role’s
initialization
Update the ServiceDefinition.csdef file:
<Startup>
<Task commandLine="startup.cmd“ executionContext="elevated" />
</Startup>
Add the command to the package
Startup Task Types
Simple (Default): (Synchronous) In this case the task is
launched and forward progress in the instance is
blocked until the task is complete.
Background: (Asynchronous Fire and Forget) In this
case the task is launched and role starts up
continues.
Foreground: (Asynchronous) Similar to Background,
but role shutdown can only happen when all the
foreground tasks exit.
Tip #1: Batch files
Create batch files to execute your commands
Be sure to save as “Unicode (UTF8 without signature)
codepage 65001” in Visual Studio (or use NotePad)
Tip #2: Debug locally
If you put start /w cmd in a batch file, it will pop up a
new command window and wait for it to exit
start /w "%~dp0\YourCommand.cmd"
Useful for testing startup tasks locally
Tip #3: Background tasks
“Simple” startup tasks (the default type) run to
completion before putting the VM in the ready state
If your startup tasks fails, you can’t RDP to connect
and debug
For development, set the startup type to “background”
Then you can RDP in and see what’s happening
Tip #4: Log to a file
Try to log to a file whenever possible, because
sometimes you can’t RDP in fast enough to watch
command1 >> log.txt 2>> err.txt
command2 >> log.txt 2>> err.txt
...
Tip #5: PowerShell scripts
You need to configure PowerShell to execute
unsigned PowerShell scripts
PowerShell 2.0
powershell -ExecutionPolicy Unrestricted ./myscript.ps1
PowerShell 1.0
reg add
HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.
PowerShell /v ExecutionPolicy /d Unrestricted /f
Tip #6: 32-bit Installers
When installing 32-bit applications in a 64-bit environment, as an elevated startup
tasks, the system can get confused
The installer will use the wrong “Local AppData” folder
md "%~dp0appdata“
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user
shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
…
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user
shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d
%%USERPROFILE%%\AppData\Local /f
Tip #7: PsExec & sys user
PsExec makes it easy to launch your scripts as the
system user when RDP’d into the VM
psexec –s -i cmd
Windows Azure Encoder
DEMO
Externalizing State
Windows Azure storage?
SQL Azure?
…
Windows Azure AppFabric Caching
Externalizing Session State
with Windows Azure
AppFabric Caching
DEMO
Takeaways
Easy to setup and no management
Simply API that’s symmetric to Windows Service
AppFabric Caching
Useful scenarios:
Session State
Page Output Caching
Explicit Caching (e.g. reference, activity, resource
data)
Full IIS Support
Leverage the ecosystem of IIS applications, programming
languages tools, and components with the revamped Web role
Multiple Web sites and applications
Improved iterative local development with the Development
Fabric
Iterative cloud development with Web Deploy and IIS Manager
Host level configuration, including native modules
Enhanced by Windows Azure automated service management
Extend the Service Model
Multiple Applications in IIS
DEMO
Takeaways
With the Windows Azure SDK 1.3 (or higher) you
now have Full IIS support
Multiple sites
Virtual applications
Virtual directories
Extend the Service Model
Dynamic Deployment
DEMO
Virtual Machine Role
VM Role provides additional control and flexibility on the
Windows Azure environment, and makes it easy to run
existing Windows applications on Windows Azure.
Developers / IT Pros have full control over the OS image
Ability to upload your own customized WS08R2
Enterprise images
Operators can reboot, reimage and Remote Desktop
Mark Russinovich: VM Role
“… let me restate that the only reason
to use them instead of worker roles is
… for the migration of Windows
Server applications that have long,
non-scriptable or fragile installation
steps.”
“… While the VM role offers additional control and flexibility, the
Windows Azure Web and Worker roles offer additional benefits over
the VM role.”
VM Role
DEMO
WAZ Toolkit for WP7
Designed to make it easier for WP7 developers to use
Windows Azure
Includes
Project templates
Class libraries
Services (e.g. push notification, membership, &
storage)
Samples
Documentation
Get it: http://watoolkitwp7.codeplex.com
Session Takeaways
Understand the Cloud fundamentals
Know what makes up the Windows Azure Platform
Go build some applications!
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.