azure powershell. azure automation

37
1 CONFIDENTIAL Azure PowerShell SDK. Azure Automation. JANUARY 13, 2016 Alex Feshchenko, SENIOR SOFTWARE ENGINEER

Upload: alexander-feschenko

Post on 16-Apr-2017

603 views

Category:

Engineering


9 download

TRANSCRIPT

Page 1: Azure Powershell. Azure Automation

1CONFIDENTIAL

Azure PowerShell SDK. Azure Automation.

JANUARY 13, 2016

Alex Feshchenko,SENIOR SOFTWARE ENGINEER

Page 2: Azure Powershell. Azure Automation

2CONFIDENTIAL

AGENDA

PowerShell Basics1

Azure RM module2

Build automation with VSO3

Azure Automation4

Demo5

Q&A6

Page 3: Azure Powershell. Azure Automation

3CONFIDENTIAL

POWERSHELL BASICS

JANUARY 13, 2016

Page 4: Azure Powershell. Azure Automation

4CONFIDENTIAL

PowerShell

Command line and scripting language- As interactive and composable as BASH/KSH- As programmatic as Perl/Python/Ruby- As production oriented as AS400 CL/VMS DCL

Page 5: Azure Powershell. Azure Automation

5CONFIDENTIAL

Cmdlets

We use cmdLets or say Command-LetsCmdlet is made of Verb-Noun Syntax

e.g. SharePoint-Rocks No spaces in cmdLets

ExamplesGet-Help, Stop-Service, Restart-Computer, Get-Command

Verbs Nouns

Get ProcessStop ServiceStart ComputerGet HelpSet Location

Page 6: Azure Powershell. Azure Automation

6CONFIDENTIAL

PowerShell Core Scripting

BasicsVariablesObjectsPipelineAliasesTab completion

Selection & FilterGet-MembersSelectWhereWhere-ObjectFilter

Page 7: Azure Powershell. Azure Automation

7CONFIDENTIAL

The Pipeline

o PowerShell has an extremely powerful pipeline that works unlike anything that’s really been done before

o It carries the output of one command to the input of the next… but it does so in an amazingly flexible way

o If you can master the pipeline (and the help system helps!)

Page 8: Azure Powershell. Azure Automation

8CONFIDENTIAL

Pipeline Example

Page 9: Azure Powershell. Azure Automation

9CONFIDENTIAL

Objects

• You may have heard that PowerShell is an object-oriented shell

• People make a big deal of this because it enables a lot… but conceptually it’s pretty simple

• Ever see an Excel spreadsheet? It’s just a data structure, right? Well, that’s all objects are. Data structures, in memory.

• Every PowerShell command (well, most) produces objects… and PowerShell will even show you everything about them

Page 10: Azure Powershell. Azure Automation

10CONFIDENTIAL

Directly Using .NET Resources

Pre-loaded assemblies [AppDomain]::CurrentDomain.GetAssemblies()

[AppDomain]::CurrentDomain.GetAssemblies() | `ForEach-Object `

{ if ($_.GlobalAssemblyCache){ $_.Location.ToString().Split("\")[4]}}

SystemSystem.DrawingSystem.XmlSystem.ConfigurationSystem.Management.Automation

Microsoft.PowerShell.Commands.UtilityMicrosoft.PowerShell.ConsoleHostMicrosoft.PowerShell.Commands.ManagementMicrosoft.PowerShell.SecuritySystem.Web.Services

Page 11: Azure Powershell. Azure Automation

11CONFIDENTIAL

Creating An Instance

Page 12: Azure Powershell. Azure Automation

12CONFIDENTIAL

Getting Help in PowerShell

Get-Help or Help

Get-Help Get-ProcessGet-Help Get-Process –examplesGet-Help Get-Process –DetailedGet-Help Get-Process -FullExamplesHelp Get-Process -Full

Page 13: Azure Powershell. Azure Automation

13CONFIDENTIAL

AZURE RM MODULE

JANUARY 13, 2016

Page 14: Azure Powershell. Azure Automation

14CONFIDENTIAL

Microsoft Azure SDK

https://goo.gl/VhU2cO

Page 15: Azure Powershell. Azure Automation

15CONFIDENTIAL

Logging in to Azure Account

PS C:\> Login-AzureRmAccount

Page 16: Azure Powershell. Azure Automation

16CONFIDENTIAL

More specific queries

PS C:\> ((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).LocationsBrazil SouthEast AsiaEast USJapan EastJapan WestNorth Central USNorth EuropeSouth Central USWest EuropeWest USSoutheast AsiaCentral USEast US 2

Page 17: Azure Powershell. Azure Automation

17CONFIDENTIAL

Create a resource group

PS C:\> New-AzureRmResourceGroup -Name TestRG1 -Location "West US"

ResourceGroupName : TestRG1Location : westusProvisioningState : SucceededTags :Permissions : Actions NotActions ======= ========== *

ResourceId : /subscriptions/{guid}/resourceGroups/TestRG1

Page 18: Azure Powershell. Azure Automation

18CONFIDENTIAL

Get available API versions for the resources

PS C:\> ((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions2015-08-012015-07-012015-06-012015-05-012015-04-012015-02-012014-11-012014-06-012014-04-01-preview2014-04-01

Page 19: Azure Powershell. Azure Automation

19CONFIDENTIAL

Deploy the template

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName TestRG1 -TemplateFile c:\Azure\Templates\azuredeploy.json

Page 20: Azure Powershell. Azure Automation

20CONFIDENTIAL

Dynamic template parameters

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName TestRG1 -TemplateFile c:\Azure\Templates\azuredeploy.json -hostingPlanName freeplanwest -serverName exampleserver -databaseName exampledata -administratorLogin exampleadmin

cmdlet New-AzureRmResourceGroupDeployment at command pipeline position 1Supply values for the following parameters:(Type !? for Help.)administratorLoginPassword: ********

Page 21: Azure Powershell. Azure Automation

21CONFIDENTIAL

Get information about your resource groups

PS C:>Get-AzureRmResourceGroup

Get all of the resource groups:

To get the resources in the resource group, use the Find-AzureRmResource cmdlet and its ResourceGroupNameContains parameter

PS C:\> Find-AzureRmResource -ResourceGroupNameContains TestRG1

Page 22: Azure Powershell. Azure Automation

22CONFIDENTIAL

Modify Resource Group

PS C:\> $resource = Get-AzureRmResource -ResourceName ExampleApp -ResourceGroupName OldRGPS C:\> Move-AzureRmResource -DestinationResourceGroupName NewRG -ResourceId $resource.ResourceId

Move resources from one group to another:

Delete resource from Resource Group:PS C:\> Remove-AzureRmResource -Name TestSite -ResourceGroupName TestRG1 -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-08-01

Delete Resource Group:

PS C:\> Remove-AzureRmResourceGroup -Name TestRG1

Page 23: Azure Powershell. Azure Automation

23CONFIDENTIAL

DEMO

JANUARY 13, 2016

DEPLOYING RESOURCES WITH ARM

Page 24: Azure Powershell. Azure Automation

24CONFIDENTIAL

DEMO

JANUARY 13, 2016

BUILD AUTOMATION

Page 25: Azure Powershell. Azure Automation

25CONFIDENTIAL

AZURE AUTOMATION

JANUARY 13, 2016

Page 26: Azure Powershell. Azure Automation

26CONFIDENTIAL

What is Azure Automation?

Microsoft Azure Automation provides a way for users to automate the manual, long-running, error-prone, and frequently repeated tasks that are commonly performed in a cloud and enterprise environment. It saves time and increases the reliability of regular administrative tasks and even schedules them to be automatically performed at regular intervals

Page 27: Azure Powershell. Azure Automation

Azure Automation Capabilities

Azure

Monitoring Systems

Change Control

Systems

Anything

Runbook Authoring in Azure:Create runbooks to automate all aspects of cloud operations, from deployment, monitoring, and optimizations

Highly Available Engine:

Support requirements for scale and H/A.Built on PowerShell Workflow. Isolation for runbook jobs

Integration into other systems:

Import PS modules and create additional modules and runbooks for Azure services or to connect into 3rd party systems

AutomationBackup

SQL Azure on a

schedule

Staged deploymen

t of a service

Remediate alert on a service

Patch Azure VMs

without downtime

Page 28: Azure Powershell. Azure Automation

28CONFIDENTIAL

Pricing

Pricing Tiers:• Free• Basic

Page 29: Azure Powershell. Azure Automation

Typical Azure Automation Scenarios

Patch Azure IaaS VMs without downtime, leveraging Traffic manager.

Enable regeneration of storage account keys while avoiding downtime in the application.

SQL Backup on a schedule.

Backup and restore IaaS VMs.

Deploy a VM on an Azure / On-Premise cloud and enable monitoring for the VM.

Deploy a new service to Azure and configure the end points for CPU and Memory alerts.

Deploy application from Git, run validation tests, and swap to production if tests pass.

Monitor SharePoint online for an approval to update a service and update the service once approved.

Alert on a VM then turn on tracing, collect logs, upload to Azure Storage and make available in Visual Studio for troubleshooting.

Monitor for when a new service gets created, and configure it for the right tracing / backup policy.

Notify users of a subscription who have underutilized VMs and perform remediation.

Patch / Update / Backup

OrchestrationChange Control &

ProvisioningMonitoring & Remediation

Page 30: Azure Powershell. Azure Automation

Automation Accounts & DashboardCreate Automation Accounts

Organize your automation by group or individual contributorAccounts can live in different regionsCreate up to 30 accounts

Use Automation DashboardOperational dashboard for analysis and troubleshootingQuickly access “problem” jobs to get up and running quickly

Page 31: Azure Powershell. Azure Automation

Runbook AuthoringAuthor

Create PowerShell Workflow runbooksCall existing runbooks in library

Manage and browse and insert assets in runbooksModules and Activities Credentials (PowerShell Credentials and Certificates)Variables (standard and encrypted)ConnectionsSchedules

TestRun runbook and see results within authoring windowTroubleshoot issues

PublishEdit draft before publishing

Page 32: Azure Powershell. Azure Automation

Manage Automation AssetsManage global assets

Add additional integration modulesUpdate to new versions of integration modulesCreate / manage credentialsCreate / manage connectionsCreate / manage variablesManage Schedules

Page 33: Azure Powershell. Azure Automation

33CONFIDENTIAL

Checkpointing

Available commands to checkpoint workflow:• Checkpoint-Workflow• -PSPersist $True• PSPersistPreference = $True/$False• Suspend-Workflow

Page 34: Azure Powershell. Azure Automation

34CONFIDENTIAL

DEMO

JANUARY 13, 2016

AZURE AUTOMATION

Page 35: Azure Powershell. Azure Automation

35CONFIDENTIAL

In Review

Azure Automation enables:• Integration into Azure services and external systems• Implement your tasks using PowerShell workflow• Automate everything!!!!

Page 36: Azure Powershell. Azure Automation

36CONFIDENTIAL

QUESTIONS

OCTOBER 7, 2015

Page 37: Azure Powershell. Azure Automation

37CONFIDENTIAL

Thank you!