Tom Lee - Doing Azure with Powershell

37
DOING AZURE WITH POWERSHELL Thomas Lee PS Partnership Partner [email protected]

Transcript of Tom Lee - Doing Azure with Powershell

Page 1: Tom Lee - Doing Azure with Powershell

DOING AZURE WITH POWERSHELLThomas LeePS [email protected]

Page 2: Tom Lee - Doing Azure with Powershell

Who Am I?I am Thomas Lee - Partner at PS Partnership17 Time MVP, MCT, etcI tweet from @DoctorDNSI blog at http://tfl09.blogspot.comEmail me [email protected] not tweeting/blogging I like to listen to my large collection of Grateful Dead live show recordings.I blog, tweet, teach, and support Azure and PowerShell

Page 3: Tom Lee - Doing Azure with Powershell

AGENDA

What IS PowerShell? What is Azure? Getting started and setup Creating Virtual Machines using PowerShell Creating Virtual Networks using PowerShell Creating File Storage in Azure using PowerShell

Page 4: Tom Lee - Doing Azure with Powershell

BEFORE WE START…

The slides and demo files for this talk are shared on Dropbox: http://bit.ly/ucdayfiles

Enjoy!!

Page 5: Tom Lee - Doing Azure with Powershell

Silver Sponsors

Gold Sponsors

Bronze Sponsors

Page 6: Tom Lee - Doing Azure with Powershell

WHAT IS POWERSHELL?

Page 7: Tom Lee - Doing Azure with Powershell

POWERSHELL IS…

Microsoft’s strategic task automation platformfor IT Pros

Page 8: Tom Lee - Doing Azure with Powershell

Cmdlets

Objects

Pipeline

Community

Discovery

PowerShell Language Features

LOOKING AT POWERSHELL

Page 9: Tom Lee - Doing Azure with Powershell

POWERSHELL CMDLETS These are tiny programs that do the work

All the rest is syntax, syntax, syntax Cmdlets come from many places

Built-in Included with Windows features Included with applications Commercial Community (PowerShell Gallery)

PowerShell cmdlets distributed as Modules Getting key modules is easy with PowerShell Gallery and PSGet

Page 10: Tom Lee - Doing Azure with Powershell

OBJECTS

PowerShell Cmdlets produce and consume objects Objects are based on .NET

.NET Objects are native WMI/CIM objects are COM data wrapped in .NET Object COM objects are adapted

See the output of a cmdlet by piping it to Get-Member Azure object documentation is evolving

Page 11: Tom Lee - Doing Azure with Powershell

THE PIPELINE

The output of one command becomes the input to the next command

Base on Linux/Unix Pipeline But based on objects not raw text No prayer-based parsing

Extremely powerful in operation

Page 12: Tom Lee - Doing Azure with Powershell

SYNTAX, SYNTAX, SYNTAX

PowerShell is a programming/scripting language It has syntax – and you need to learn it

Syntax errors usually easy to troubleshoot Good error messages for the most part

Errors using cmdlets can be harder to troubleshoot Some Azure cmdlet messages are cryptic If stuck – there are places you can get help like Spiceworks.Com

Page 13: Tom Lee - Doing Azure with Powershell

WHAT IS AZURE?

Page 14: Tom Lee - Doing Azure with Powershell

Do I even need to ask?

Page 15: Tom Lee - Doing Azure with Powershell

AZURE

Microsoft operateddata centre in the cloud

Page 16: Tom Lee - Doing Azure with Powershell

WINDOWS AZURE SERVICES

You canmanage Azure

using PowerShell

Page 17: Tom Lee - Doing Azure with Powershell

USING CMDLETS AGAINST AZURE

You can use PowerShell cmdlets to manage almost all Azure resources

The cmdlets are a wrapper around the underlying REST based APIs

The cmdlets have changed a lot and continue to be improved The Story of Two APIs and cmdlets to suit each

Page 18: Tom Lee - Doing Azure with Powershell

GETTING STARTED

Page 19: Tom Lee - Doing Azure with Powershell

BEFORE WE CAN MANAGE AZURE You need to setup your management environment

Install latest updates Setup your desktop Update $Profile with useful commands

For this talk, I created a new Outlook.com account ([email protected]) and a trial Azure account for this email address

Page 20: Tom Lee - Doing Azure with Powershell

FOR OUR DEMOS

C:\Foo setup as location to put scripts, etc. Added a $Profile for both ISE and Console Create Personal Modules drive Also

Turned off IE Protected mode Update-Help

Page 21: Tom Lee - Doing Azure with Powershell

GETTING AZURE MODULES You need to find, then get and install the cmdlets

Use Find-Module to find Azure modules (On PSGallery) This requires you also installing the NuGet Provider

For this talk, we are using the PowerShell gallery as the source of the cmdlets

There are other places, but PowerShell Gallery is easy with PowerShellGet module

Once you download the cmdlets, ensure you update help Update-Help

Page 22: Tom Lee - Doing Azure with Powershell

FINDING MODULES

Page 23: Tom Lee - Doing Azure with Powershell

INSTALLING MODULES Azure Service Management API based cmdlets

Azure module Azure Resource Manager API based cmdlets

AzureRM module(s)

Modules and contained Cmdlets change regularly Changes are versioned You can update using Update-Module

Page 24: Tom Lee - Doing Azure with Powershell

GETTING SETUP IN AZURE

Download/Install the cmdlets Login to Azure Create Resource Group(s) and Storage Account(s) Create some tags And get more familiar with the Azure cmdlets

Page 25: Tom Lee - Doing Azure with Powershell

Demo 0Getting Started with Azure

Page 26: Tom Lee - Doing Azure with Powershell

CREATING VIRTUAL MACHINES AND NETWORKS

Page 27: Tom Lee - Doing Azure with Powershell

CREATING A VIRTUAL NETWORK

Define Azure subnets New-AzureRmVirtualNetworkSubnetConfig

Create the virtual network New-AzureRMVirtualNetwork

Page 28: Tom Lee - Doing Azure with Powershell

CREATING A VIRTUAL MACHINE IN THE VNET First create a VMConfig object

New-AzureRmVmConfig Use cmdlets to add configuration items to this config object

Set-AzureRmVMOperatingSystem Set-AzureRmVMSourceImage Add-AzureRmVMNetworkInterface Set-AzureRmVMOSDisk

Create the VM using the VM config object New-AzureRmVM

Page 29: Tom Lee - Doing Azure with Powershell

Demo 1Creating a Virtual Network and a VM

Page 30: Tom Lee - Doing Azure with Powershell

THINGS YET TO DO That demo created a VPN, but without a VPN gateway To create the gateway you need to both create a gateway and

configure your local end For Site to Site VPNs, you need to setup your VPN server For Point to Site VPNs, you need to download and install the client

P2S is easy to setup but You have to manually install the VPN client (you can automate the

download!) You have to manually turn the VPN on (Rasdial does not work to connect

to the VPN) There is an additional demo that can show this – if we get time…

Page 31: Tom Lee - Doing Azure with Powershell

AZURE FILES

Page 32: Tom Lee - Doing Azure with Powershell

AZURE FILES

Provides SMB based storage in Azure Great for apps you want to move to the cloud with minimal

change You set up using some simple PowerShell – or the GUI if you

must! Most of the automation is actually pretty easy

You access it using standard tools and drive mappings Use PowerShell to setup the share, then use standard commands

and cmdlets to manage/use the file store It feels very familiar in usage

Page 33: Tom Lee - Doing Azure with Powershell

CREATING A FILE SHARE IN AZURE

Create an Azure storage account to hold the files (done already for the VM)

Get storage account key and storage account context Then create a new Azure Storage Share Once related, you can use New-SMBMapping to create a local

drive mapping

Page 34: Tom Lee - Doing Azure with Powershell

Demo 2Creating and Using an Azure File Share

Page 35: Tom Lee - Doing Azure with Powershell

SUMMARY

Using Azure with PowerShell is easy Creating a virtual network Creating a virtual machine Using Azure files

The cmdlets are in a state of constant change Test updates carefully Watch for the updates and what new features they bring

You can easily automate almost of all the things you can do with/on/to Azure

Page 36: Tom Lee - Doing Azure with Powershell

“”

LEARN POWERSHELL OR LEARN TO SMILE AS YOU SAY ‘WOULD YOU LIKE FRIES WITH THAT BURGER?’

Thomas Lee or Don Jones

Page 37: Tom Lee - Doing Azure with Powershell

QUESTIONS/ANSWERS