39
Automating and Managing Windows Azure Solutions with Powershell Tom Fuller Windows Azure – Technology Solution Professional @DeveloperTofu http://developertofu.com

Automating and Managing Windows Azure Solutions with Powershell

  • Upload
    base

  • View
    64

  • Download
    2

Embed Size (px)

DESCRIPTION

Automating and Managing Windows Azure Solutions with Powershell. Tom Fuller Windows Azure – Technology Solution Professional @ DeveloperTofu http://developertofu.com . Who is Tom Fuller?. - PowerPoint PPT Presentation

Citation preview

Page 1: Automating and Managing Windows Azure Solutions with  Powershell

Automating and Managing Windows Azure Solutions with PowershellTom FullerWindows Azure – Technology Solution Professional@DeveloperTofuhttp://developertofu.com

Page 2: Automating and Managing Windows Azure Solutions with  Powershell

Who is Tom Fuller?

In 2010, the family moves to Atlanta, GA from Tampa, FL

I lived in Buffalo, NY until I left for college and yes, I am still a Buffalo Bills fan but no, I do not miss the snow

2 Years as MVP, 5 Years as Microsoft Field Engineer, recently took role as Azure specialist

12 years in dev focused roles like architect, web developer lots of work with large enterprises in the US

A fun challenge, coaching a 5 and under girls team

Active speaker, writer, blogger developertofu.com or @DeveloperTofu

Page 3: Automating and Managing Windows Azure Solutions with  Powershell

Cloud ComputingPackaged Software

Storage

Servers

Networking

O/S

Middleware

Virtualization

Data

Applications

Runtime

You

man

age

Infrastructure(as a Service)

Storage

Servers

Networking

O/S

Middleware

Virtualization

Data

Applications

Runtime

Managed by vendor

You

man

age

Platform(as a Service)

Managed by vendor

You

man

age

Storage

Servers

Networking

O/S

Middleware

Virtualization

Applications

Runtime

Data

Software(as a Service)

Managed by vendor

Storage

Servers

Networking

O/S

Middleware

Virtualization

Applications

Runtime

Data

Page 4: Automating and Managing Windows Azure Solutions with  Powershell

Cloud Computing Patterns

tCom

pute

InactivityPeriod

t

t

t

On and OffOn & off workloads (e.g. batch job)Over provisioned capacity is wasted Time to market can be cumbersome

Unpredictable BurstingUnexpected/unplanned peak in demand Sudden spike impacts performance Can’t over provision for extreme cases Co

mpu

te

Growing FastSuccessful services needs to grow/scale Keeping up w/ growth is big IT challenge Cannot provision hardware fast enoughCo

mpu

te

Predictable BurstingServices with micro seasonality trends Peaks due to periodic increased demandIT complexity and wasted capacity

Com

pute

Page 5: Automating and Managing Windows Azure Solutions with  Powershell

Windows AzureComprehensive set of services that enable you to quickly build, deploy and manage applications across a global network of Microsoft-managed datacenters

Solid

Open

Flexible

Page 6: Automating and Managing Windows Azure Solutions with  Powershell

Global Footprint

Page 7: Automating and Managing Windows Azure Solutions with  Powershell

99.95% monthly SLA

Page 8: Automating and Managing Windows Azure Solutions with  Powershell

Pay only for what you use

Page 9: Automating and Managing Windows Azure Solutions with  Powershell

Cloud services Web sites Virtual machines

Page 10: Automating and Managing Windows Azure Solutions with  Powershell

infrastructure for building andrunning your applications

applicationbuilding

blocksstorage

big data

caching

CDN

database

media

networking

traffic manager

virtualmachines

web sites

cloud services

compute

service bus

identity

mobile

Page 11: Automating and Managing Windows Azure Solutions with  Powershell

Windows Azure Cloud Services (Stateless VM’s)

Web Role Worker Role

Virtual machines in the CloudTwo Flavors:

A place for your application code to run…Web role is simply a Virtual Machine with IIS pre-configuredWorker role is for non-web based processing code, back-end business processesYou can actually connect to your web/worker roles – they are just VM’sYou package your code/artifacts and Windows Azure bootstraps a VM, installs the code and starts up the VM for you. Load balances multiple instances

compute data management networkingSQL

databasenoSQL

databasewebsites blob connectvirtual

networktraffic

managerVMscloud

services

Page 12: Automating and Managing Windows Azure Solutions with  Powershell

Windows Azure Virtual Machines

Management Portal

Scripting (Windows, Linux and Mac)

compute data management networkingSQL

databasenoSQL

databasewebsites blob connectvirtual

networktraffic

managercloud

services

REST API

Getting Started Select Image and VM Size New Disk Persisted in Storage

Boot VM from New Disk

VMs

Page 13: Automating and Managing Windows Azure Solutions with  Powershell

Windows Azure Web SitesQuickly and easily deploy sites to a highly scalable cloud environment with the frameworks and open source apps of your choice using Windows Azure Web Sites

Supports multiple frameworks (ASP.NET, Classic ASP, PHP, Node.js)

Pick from popular Open Source apps Pick your DB (SQL Azure, MySQL)

Choose your tools (Visual Studio, Git, FTP, WebMatrix)

Build on any platform (Windows, Mac, Linux)

compute data management networkingSQL

databasenoSQL

database blob connectvirtual

networktraffic

managercloud

services VMs

GIT : FTP

GIT : FTP

GIT : FTP Web Deploy : TFS Deploy

Supported Deployment Protocols

websites

Page 14: Automating and Managing Windows Azure Solutions with  Powershell

Management

Page 15: Automating and Managing Windows Azure Solutions with  Powershell

Service Management API for Managing and Monitoring Applications in Windows Azure

Provides programmatic access to platform functionality

Used to deploy, manage, and monitor applications

Powerful REST API, performed over SSL and mutually authenticated using X.509 certificatesMay be accessed from within application running in Windows Azure, or directly over the Internet from any application

PowerShell commands using the same APIs can be used to script management functions

Page 16: Automating and Managing Windows Azure Solutions with  Powershell

What can you do with PowerShell?

AutomationQuery, Manage and Configure Virtual Machines across multiple subscriptions, cloud services and storage accounts.

Virtual NetworkingCompletely Configure VNETs from a Script

Provision Fully Configured Virtual MachinesDomain JoinedStorage and Networking Configured

Remote ManagementManage SQL Databases, Configuration, Diagnostics, Deployments, and Azure assets (Affinity Groups, Storage Accounts, Keys, etc..)

Page 17: Automating and Managing Windows Azure Solutions with  Powershell

Getting StartedUse: Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFileTo Import Downloaded Publish Profile (.publishsettings) http://windows.azure.com/download/publishprofile.aspx

Automatically configures Subscription ID, Certificate, Service Endpoint and Subscription Name.

Multiple Subscription Support Get-AzureSubscription | foreach { Select-AzureSubscription $_.SubscriptionName # Perform Management Operation Against Each Subscription}

Page 18: Automating and Managing Windows Azure Solutions with  Powershell

DemoGetting Started with Azure Subscription Credentials in Powershell

Page 19: Automating and Managing Windows Azure Solutions with  Powershell

Virtual Machine ManagementQuick VM Provisioning ModeSupports VM Creation in a Single Cmdlet

Create Multiple Pre-Defined VMs in a BatchNew-AzureVM -VMs $vm1, $vm2, $vm3

Advanced Provisioning Configuration ModeProvision With: Endpoints, Data DisksConfigure: Cache Settings for OS/Data Disks and Subnet Names

Page 20: Automating and Managing Windows Azure Solutions with  Powershell

Setting the current storage account

Returns Storage AccountGet-AzureStorageAccount | Select StorageAccountName

Cmdlets like New-AzureQuickVM will use this Account

Sets the Current Storage AccountSet-AzureSubscription 'somesub1' -CurrentStorageAccount 'mystorage‘

Page 21: Automating and Managing Windows Azure Solutions with  Powershell

Information Needed to create a VM

Image NameGet-AzureVMImage | select ImageName

Disk NameGet-AzureDisk | select DiskName

Data Center LocationGet-AzureLocation

Page 22: Automating and Managing Windows Azure Solutions with  Powershell

Simple VM CreationFirst Virtual Machine in a NEW Cloud Service (-Location specified)New-AzureQuickVM -Windows -ServiceName $svc -Name $vm1 -ImageName $wimg -Location $location -Password $pwd

New Virtual Machine in an Existing Cloud Service (no –Location)New-AzureQuickVM -Windows -ServiceName $svc -Name $vm2 -ImageName $wimg -Password $pwd

Creating a Linux Virtual Machine in an Existing Cloud ServiceNew-AzureQuickVM -Linux -ServiceName $svc -Name $vm3 -ImageName $limg -LinuxUser $lu -Password $pwd

Page 23: Automating and Managing Windows Azure Solutions with  Powershell

Virtual Machine DiscoveryRetrieve Cloud Services Get-AzureService

Retrieve Virtual Machines for Service Get-AzureVM -ServiceName $cloudSvcName

Retrieve Status for All VMs in SubsriptionGet-AzureService | foreach { $_ | Get-AzureVM | ft ServiceName, Name, InstanceStatus}

Page 24: Automating and Managing Windows Azure Solutions with  Powershell

Common SettingsNameThe name of the Virtual Machine

InstanceSizeExtraSmall, Small, Medium, Large, ExtraLarge

AvailabilitySetNameThe availability set (used for high availability)

Page 25: Automating and Managing Windows Azure Solutions with  Powershell

Provisioning Options

Add-AzureProvisioningConfig Options-Windows -Password $pwd-WindowsDomain -Password $pwd -Domain $dom, -JoinDomain $fqdn, -DomainUser $domUser -DomainPassword $domPwd -MachineObjectOU $ou-DisableAutomaticUpdates-NoRDPEndpoint, -TimeZone, Certificates

Add-AzureProvisioningConfig OptionsLinux -LinuxUser $user -Password $pwd -DisableSSH , -NoSSHEndpoint -SSHKeyPairs, -SSHPublicKeys installed from certificates deployed in cloud service

Page 26: Automating and Managing Windows Azure Solutions with  Powershell

Configuring a VM at Provision Time

Create Configuration Object with New-AzureVMConfigModify with Add-* cmdletsAdd with New-AzureVM

New-AzureVMConfig -Name $vm1 -InstanceSize Medium -ImageName $img | Add-AzureProvisioningConfig -Windows -Password $pwd | Add-AzureDataDisk -CreateNew -DiskLabel 'data' -DiskSizeInGB 10 -LUN 0 | Add-AzureEndpoint -Name 'web' -PublicPort 80 -LocalPort 80 -Protocol tcp | New-AzureVM -ServiceName $newSvc -Location $location

Page 27: Automating and Managing Windows Azure Solutions with  Powershell

Virtual Machine StorageData DisksAdd/Remove data disks at boot or while runningCreate blank or attach existing disks

Modify Cache Settings of OS Disk or Data DiskModifying OS Disk while running requires reboot

Page 28: Automating and Managing Windows Azure Solutions with  Powershell

Data Disk CreationNew Virtual Machine Creation with Data DiskNew-AzureVMConfig -Name 'myvm1' -InstanceSize 'Small' -ImageName $img | Add-AzureProvisioningConfig -Windows -Password $pwd | Add-AzureDataDisk -CreateNew -DiskSizeInGB 10 -DiskLabel 'myddisk' -LUN 0 | New-AzureVM -ServiceName $cloudSvcName

Add new Data Disk to existing Virtual MachineGet-AzureVM -ServiceName 'myvm1' | Add-AzureDataDisk -CreateNew -DiskSizeInGB 10 -DiskLabel 'myddisk' -LUN 1 | Update-AzureVM

Page 29: Automating and Managing Windows Azure Solutions with  Powershell

Deploying into a Virtual Network

Virtual Machine SettingsSet Subnet on VM with Set-AzureSubnet

Deployment SettingsSet Virtual Network -VNetName Set DNS Servers - New-AzureDns and -DNSSettings

Page 30: Automating and Managing Windows Azure Solutions with  Powershell

Provision into a VNET and AD$dom = 'contoso'$jdom = 'contoso.com'$onPremDNS = New-AzureDns -IPAddress '192.168.1.4' -Name 'OnPremDNS'$cloudDNS = New-AzureDns -IPAddress '10.1.1.4' -Name 'CloudDNS'$computerOU = $advmou = 'OU=AzureVMs,DC=contoso,DC=com‘

New-AzureVMConfig -Name 'myvm1' -InstanceSize 'Small' -ImageName $img | Add-AzureProvisioningConfig -WindowsDomain -Password $pwd -Domain $dom ` -DomainUserName $domUser -DomainPassword $dpwd -JoinDomain $jdom ` -MachineObjectOU 'AzureVMs' | Set-AzureSubnet -SubnetNames 'AppSubnet' | New-AzureVM –ServiceName $svc -AffinityGroup 'adag' ` -VNetName 'ADVNet' -DnsSettings $onPremDNS, $cloudDNS

Page 31: Automating and Managing Windows Azure Solutions with  Powershell

DemoProvisioning and updating a new Virtual Machine from Powershell

Page 32: Automating and Managing Windows Azure Solutions with  Powershell

Automation

Page 33: Automating and Managing Windows Azure Solutions with  Powershell

Adding and Removing InstancesUpdate a running role to have more or less instancesSet-AzureRole –ServiceName "MySvc1" –Slot "Production" –RoleName "MyTestRole3" –Count 3

Page 34: Automating and Managing Windows Azure Solutions with  Powershell

VM Batch CreationCreate Multiple Configured VMs and Pass to New-AzureVM$vm1 = New-AzureVMConfig -Name 'myvm1' -InstanceSize 'Small' -ImageName $img | Add-AzureProvisioningConfig -Windows -Password $pwd

$vm2 = New-AzureVMConfig -Name 'myvm1' -InstanceSize 'Small' -ImageName $img | Add-AzureProvisioningConfig -Windows -Password $pwd $vm3 = New-AzureVMConfig -Name 'myvm1' -InstanceSize 'Small' -ImageName $img | Add-AzureProvisioningConfig -Windows -Password $pwd New-AzureVM -CreateService -ServiceName $cloudSvcName -VMs $vm1,$vm2,$vm3 -Location $dc

Page 35: Automating and Managing Windows Azure Solutions with  Powershell

Disk and Image Repository

OS Images

Get-AzureVMImage # Return all Get-AzureVMImage | Where { $_.Category -eq 'Microsoft' } # Return Microsoft Get-AzureVMImage | Where { $_.Category -eq 'User' } # Return CustomGet-AzureVMImage | Where { $_.Category -eq 'Partner' } # Return Partner ImagesGet-AzureVMImage | Where { $_.OS -eq 'Windows' } # Return only Windows OS imagesRemove-AzureVMImage -ImageName 'myimg' -DeleteVHD # Delete image and storageAdd-AzureVMImage -OS 'Windows' -ImageName 'MyWinImage' -MediaLocation 'http://storageaccount/vhds/winimage.vhd' # Add Existing VM Image from Storage

Disks

Get-AzureDisk # Return all Get-AzureDisk | Where { $_.AttachedTo -eq $null } # Return all not attached to a VMGet-AzureDisk | Where { $_.OS -eq $null } # Return only data disks Get-AzureDisk | Where { $_.OS -eq 'Windows' } # Return only Windows OS disksRemove-AzureDisk -DiskName 'mydisk' -DeleteVHD # Delete disk and storageAdd-AzureDisk -OS 'Windows' -DiskName 'MyWinDisk' -MediaLocation 'http://storageaccount/vhds/winosdisk.vhd‘ # Add Existing OS Disk from Storage Add-AzureDisk -DiskName 'MyDataDisk' -MediaLocation 'http://storageaccount/vhds/datadisk.vhd‘# Add Existing Data Disk from Storage

Microsoft, Partner and User

OS Disks or Data Disks

Page 36: Automating and Managing Windows Azure Solutions with  Powershell

Batch Updating Running VMsRemove RDP and Add New Storage Across all Web Front Ends

Get-AzureVM -ServiceName $svc | Where { $_.Name -match 'wfe' } | foreach { $_ | Remove-AzureEndpoint -Name 'rdp' | Add-AzureDataDisk -CreateNew -DiskSizeInGB 10 -LUN 1 -DiskLabel 'newstorage' | Update-AzureVM}

Page 37: Automating and Managing Windows Azure Solutions with  Powershell

DemoAutomating Scale Up of a Web Role with Powershell

Page 38: Automating and Managing Windows Azure Solutions with  Powershell

Get Startedhttp://WindowsAzure.com

Page 39: Automating and Managing Windows Azure Solutions with  Powershell

Q&A