azure powershell. azure automation

Post on 16-Apr-2017

639 Views

Category:

Engineering

9 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1CONFIDENTIAL

Azure PowerShell SDK. Azure Automation.

JANUARY 13, 2016

Alex Feshchenko,SENIOR SOFTWARE ENGINEER

2CONFIDENTIAL

AGENDA

PowerShell Basics1

Azure RM module2

Build automation with VSO3

Azure Automation4

Demo5

Q&A6

3CONFIDENTIAL

POWERSHELL BASICS

JANUARY 13, 2016

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

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

6CONFIDENTIAL

PowerShell Core Scripting

BasicsVariablesObjectsPipelineAliasesTab completion

Selection & FilterGet-MembersSelectWhereWhere-ObjectFilter

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!)

8CONFIDENTIAL

Pipeline Example

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

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

11CONFIDENTIAL

Creating An Instance

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

13CONFIDENTIAL

AZURE RM MODULE

JANUARY 13, 2016

14CONFIDENTIAL

Microsoft Azure SDK

https://goo.gl/VhU2cO

15CONFIDENTIAL

Logging in to Azure Account

PS C:\> Login-AzureRmAccount

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

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

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

19CONFIDENTIAL

Deploy the template

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

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: ********

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

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

23CONFIDENTIAL

DEMO

JANUARY 13, 2016

DEPLOYING RESOURCES WITH ARM

24CONFIDENTIAL

DEMO

JANUARY 13, 2016

BUILD AUTOMATION

25CONFIDENTIAL

AZURE AUTOMATION

JANUARY 13, 2016

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

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

28CONFIDENTIAL

Pricing

Pricing Tiers:• Free• Basic

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

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

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

Manage Automation AssetsManage global assets

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

33CONFIDENTIAL

Checkpointing

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

34CONFIDENTIAL

DEMO

JANUARY 13, 2016

AZURE AUTOMATION

35CONFIDENTIAL

In Review

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

36CONFIDENTIAL

QUESTIONS

OCTOBER 7, 2015

37CONFIDENTIAL

Thank you!

top related