Upload
sean-kearney
View
53
Download
0
Embed Size (px)
Citation preview
aOS 2017Canadian Tour
Fueled by
QuebecMontrealOttawaToronto
February 6February 7 February 8February 10
Manage AzureRM Virtual Machineswith PowerShell
Using the Windows PowerShell Cmdlet to Manage, Access and Control Resources in
the Azure Resource ModelSean Kearney @energizedtech
Senior Solutions ArchitectCistel Technology Inc.
Thank you !
Get-Content 'C:\Sean Kearney.txt'• Sean Kearney – MVP Sean Kearney is a Senior Solutions Architect at Cistel
Technology Inc. He lives in the world of Automation leveraging technologies providing Automation to clients in whatever way shape or form he can. He will break out into song when the word “PowerShell” is used.
He is a Windows PowerShell MVP, Charter Member of the Springboard Technical Experts Program and an Honorary Scripting Guy who regularly contributes content to Microsoft's own "Scripting Guys" website.
In his spare time, he composes songs and Holiday specials about PowerShell and is working on a sonnet about Satya Nadella.
What can we say, he’s a complete Nerd about technology and he loves it.
• You can reach him at [email protected] / [email protected] Twitter @energizedtech – He’s on that Facebook and LinkedIn thing too ;) .
On the Agenda
• High level view of Azure and IAAS• Visiting the AzureRM Modules and Cmdlets• Preparing your Virtual Machine Infrastructure• Creating your Virtual Machines• Obtaining Azure Resources• Using Azure Automation
Microsoft AzureOverview Azure IAAS
What *IS* Azure IAAS?
• Remotely Hosted Highly Scalable Virtualization Datacenter
• Plenty of Virtual Machine Templates provided
• Supporting Windows and various versions of Linux as well as Oracle
• Works with PowerShell Desired State Configuration files (DSC) and other technologies such as Chef
Automation Options
• Windows PowerShell Cmdlets
• PowerShell Workflows
• Azure Automation Services
Available Cmdlets
• Almost everything in Microsoft Azure has Cmdlets
• Current List http://bit.ly/AzureCmdletList
• www.powershellgallery.com• Search AzureRM download and install• Presently 27 Modules classified by purpose• 884 Cmdlets at your disposal (*klunk!*)
Available Modules
AzureRM.ApiManagement AzureRM.HDInsight AzureRM.Resources
AzureRM.Automation AzureRM.Insights AzureRM.SiteRecovery
AzureRM.Backup AzureRM.KeyVault AzureRM.Sql
AzureRM.Batch AzureRM.Network AzureRM.Storage
AzureRM.Compute AzureRM.NotificationHubs AzureRM.StreamAnalytics
AzureRM.DataFactories AzureRM.OperationalInsights AzureRM.Tags
AzureRM.DataLakeAnalytics AzureRM.profile AzureRM.TrafficManager
AzureRM.DataLakeStore AzureRM.RecoveryServices AzureRM.UsageAggregates
AzureRM.Dns AzureRM.RedisCache AzureRM.Websites
Connect to Azure RM with PowerShell
Azure Virtual MachinesBuild your Base Infrastructure
Build Your Base Infrastructure
• On Premise Solution Requirements
• Servers and Storage
• Networking
Build Your Base Infrastructure
• Azure Virtual Machine Requirements
• Servers and Storage
• Networking
• Service Point
Build Your Base Infrastructure
• Azure Virtual Machines
• Define Azure Resource Group• Location, Reference Name
• Define our Storage• Location, Reference Name, Storage Type
• Define our Network• Virtual Network - Location, Resource Name, Address Range/Subnet• Virtual Network Subnet – Resource Name, Address Range/Subnet
Build Your Base Infrastructure
• Azure Virtual Machines using Windows PowerShell
• Define Azure Resource Group• New-AzureRM
• Define our Storage• New-AzureRMStorage
• Define our Network• New-AzureRMVirtualNetworkSubnetConfig• New-AzureRMVirtualNetwork
Build your Base Infrastructure
Azure Virtual MachinesCreating a Virtual
Machine
Creating a Virtual Machine
• On Premise Solution Requirements
• Operating System• Memory• Virtual Disk(s)• CPU Count and Speed• Network Connection(s)• Virtual Network Wire• Firewall Rule(s)
Creating a Virtual Machine
• Azure Virtual Machine Requirements
• Operating System• Memory• Virtual Disk(s) (Cannot Assign Letter D)• CPU Count and Speed• Network Connection (Dynamic IP)• Virtual Network Wire• Firewall Rule(s)
Creating a Virtual Machine
• Azure Virtual Machines
• Quick Create or From Gallery• DNS Name• O/S Image• Size (Predefined VM Template config)• UserName (Default Admin)• Password (Default Password)• Location
Creating a Virtual Machine
• Azure Virtual Machines using PowerShell
• Create AzureRM Configuration• New-AzureRMVMConfig
• Create network card• New-AzureRMPublicIPAddress, New-AzureRMNetworkInterface, Add-AzureRMVMNetworkInterface
• Define Operating System• Set-AzureRMVMOperatingSystem, Set-AzureRMVMSourceImage
• Define attached OS Disk and Data Disk• Set-AzureRMVMOSDisk, Set-AzureRMVMDataDisk
• Create Firewall Rules• New-AzureRMNetworkSecurityRuleConfig• New-AzureRMNetworkSecurityGroup
• Create the Virtual Machine• New-AzureRMVM
Creating a Virtual Machine
• A quick way to grab the JSON configuration
• Get-AzureRMVM• Set-AzureRMVM –generalized• Save-AzureRMVM
• *OR*
• View before provisioning in AzureRM GUI Portal
Creating a Virtual Machine
Azure Virtual MachinesAzure Resources through
PowerShell
Azure Resources through PowerShell
• Resources you will need to get names for
• Virtual Machine Template name / VHD Filename• Geographic Locations• Virtual Machine Role Sizes• Service Names• Storage Accounts• Networks
Azure Resources through PowerShell
• Access those needed resources with Cmdlets
• Get-AzureRMVMImage• Get-AzureRMResourceGroup• Get-AzureRMStorageAccount• Get-AzureRMVirtualNetwork• Get-AzureRMNetwork• Get-AzureRMVM• Access properties of a VM to get all resource data
Azure Resources through PowerShell
Azure Virtual MachinesLeveraging Azure
Automation
Virtual Machine States
• Three possible states• Running
• Operating System is up and Resouces Allocated• Costing Money
• Deallocated• Operating System is down and Resourcs are Deallocated• Not Costing Money
• StoppedVM• (Operating System if off, Resources are still Allocated)• Costing Money
Scheduling PowerShell Scripts
• On Premise Server connecting through the Internet• Requires Internet• Scripts can be used immediately
• Azure Automation hosted within Azure• No Internet required• Some reconfiguration needed
Using Azure Automation
• Build an Automation account
• Create Automation Credentials
• Populate Scripts within the Runbook
• Build Variables within Azure Automation
• Setup a schedule
Leveraging Azure Automation
Take aways
• AzureRM Virtual Machines are just Hyper-V “in the cloud”
• You can access all resources from just PowerShell alone
• Create a Virtual Machine in the Web console first, then use PowerShell to identify all your needed Azure resources
• Azure Automation allows you to schedule and manage Virtual Machines without the need for Internet
Questions?
Azure PowerShell Resources
• Sample JSON Templates for AzureRM• http://bit.ly/AzureRMJson
• Azure RM Cmdlets• http://bit.ly/AzureRMPowerShell• http://bit.ly/GHAzureRM
• Scripting Guys articles on Azure Automation• http://bit.ly/PowerShell-AzureAutomation
• Look for a series on Azure RM and Virtual Machines with PowerShell THIS Month on Scripting Guys!
Thanks Everybody!
• www.powershell.org• www.scriptingguys.com
• Download Sample PowerShell scripts here forPresentation
• https://1drv.ms/u/s!Aknz413LlS-VkJ4q3TWnUIhWm-daAA
• Email:[email protected] www.cistel.com• Email:[email protected] www.powershell.ca• Twitter: @energizedtech
Thank you !