automation azure with powershell -...

20
#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM Automation Azure with PowerShell Beyond the PowerShell Module #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM Neil Peterson @nepeters

Upload: others

Post on 06-Sep-2019

99 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Automation Azure with PowerShellBeyond the PowerShell Module

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Neil Peterson@nepeters

Page 2: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Session Topics

- Azure PowerShell Module- Azure VM Custom Script Extension- Azure VM DSC Extension- Azure Automation- REST endpoints

Page 3: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

PowerShell Module

Module work working with Azure resources

- Windows, macOS, Linux, and as a Docker image- PowerShell for .net standard- PowerShell Core (focus for this session)

Page 4: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure module for PowerShell Core

Some notes on pwsh.

- Install-Module Az- Get-AzRMVM > Get-AzVM- Enable AzRM aliasing (Enable-AzureRmAlias)

Page 5: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Authentication

Methods for authenticating the PowerShell module with Azure

- Connect-AzAccount- Connect-AzAccount –ServicePrincipal –ApplicationID <> -Credential <> -TenantId- Enable-AzContextAutosave- Disable-AzContextAutosave

Page 6: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Demo - PowerShell Module

Page 7: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure VM Extensions

Provide dynamic features, supplied by Microsoft and third parties, executed by the Azure VM Agent.

- VM Agent installs, configures, and executes extensions- Added with any Azure management tooling- Can be added at or after deployment time

Page 8: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure VM Extensions cont..

Many extensions available

- Custom Script- DSC- BgInfo- Chef- Puppet

Page 9: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

VM Custom Script Extension

Scripts copied to VM and executed locally

- Windows: PowerShell- Linux: Bash- Azure PS module > 8.0- Stored in blob storage or HTTP accusable location (GitHub)- Only one scripts can be specified

Page 10: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

VM Custom Script Extension cont..

Benefits

- No need for VM endpoint or PowerShell remoting- Configure new virtual machines- Manage existing virtual machines

Page 11: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Demo – Custom Script Extension

Page 12: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

PowerShell DSC

PowerShell language extension used to declaratively specify, apply, and maintain software configurations.

- Declarative Configurations: define and configure infrastructure- DSC Resources: configuration logic, grouped into modules- Removes need for complex logic

Page 13: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure VM DSC Extension

Apply DSC configuration to new or existing Azure virtual machines,

- Set-AzVMDscExtension: Injects configurations- Get-AzVMDscExtensionStatus: retrieves status- RemoveAzVMDscExtension: removes handler, not configuration

Page 14: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Publishing a DSC Configuration

The Publish-AzureRMDSCConfiguration command automates the prep work.

- Creates .zip of configuration and resources- Publishes file to Azure Storage- Can also publish locally

Page 15: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Demo – DSC Extension

Page 16: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure Automation

An Azure hosted Runbook / technical workflow solution.

- Process automation: PowerShell and Python runbooks- Configuration management: PowerShell DSC- Update management:

Page 17: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure Automation Cont..

Process Automation

- Runbooks for the cloud and on-premises- Trigger manually, on a schedule, by webhook or event- Capability for graphical authoring

Page 18: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Demo – Azure Automation

Page 19: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Azure REST Interfaces

Sometimes, perhaps, you may want to work with a raw REST interface.

- Service endpoints that support HTTP methods- Create, retrieve, update, delete- Service Principle for authentication

Page 20: Automation Azure with PowerShell - files.informatandm.comfiles.informatandm.com/...with_PowerShell_Beyond_the_Azure_PowerShell... · #ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM PowerShell

#ITDEVCONNECTIONS | ITDEVCONNECTIONS.COM

Demo – Rest Interface