Skip to content

Commit 65cec44

Browse files
authored
[Automation] Initial release (Azure#2643)
* [Automation] Initial release
1 parent e58d14e commit 65cec44

File tree

73 files changed

+13994
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+13994
-0
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,5 @@
159159
/src/vmware/ @fengzhou-msft @qwordy
160160

161161
/src/stack-hci/ @zhoxing-ms
162+
163+
/src/automation/ @arrownj

src/automation/HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. :changelog:
2+
3+
Release History
4+
===============
5+
6+
0.1.0
7+
++++++
8+
* Initial release.

src/automation/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Azure CLI automation Extension #
2+
This package is for the 'automation' extension, i.e. 'az automation'.
3+
4+
### How to use ###
5+
Install this extension using the below CLI command
6+
```
7+
az extension add --name automation
8+
```
9+
10+
### Included Features
11+
#### Automation Management:
12+
Manage Automation: [more info](https://docs.microsoft.com/en-us/azure/automation/)\
13+
*Examples:*
14+
15+
##### Create an Automation Account
16+
17+
```
18+
az automation account create \
19+
--resource-group groupName \
20+
--name accountName \
21+
--location westus
22+
```
23+
24+
##### Create a runbook
25+
```
26+
az automation runbook create \
27+
--resource-group groupName \
28+
--automation-account-name accountName \
29+
--name runbookName \
30+
--type PowerShell \
31+
--location westus
32+
```
33+
34+
##### Set runbook content (Download [AzureAutomationTutorial.ps1](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation/scripts/AzureAutomationTutorial.ps1) as an example)
35+
```
36+
az automation runbook replace-content \
37+
--resource-group groupName \
38+
--automation-account-name accountName \
39+
--name runbookName \
40+
--content @/path/to/local/script
41+
```
42+
43+
##### Publish a runbook
44+
```
45+
az automation runbook publish \
46+
--resource-group groupName \
47+
--automation-account-name accountName \
48+
--name runbookName
49+
```
50+
51+
##### Start a runbook
52+
```
53+
az automation runbook start \
54+
--resource-group groupName \
55+
--automation-account-name accountName \
56+
--name runbookName
57+
```
58+
59+
##### List automation jobs
60+
```
61+
az automation job list \
62+
--resource-group groupName \
63+
--automation-account-name accountName
64+
```
65+
66+
##### Stop an automation job
67+
```
68+
az automation job stop \
69+
--resource-group groupName \
70+
--automation-account-name accountName \
71+
--name jobName
72+
```
73+
74+
##### Suspend an automation job
75+
```
76+
az automation job suspend \
77+
--resource-group groupName \
78+
--automation-account-name accountName \
79+
--name jobName
80+
```
81+
82+
##### Resume an automation job
83+
```
84+
az automation job resume \
85+
--resource-group groupName \
86+
--automation-account-name accountName \
87+
--name jobName
88+
```
89+
90+
If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
11+
from azure.cli.core import AzCommandsLoader
12+
from azext_automation.generated._help import helps # pylint: disable=unused-import
13+
try:
14+
from azext_automation.manual._help import helps # pylint: disable=reimported
15+
except ImportError:
16+
pass
17+
18+
19+
class AutomationClientCommandsLoader(AzCommandsLoader):
20+
21+
def __init__(self, cli_ctx=None):
22+
from azure.cli.core.commands import CliCommandType
23+
from azext_automation.generated._client_factory import cf_automation_cl
24+
automation_custom = CliCommandType(
25+
operations_tmpl='azext_automation.custom#{}',
26+
client_factory=cf_automation_cl)
27+
parent = super(AutomationClientCommandsLoader, self)
28+
parent.__init__(cli_ctx=cli_ctx, custom_command_type=automation_custom)
29+
30+
def load_command_table(self, args):
31+
from azext_automation.generated.commands import load_command_table
32+
load_command_table(self, args)
33+
try:
34+
from azext_automation.manual.commands import load_command_table as load_command_table_manual
35+
load_command_table_manual(self, args)
36+
except ImportError:
37+
pass
38+
return self.command_table
39+
40+
def load_arguments(self, command):
41+
from azext_automation.generated._params import load_arguments
42+
load_arguments(self, command)
43+
try:
44+
from azext_automation.manual._params import load_arguments as load_arguments_manual
45+
load_arguments_manual(self, command)
46+
except ImportError:
47+
pass
48+
49+
50+
COMMAND_LOADER_CLS = AutomationClientCommandsLoader
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
# pylint: disable=wildcard-import
11+
# pylint: disable=unused-wildcard-import
12+
13+
from .generated.action import * # noqa: F403
14+
try:
15+
from .manual.action import * # noqa: F403
16+
except ImportError:
17+
pass
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"azext.isExperimental": true,
3+
"azext.minCliCoreVersion": "2.13.0"
4+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
# pylint: disable=wildcard-import
11+
# pylint: disable=unused-wildcard-import
12+
13+
from .generated.custom import * # noqa: F403
14+
try:
15+
from .manual.custom import * # noqa: F403
16+
except ImportError:
17+
pass
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
11+
12+
def cf_automation_cl(cli_ctx, *_):
13+
from azure.cli.core.commands.client_factory import get_mgmt_service_client
14+
from ..vendored_sdks.automation import AutomationClient
15+
return get_mgmt_service_client(cli_ctx,
16+
AutomationClient)
17+
18+
19+
def cf_runbook(cli_ctx, *_):
20+
return cf_automation_cl(cli_ctx).runbook
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
#
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is
8+
# regenerated.
9+
# --------------------------------------------------------------------------
10+
# pylint: disable=too-many-lines
11+
12+
from knack.help_files import helps
13+
14+
15+
helps['automation runbook'] = """
16+
type: group
17+
short-summary: automation runbook
18+
"""
19+
20+
helps['automation runbook list'] = """
21+
type: command
22+
short-summary: "Retrieve a list of runbooks."
23+
examples:
24+
- name: List runbooks by automation account
25+
text: |-
26+
az automation runbook list --automation-account-name "ContoseAutomationAccount" --resource-group "rg"
27+
"""
28+
29+
helps['automation runbook show'] = """
30+
type: command
31+
short-summary: "Retrieve the runbook identified by runbook name."
32+
examples:
33+
- name: Get runbook
34+
text: |-
35+
az automation runbook show --automation-account-name "ContoseAutomationAccount" --resource-group "rg" \
36+
--name "Get-AzureVMTutorial"
37+
"""
38+
39+
helps['automation runbook create'] = """
40+
type: command
41+
short-summary: "Create the runbook identified by runbook name."
42+
parameters:
43+
- name: --publish-content-link-content-hash
44+
short-summary: "Gets or sets the hash."
45+
long-summary: |
46+
Usage: --publish-content-link-content-hash algorithm=XX value=XX
47+
48+
algorithm: Required. Gets or sets the content hash algorithm used to hash the content.
49+
value: Required. Gets or sets expected hash value of the content.
50+
examples:
51+
- name: Create or update runbook and publish it
52+
text: |-
53+
az automation runbook create --automation-account-name "ContoseAutomationAccount" --draft-parameters \
54+
"{\\"name\\":\\"Get-AzureVMTutorial\\",\\"location\\":\\"East US 2\\",\\"properties\\":{\\"description\\":\\"Descriptio\
55+
n of the Runbook\\",\\"logActivityTrace\\":1,\\"logProgress\\":true,\\"logVerbose\\":false,\\"publishContentLink\\":{\\\
56+
"contentHash\\":{\\"algorithm\\":\\"SHA256\\",\\"value\\":\\"115775B8FF2BE672D8A946BD0B489918C724DDE15A440373CA54461D53\
57+
010A80\\"},\\"uri\\":\\"https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runboo\
58+
k-getvms/Runbooks/Get-AzureVMTutorial.ps1\\"},\\"runbookType\\":\\"PowerShellWorkflow\\"},\\"tags\\":{\\"tag01\\":\\"va\
59+
lue01\\",\\"tag02\\":\\"value02\\"}}" --resource-group "rg" --runbook-name "Get-AzureVMTutorial"
60+
- name: Create runbook as draft
61+
text: |-
62+
az automation runbook create --automation-account-name "ContoseAutomationAccount" --draft-parameters \
63+
"{\\"name\\":\\"Get-AzureVMTutorial\\",\\"location\\":\\"East US 2\\",\\"properties\\":{\\"description\\":\\"Descriptio\
64+
n of the Runbook\\",\\"draft\\":{},\\"logProgress\\":false,\\"logVerbose\\":false,\\"runbookType\\":\\"PowerShellWorkfl\
65+
ow\\"},\\"tags\\":{\\"tag01\\":\\"value01\\",\\"tag02\\":\\"value02\\"}}" --resource-group "rg" --runbook-name \
66+
"Get-AzureVMTutorial"
67+
"""
68+
69+
helps['automation runbook update'] = """
70+
type: command
71+
short-summary: "Update the runbook identified by runbook name."
72+
examples:
73+
- name: Update runbook
74+
text: |-
75+
az automation runbook update --automation-account-name "ContoseAutomationAccount" --description \
76+
"Updated Description of the Runbook" --log-activity-trace 1 --log-progress true --log-verbose false --resource-group \
77+
"rg" --runbook-name "Get-AzureVMTutorial"
78+
"""
79+
80+
helps['automation runbook delete'] = """
81+
type: command
82+
short-summary: "Delete the runbook by name."
83+
examples:
84+
- name: Delete a runbook
85+
text: |-
86+
az automation runbook delete --automation-account-name "ContoseAutomationAccount" --resource-group "rg" \
87+
--name "Get-AzureVMTutorial"
88+
"""
89+
90+
helps['automation runbook publish'] = """
91+
type: command
92+
short-summary: "Publish runbook draft."
93+
examples:
94+
- name: Publish runbook draft
95+
text: |-
96+
az automation runbook publish --automation-account-name "ContoseAutomationAccount" --resource-group \
97+
"rg" --name "Get-AzureVMTutorial"
98+
"""
99+
100+
helps['automation runbook wait'] = """
101+
type: command
102+
short-summary: Place the CLI in a waiting state until a condition of the automation runbook is met.
103+
examples:
104+
- name: Pause executing next line of CLI script until the automation runbook is successfully created.
105+
text: |-
106+
az automation runbook wait --automation-account-name "ContoseAutomationAccount" --resource-group "rg" \
107+
--name "Get-AzureVMTutorial" --created
108+
"""

0 commit comments

Comments
 (0)