25
Oleg Chorny IT Operations, Edgar Online Microsoft SPDS MVP Azure Camp UA Part II: Infrastructure as a Code Anton Vidishchev Program Manager, Edgar Online Microsoft Azure MVP

Azure Expert Leading Camp UA - 2015

Embed Size (px)

Citation preview

Page 1: Azure Expert Leading Camp UA - 2015

Oleg Chorny IT Operations, Edgar OnlineMicrosoft SPDS MVP

Azure Camp UAPart II: Infrastructure as a Code

Anton VidishchevProgram Manager, Edgar OnlineMicrosoft Azure MVP

Page 2: Azure Expert Leading Camp UA - 2015

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

Agenda

Page 3: Azure Expert Leading Camp UA - 2015

Microsoft Azure Virtual Machines

Page 4: Azure Expert Leading Camp UA - 2015

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

Page 5: Azure Expert Leading Camp UA - 2015

Reliability Scalability Elasticity Load balancing High availability Automation Disaster Recovery

Microsoft Azure

Page 6: Azure Expert Leading Camp UA - 2015

Complex Solutions for Enterprise Workloads

Page 7: Azure Expert Leading Camp UA - 2015

Microsoft Azure VM: D series

Page 8: Azure Expert Leading Camp UA - 2015

Demo & Practice:

Creating a Virtual Machine using the Azure

Portal

Microsoft Azure Virtual Machines

Page 9: Azure Expert Leading Camp UA - 2015

Windows Azure PowerShell

Page 10: Azure Expert Leading Camp UA - 2015

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

Windows Management Framework 5.0 Preview

Page 11: Azure Expert Leading Camp UA - 2015

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 }

Page 12: Azure Expert Leading Camp UA - 2015

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

Page 13: Azure Expert Leading Camp UA - 2015

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

Page 14: Azure Expert Leading Camp UA - 2015

Demo & Practice:

Creating a Virtual Machine using the Azure

PowerShell

Windows Azure PowerShell

Page 15: Azure Expert Leading Camp UA - 2015

PowerShell Desired State Configuration

Page 16: Azure Expert Leading Camp UA - 2015

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

Page 17: Azure Expert Leading Camp UA - 2015

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)

Page 18: Azure Expert Leading Camp UA - 2015

Demo & Practice:

Configuring a Virtual Machine using the PowerShell DSC

PowerShell Desired State Configuration

Page 19: Azure Expert Leading Camp UA - 2015

Azure PowerShell DSC

Page 20: Azure Expert Leading Camp UA - 2015

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

Page 21: Azure Expert Leading Camp UA - 2015

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

Page 22: Azure Expert Leading Camp UA - 2015

Demo & Practice:

Deploying Web Application using the Azure PowerShell DSC

Azure PowerShell DSC

Page 23: Azure Expert Leading Camp UA - 2015

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

Page 24: Azure Expert Leading Camp UA - 2015

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

Page 25: Azure Expert Leading Camp UA - 2015

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