Skip to content

Update Import-AzureRMAutomationRunbook command to support Python Runbooks #5000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ResourceManager/Automation/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Additional information about change #1
-->
## Current Release
* Update to Import-AzureRMAutomationRunbook
- Support is now being provided for Python2 runbooks

## Version 4.0.0
* Add support for online help
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -66,6 +66,7 @@ public class ImportAzureAutomationRunbook : AzureAutomationBaseCmdlet
Constants.RunbookType.PowerShellWorkflow,
Constants.RunbookType.GraphicalPowerShellWorkflow,
Constants.RunbookType.Graph,
Constants.RunbookType.Python2,
IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public string Type { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -489,6 +489,9 @@ public Runbook ImportRunbook(string resourceGroupName, string automationAccountN
StringComparison.OrdinalIgnoreCase) &&
0 !=
string.Compare(fileExtension, Constants.SupportedFileExtensions.Graph,
StringComparison.OrdinalIgnoreCase) &&
0 !=
string.Compare(fileExtension, Constants.SupportedFileExtensions.Python,
StringComparison.OrdinalIgnoreCase))
{
throw new ResourceCommonException(typeof(Runbook),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -85,13 +85,17 @@ public static class RunbookType
public const string GraphicalPowerShell = "GraphicalPowerShell";

public const string GraphicalPowerShellWorkflow = "GraphicalPowerShellWorkflow";

public const string Python2 = "Python2";
}

public static class SupportedFileExtensions
{
public const string PowerShellScript = ".ps1";

public const string Graph = ".graphrunbook";

public const string Python = ".py";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Import-AzureRmAutomationRunbook [-Path] <String> [-Description <String>] [-Name
```

## DESCRIPTION
The **Import-AzureRmAutomationRunbook** cmdlet imports an Azure Automation runbook. Specify the
path to a wps_2 script (.ps1 ) file to import for wps_2 and wps_2 Workflow runbooks, or to a
graphical runbook (.graphrunbook) file for graphical runbooks. The name of the file becomes the
name of the runbook. For wps_2 Workflow runbooks, the script must contain a single wps_2 Workflow
definition that matches the name of the file.
The **Import-AzureRmAutomationRunbook** cmdlet imports an Azure Automation runbook. Specify the
path to a wps_2 script (.ps1) file to import for wps_2 and wps_2 Workflow runbooks,
or to a graphical runbook (.graphrunbook) file for graphical runbooks, or to a python 2 script (.py) file for python 2 runbooks.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the 'or' before the 'to a graphical runbook' please? Sorry I might have added it in my suggestion but 2 'or' doesnt make sens.
Singing off.

Thanks!

For wps_2 Workflow runbooks, the script must contain a single wps_2 Workflow definition that matches the name of the file.

## EXAMPLES

Expand Down Expand Up @@ -218,6 +217,7 @@ Valid values are:
- PowerShellWorkflow
- GraphicalPowerShellWorkflow
- Graph
- Python2

The value Graph is obsolete.
It is equivalent to GraphicalPowerShellWorkflow.
Expand All @@ -226,7 +226,7 @@ It is equivalent to GraphicalPowerShellWorkflow.
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: PowerShell, GraphicalPowerShell, PowerShellWorkflow, GraphicalPowerShellWorkflow, Graph
Accepted values: PowerShell, GraphicalPowerShell, PowerShellWorkflow, GraphicalPowerShellWorkflow, Graph, Python

Required: True
Position: Named
Expand Down