Azure Expert Leading Camp UA - 2015

Preview:

Citation preview

Oleg Chorny IT Operations, Edgar OnlineMicrosoft SPDS MVP

Azure Camp UAPart II: Infrastructure as a Code

Anton VidishchevProgram Manager, Edgar OnlineMicrosoft Azure MVP

Microsoft Azure Virtual Machines Windows Azure PowerShell PowerShell Desired State Configuration Azure PowerShell DSC

Agenda

Microsoft Azure Virtual Machines

Services in the Cloud On-premises IaaS PaaS SaaS

Data

Runtime

Middleware

OS

Virtualization

Servers

Storage

Networking

Applications

Data

Runtime

Middleware

OS

Virtualization

Servers

Storage

Networking

Applications

Data

Runtime

Middleware

OS

Virtualization

Servers

Storage

Networking

Applications

Data

Runtime

Middleware

OS

Virtualization

Servers

Storage

Networking

Applications

Man

ag

ed

by y

ou

r org

an

izati

on

Man

ag

ed

by y

ou

r org

an

izati

on

Man

ag

ed

by

ven

dor

Man

ag

ed

by

ven

dor

Man

ag

ed

by y

ou

r org

an

izati

on

Man

ag

ed

by y

ou

r org

an

izati

on

Man

ag

ed

by

ven

dor

Reliability Scalability Elasticity Load balancing High availability Automation Disaster Recovery

Microsoft Azure

Complex Solutions for Enterprise Workloads

Microsoft Azure VM: D series

Demo & Practice:

Creating a Virtual Machine using the Azure

Portal

Microsoft Azure Virtual Machines

Windows Azure PowerShell

Windows PowerShell PowerShell Desired State Configuration PowerShell ISE OneGet cmdlets PowerShellGet cmdlets Network Switch cmdlets

Windows Management Framework 5.0 Preview

We want Telnet Client to be installed: PowerShell$featureName = "telnet-client"

$result = Get-WindowsFeature $featurename

if ($result.InstallState -eq "Installed") { Write-host "$featureName already installed"}

else { Write-host "$featureName is not installed, going to install it" Install-WindowsFeature $featureName }

Install Azure PowerShell Connect to your subscription

Azure AD method - RecommendedAdd-AzureAccount

Certificate methodGet-AzurePublishSettingsFileImport-AzurePublishSettingsFile

Getting helpGet-Help AzureGet-Command *Azure*

View account and subscription detailsGet-AzureAccountGet-AzureSubscription

Windows Azure PowerShell

How to create new VM in Azure$subscriptionname = ‘Visual Studio Premium с подпиской MSDN’$storageaccountname = ‘azurecampvnstg’$vmname = ‘AzureCampVN01’$servicename = ‘azurecampvn’$configurationarchive = ‘DSCConfig.ps1.zip’$configurationname = ‘AzureCamp’$location = ‘East US 2’$instancesize = "Standard_D1"$adminusername = "acadmin"$adminPassword = "P@ssw0rd"

#Selecting subscriptionSelect-AzureSubscription -SubscriptionName $subscriptionname

#Creating storage accountNew-AzureStorageAccount -StorageAccountName $storageaccountname -Location $location

#Selecting storage account where DSC configuration will be storedSet-AzureSubscription -SubscriptionName $subscriptionname -CurrentStorageAccountName $storageaccountname

# Take the name of last Windows Server 2012 R2 Image$imagename = (Get-AzureVMImage | where Label -Like "Windows Server 2012 R2*")[-1].ImageName

# Create new VmNew-AzureVMConfig -Name $vmname -InstanceSize $instancesize -ImageName $imagename ` | Add-AzureProvisioningConfig -Windows -Password $adminPassword -AdminUsername $adminusername ` | New-AzureVM -ServiceName $servicename -location $location -WaitForBoot

Demo & Practice:

Creating a Virtual Machine using the Azure

PowerShell

Windows Azure PowerShell

PowerShell Desired State Configuration

We want Telnet Client to be installed: DSCConfiguration AzureCamp

{

node localhost { WindowsFeature TelnetClient { Ensure = "Present" Name = "telnet-client" } }}AzureCamp

PS C:\Azure> Configure-SMRemoting.exe -enablePS C:\Azure> .\DSCConfig.ps1PS C:\Azure> Start-DscConfiguration -Wait -Verbose -Path .\AzureCamp -force

12 Built-In DSC Resources Archive Environment File Package Service WindowsFeature

180 resources in the DSC Resource Kit 10 xActiveDirectory xAzure xNetworking xWebAdministration

You can create your own resources

DSC resources (April 2015)

Demo & Practice:

Configuring a Virtual Machine using the PowerShell DSC

PowerShell Desired State Configuration

Azure PowerShell DSC

Declare what you want to be performed in the DSC config

Upload DSC config and resources into the Azure storage

Apply uploaded configuration to the Azure VM Locate logs at Azure VM if you want to check

results:C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0C:\WindowsAzure\Logs\Plugins\Microsoft.Powershell.DSC\1.7.0.0

Check the status of DSC extension:Get-AzureVMDscExtensionStatus -ServiceName “CloudServiceName” -Name “VMname”

Important note: behavior could be different depends on version of DSC extension

Azure VM & DSC

Apply DSC configuration to the Azure VM$subscriptionname = ‘Visual Studio Premium с подпиской MSDN’$storageaccountname = ‘azurecampvnstg’$vmname = ‘AzureCampVM01’$servicename = ‘azurecampvn’$configurationarchive = ‘DSCConfig.ps1.zip’$configurationname = ‘AzureCamp’$configurationpath = ‘C:\AzureCamp\DSCConfig.ps1’$location = ‘East US 2’

#Selecting subscriptionSelect-AzureSubscription -SubscriptionName $subscriptionname

#Creating storage accountNew-AzureStorageAccount -StorageAccountName $storageaccountname -Location $location

#Selecting storage account where DSC configuration will be storedSet-AzureSubscription -SubscriptionName $subscriptionname -CurrentStorageAccountName $storageaccountname

#Uploading configuration into the storage account. Publish-AzureVMDscConfiguration -ConfigurationPath $configurationpath -Force

#Applying DSC configuration to the $vmname$vmtoupdate = Get-AzureVM -Name $vmname -ServiceName $servicename$vmtoupdate = Set-AzureVMDSCExtension -VM $vmtoupdate `

–ConfigurationArchive $configurationarchive -ConfigurationName $configurationname $vmtoupdate | Update-AzureVM

Demo & Practice:

Deploying Web Application using the Azure PowerShell DSC

Azure PowerShell DSC

Final Script$subscriptionname = ‘Visual Studio Premium с подпиской MSDN’$storageaccountname = ‘azurecampkhstg’$configurationpath = ‘C:\AzureCamp\DSCConfig.ps1’$vmname = ‘AzureCampKh01’$servicename = ‘azurecampkh’$configurationarchive = ‘DSCConfig.ps1.zip’$configurationname = ‘AzureCamp’$location = ‘East US 2’$instancesize = "Standard_D1"$adminusername = "acadmin"$adminPassword = "P@ssw0rd"$avset = "KhAvSet"$imagename = (Get-AzureVMImage | where Label -Like "Windows Server 2012 R2*")[-1].ImageName

Select-AzureSubscription -SubscriptionName $subscriptionnameNew-AzureStorageAccount -StorageAccountName $storageaccountname -Location $locationSet-AzureSubscription -SubscriptionName $subscriptionname -CurrentStorageAccountName $storageaccountnameNew-AzureVMConfig -Name $vmname -InstanceSize $instancesize -ImageName $imagename -AvailabilitySetName $avset ` | Add-AzureProvisioningConfig -Windows -Password $adminPassword -AdminUsername $adminusername ` | Add-AzureEndpoint -Name 'web' -LocalPort 80 -PublicPort 80 -Protocol tcp -LBSetName 'lbweb' -DefaultProbe ` | New-AzureVM -ServiceName $servicename -location $location -WaitForBootPublish-AzureVMDscConfiguration -ConfigurationPath $configurationpath -Force$vmtoupdate = Get-AzureVM -Name $vmname -ServiceName $servicename$vmtoupdate = Set-AzureVMDSCExtension -VM $vmtoupdate ` –ConfigurationArchive $configurationarchive -ConfigurationName $configurationname $vmtoupdate | Update-AzureVM

$status = Get-AzureVMDscExtensionStatus -ServiceName $servicename -Name $vmname$status

Final DSC configurationConfiguration AzureCamp{ node localhost {

WindowsFeature TelnetClient { Ensure = "Present" Name = "telnet-client" } WindowsFeature IIS { Ensure = "Present" Name = "Web-Server" } WindowsFeature IISConsole { Ensure = "Present" Name = "Web-Mgmt-Console" } WindowsFeature ASPNet45 { Ensure = "Present" Name = "Web-Asp-Net45" DependsOn = "[WindowsFeature]IIS" } File Index { Ensure = "Present" DestinationPath = "c:\inetpub\wwwroot\index.html" Contents = "Hello World!" }}

}#AzureCamp#Start-DscConfiguration -Wait -Verbose -Path .\AzureCamp -force

10+ Deploys Per Day: Dev and Ops Cooperation at Flickr http://www.slideshare.net/jallspaw/10-deploys-per-day-dev-and-ops-cooperation-at-flickr

Introducing PowerShell Desired State Configuration (DSC)http://blogs.technet.com/b/privatecloud/archive/2013/08/30/introducing-powershell-desired-state-configuration-dsc.aspx

Introducing the Azure PowerShell DSC (Desired State Configuration) extension http://blogs.msdn.com/b/powershell/archive/2014/08/07/introducing-the-azure-powershell-dsc-desired-state-configuration-extension.aspx

Build Custom Windows PowerShell Desired State Configuration Resources http://technet.microsoft.com/en-us/library/dn249927.aspx

DSC Resource Kit (All Modules) https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d

Links

Recommended