elevating windows azure deployments (visual studio live - las vegas 2013)
DESCRIPTION
One of the core tenants for working with cloud services is automation. When it comes to deploying our new cloud solutions, we want to automate the process as much as possible too. Both Visual Studio and the Windows Azure online management portal make deployments pretty easy - but it's manual. By leveraging tools like PowerShell we can automate much of the mundane deployment tasks, allowing us to have confidence in the final solution. We can further enhance our build and deploy solution by leveraging TFS - giving us continuous cloud deployments! Besides covering deployment options with PowerShell and TFS, in this session we'll also discuss techniques for handling the inevitable updates of our cloud services. Coming away from this session you'll have a solid understanding, backed by practical real-world examples, of handling service deployments and updates. This session was presented at Visual Studio Live (Las Vegas, March 2013).TRANSCRIPT
Elevating Windows Azure Deployments
Michael S. CollierNational Architect, Cloud
Level: Intermediate
About Me
Michael S. Collier
National Architect, Cloud
@MichaelCollier
www.MichaelSCollier.com
http://www.slideshare.net/buckeye01
Today’s Agenda
• Authentication• Visual Studio• PowerShell• TFS• Command Line Options
• Build & deployment process crucial to any project.– Easily overlooked initially.– Good tools and/or process
are worth the time.
Why?
• Windows Azure – nearly everything is automated.
• Scale makes automation a necessity.
• Failure to automate puts projects at risk
• Several deployment options available with Windows Azure.
Automation is the Key
Management PortalGreat for quick deployments or updates.
Need to have deployment package and config prepared.
Windows Azure Deployment Options
Visual StudioVery low developer friction – wizards make it easy.
Automatically handles some of the necessary tasks
Windows Azure Deployment Options
PowerShellVery powerful – can do pretty much anything from PowerShell.
Slight learning curve if not familiar with PowerShell.
Windows Azure Deployment Options
Management APIThe native interface – everything else uses the management API.
More code to write – build your own tools or processes.
Windows Azure Deployment Options
• Team Foundation Server– Tap into existing build workflows.– Need to understand how to edit
build tasks and workflows.– Use PowerShell script or MSBuild
target to deploy.
• Team Foundation Service– Already includes workflow to build
and deploy.
• Everything requires some form of authentication.
Windows Azure Deployment Options
Microsoft Account
• Used only with Windows Azure Management Portal.• Can delegate co-admin access to other Microsoft Accounts.
https://manage.windowsazure.com
Management Certificate
• Identifies you with Windows Azure– X509 certificate.– Can create yourself or have Windows Azure create one for you.– Anything that uses the management API (Visual Studio, PowerShell, TFS, etc.)
• Key Management– Upload the .cer file to the Windows Azure management portal.– You keep the private key in your certificate store.
Create a Cert using IIS
• Quick and easy, but limited control– IIS Management Console
Server CertificateLink to ‘Create Self-Signed Certificate’Provide a name – file in Local Computer\Personal store
– Export the PFX to a CER without the private keyAdd Certificate snap-in for MMCFind certificate and Export
Create a Cert using IIS
• Quick and easy, but limited control– IIS Management Console
Server CertificateLink to ‘Create Self-Signed Certificate’Provide a name – file in Local Computer\Personal store
– Export the PFX to a CER without the private keyAdd Certificate snap-in for MMCFind certificate and Export
Create a Cert using IIS
• Quick and easy, but limited control– IIS Management Console
Server CertificateLink to ‘Create Self-Signed Certificate’Provide a name – file in Local Computer\Personal store
– Export the PFX to a CER without the private keyAdd Certificate snap-in for MMCFind certificate and Export
• Import a Certificate via a .publishsettings file– Created automatically by visiting
https://windows.azure.com/download/publishprofile.aspx
– Contains a base64 encoded certificate (w/ the private key).
• Advantages– Fast and easy – minimal developer
friction.
• Disadvantages– Certificate created in every subscription
associated with your Microsoft Account.– Can’t control the certificate name
(<subscription_name>-<date_created>-credentials)
– Easy to hit 25 certificate limit within a subscription or Microsoft Account.
Import a Cert from Windows Azure
• Protect Your Secrets– Delete the .publishsettings file after
import (or at least keep someplace safe).– Visual Studio places local file at
%UserProfile%\My Documents\Visual Studio 2012\Settings\Windows Azure Connections.xml.
Import a Cert from Windows Azure
Create a Cert using MAKECERT
• Offers a great deal of control.• Create a .cmd file for easy reuse & share with team.
One line
CREATING A CERT ANDMANUAL CONFIGURATION
demo
Visual Studio Deployment• Create a Project
– New Windows Azure Cloud Service project.– Add Windows Azure deployment to existing
project.
• Authenticate– Import certificate from a .publishsettings file.– Use an existing certificate.
Load certificate to the management portal.Associate certificate with Visual Studio.
• Publish– Visual Studio verifies deployment package.– Creates new Cloud Service (if necessary).– Uploads package (.cspkg and .cscfg) to blob
storage and deploys.
More details at http://msdn.microsoft.com/en-us/library/ee460772.aspx
Where are the Files?
• Visual Studio publish location– Temporarily stored at <storage_account>\vsdeploy\<guid>
• Keep deployment files in blob storage for easy & fast deployments in the future.
• No need to re-upload – deploy from blob storage.
PowerShell Deployment
• Automate as much as possible.– Figure out the process first.– Automate the tedious and error prone – like deployments.– Save time and frustrations.
• One script for all.– One script for local and source control builds (TFS).– Share across a team – everybody follows the same process.
PowerShell Deployment
Getting Started• Download from
https://www.windowsazure.com/en-us/manage/downloads/ – Officially supported cmdlets – not the previous version on CodePlex.– Not everything from previous version has made it over yet (e.g. storage)
• Import module– Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\
PowerShell\Azure\Azure.psd1“
• Authenticate– Import certificate from a .publishsettings file or use an existing certificate.
• Subscription– Select a subscription and a storage account for deployments– Default location - %userprofile%\AppData\Roaming\Windows Azure Powershell
BUILD & DEPLOY WITH POWERSHELL
demo
Leverage Team Foundation Service
• Includes pre-built deployment workflow.– Use default settings– Override settings to customize
deployment (name, storage account, slot, label, etc.)
– See full tutorial at https://www.windowsazure.com/en-us/develop/net/common-tasks/publishing-with-tfs/
• Currently in Preview
Leverage Team Foundation Service
• Includes pre-built deployment workflow.– Use default settings– Override settings to customize
deployment (name, storage account, slot, label, etc.)
– See full tutorial at https://www.windowsazure.com/en-us/develop/net/common-tasks/publishing-with-tfs/
• Currently in Preview
BUILD & DEPLOY WITHTEAM FOUNDATION SERVICE
demo
PowerShell and TFS
• Execute PowerShell script from TFS build workflow– Call to the same PowerShell script created previously.– Edit build definition to accept input parameters for the PowerShell script.
Enabling Continuous Deployment
• Check-in the source code.• Package and deploy to Windows Azure.
• NOT cost efficient!– Deployed services cost money regardless of use.– Each time a service is deleted and deployed == 1 hour cost charge.
Build Server Configuration
• Not “hard”, but somewhat time consuming.– Turn on logging in the build – very helpful in understanding why something doesn’t work.
• Several misc. components to install manually.– Developer workstations – Web PI often handles these things for you as part of Visual Studio
setup.
• Give build service account at least Read access to mgmt. certificate.• What You May Need
– .NET Framework version(s)– Windows Azure Authoring Tools– Windows Azure Tools for Visual Studio– Windows Azure PowerShell Cmdlets– Microsoft.WebApplications.targets file (copy from computer w/ Visual Studio installed)– Management Certificate
POWERSHELL AND TFSdemo
• Service Bus– Create & manage namespaces
• Cloud Services– List & delete services– Manage service certificates
• Storage Account– Create & manage
• Websites– Create & manage– Download logs– Manage deployments– Github integration
• Virtual Machines– Create & manage– Endpoints & images
• Mobile Services– Create & manage– Tables, scripts, & configuration– Logs
Cross Platform Tools (command line)
• Command reference at http://www.windowsazure.com/en-us/manage/linux/other-resources/command-line-tools/
• Check out https://github.com/windowsazure/azure-sdk-tools-xplat for bug list and updates. Look at the dev branch to see the future!
Get the Tools
• Get node.js– http://nodejs.org– npm install –g azure-cli– V0.8.x
• Get node.js– Windows installer– http://go.microsoft.com/fwlink/
?LinkID=275464&clcid=0x409
Easy Git integration
Windows Azure xPlat CLI
> azure site create -–location “East US” –-git MySiteName> notepad default.htm> git add .> git commit –m “initial commit”> git push azure master
CONTINUOUS DEPLOYMENT WITH WEB SITES
demo
Support for Logical Environments• Different Windows Azure projects for different logical
environments– Handle differences in .csdef (i.e. machine size).
• Different build definitions - different environments.– Different configuration settings (instance count, connection strings, etc.)– Adjust input parameters to match the environment.
Storage account nameService nameDeployment slot. . .
Development
Staging
Production
CS CS
CS DB
CS CS
CS DB
QA
Staging
Production
CS
DB
CS
DB
Production
Staging
Production
CS
CS
DB
Command Line
Visual Studio TFSPowerShell
Multiple paths availablePick an authentication approach that works for you – understand the pros and cons.Automate as much as possible – invest early and save yourself time and money later.
Windows Azure Deployments
• Windows Azure Guidance– https://www.windowsazure.com/en-us/develop/net/Guidance/
• Windows Azure Training Kit– https://www.windowsazure.com/en-us/develop/net/other-resources/training-kit/
• Windows Azure Continuous Delivery– https://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-d
elivery/
• Deploy Cloud Services with Visual Studio– http://msdn.microsoft.com/en-us/library/ee460772.aspx
• Windows Azure Web Sites Cheat Sheet– http://windowsazurewebsitescheatsheet.info
Resources
Q &
A
Ask your questions
Thank You!!Michael S. Collier
National Architect, Cloud
@MichaelCollier
www.MichaelSCollier.com
http://www.slideshare.net/buckeye01
Please fill out your session evals!