You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/automation/automation-hrw-run-runbooks.md
+34-38Lines changed: 34 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ ms.topic: conceptual
8
8
---
9
9
# Run runbooks on a Hybrid Runbook Worker
10
10
11
-
Runbooks that target a Hybrid Runbook Worker typically manage resources on the local computer or against resources in the local environment where the worker is deployed. Runbooks in Azure Automation typically manage resources in the Azure cloud. Even though they are used differently, runbooks that run in Azure Automation and runbooks that run on a Hybrid Runbook Worker are identical in structure.
11
+
Runbooks that run on a [Hybrid Runbook Worker](automation-hybrid-runbook-worker.md) typically manage resources on the local computer or against resources in the local environment where the worker is deployed. Runbooks in Azure Automation typically manage resources in the Azure cloud. Even though they are used differently, runbooks that run in Azure Automation and runbooks that run on a Hybrid Runbook Worker are identical in structure.
12
12
13
-
When you author a runbook to run on a Hybrid Runbook Worker, you should edit and test the runbook on the machine that hosts the worker. The host machine has all the PowerShell modules and network access required to manage and access the local resources. Once you test the runbook on the Hybrid Runbook Worker machine, you can then upload it to the Azure Automation environment, where it can be run on the worker.
13
+
When you author a runbook to run on a Hybrid Runbook Worker, you should edit and test the runbook on the machine that hosts the worker. The host machine has all the PowerShell modules and network access required to manage the local resources. Once you test the runbook on the Hybrid Runbook Worker machine, you can then upload it to the Azure Automation environment, where it can be run on the worker.
14
14
15
15
>[!NOTE]
16
16
>This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see [Introducing the new Azure PowerShell Az module](https://docs.microsoft.com/powershell/azure/new-azureps-module-az?view=azps-3.5.0). For Az module installation instructions on your Hybrid Runbook Worker, see [Install the Azure PowerShell Module](https://docs.microsoft.com/powershell/azure/install-az-ps?view=azps-3.5.0). For your Automation account, you can update your modules to the latest version using [How to update Azure PowerShell modules in Azure Automation](automation-update-azure-modules.md).
@@ -23,15 +23,15 @@ Remember that jobs for Hybrid Runbook Workers run under the local **System** acc
23
23
24
24
## Set up runbook permissions
25
25
26
-
You define permissions for your runbook to run on the Hybrid Runbook Manager in the following ways:
26
+
Define permissions for your runbook to run on the Hybrid Runbook Worker in the following ways:
27
27
28
28
* Have the runbook provide its own authentication to local resources.
29
29
* Configure authentication using [managed identities for Azure resources](../active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-arm.md#grant-your-vm-access-to-a-resource-group-in-resource-manager).
30
30
* Specify a Run As account to provide a user context for all runbooks.
31
31
32
32
## Use runbook authentication to local resources
33
33
34
-
If preparing a runbook that provides its own authentication to resources, use [Credential](automation-credentials.md) and [Certificate](automation-certificates.md) assets in your runbook. There are several cmdlets that allow you to specify credentials so that the runbook can authenticate to different resources. The following example shows a portion of a runbook that restarts a computer. It retrieves credentials from a credential asset and the name of the computer from a variable asset and then uses these values with the `Restart-Computer` cmdlet.
34
+
If preparing a runbook that provides its own authentication to resources, use [credential](automation-credentials.md) and [certificate](automation-certificates.md) assets in your runbook. There are several cmdlets that allow you to specify credentials so that the runbook can authenticate to different resources. The following example shows a portion of a runbook that restarts a computer. It retrieves credentials from a credential asset and the name of the computer from a variable asset and then uses these values with the `Restart-Computer` cmdlet.
You can also use an [InlineScript](automation-powershell-workflow.md#inlinescript) activity. `InlineScript` allows you to run blocks of code on another computer with credentials specified by the [PSCredential common parameter](/powershell/module/psworkflow/about/about_workflowcommonparameters).
43
+
You can also use an [InlineScript](automation-powershell-workflow.md#inlinescript) activity. `InlineScript` allows you to run blocks of code on another computer with credentials.
44
44
45
45
## <aname="runbook-auth-managed-identities"></a>Use runbook authentication with managed identities
46
46
47
-
Hybrid Runbook Workers on Azure virtual machines can use managed identities for Azure resources to authenticate to Azure resources. Using managed identities for Azure resources instead of Run As accounts provides benefits because you don't need to:
47
+
Hybrid Runbook Workers on Azure virtual machines can use managed identities to authenticate to Azure resources. Using managed identities for Azure resources instead of Run As accounts provides benefits because you don't need to:
48
48
49
49
* Export the Run As certificate and then import it into the Hybrid Runbook Worker.
50
50
* Renew the certificate used by the Run As account.
51
51
* Handle the Run As connection object in your runbook code.
52
52
53
-
Follow the next steps to use a managed identity for Azure resources on a Hybrid Runbook Worker.
53
+
Follow the next steps to use a managed identity for Azure resources on a Hybrid Runbook Worker:
54
54
55
55
1. Create an Azure VM.
56
56
2. Configure managed identities for Azure resources on the VM. See [Configure managed identities for Azure resources on a VM using the Azure portal](../active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm.md#enable-system-assigned-managed-identity-on-an-existing-vm).
57
57
3. Give the VM access to a resource group in Resource Manager. Refer to [Use a Windows VM system-assigned managed identity to access Resource Manager](../active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-arm.md#grant-your-vm-access-to-a-resource-group-in-resource-manager).
58
-
4. Install the Hybrid Runbook worker on the VM. See [Deploy a Windows Hybrid Runbook Worker](automation-windows-hrw-install.md).
58
+
4. Install the Hybrid Runbook Worker on the VM. See [Deploy a Windows Hybrid Runbook Worker](automation-windows-hrw-install.md) or [Deploy a Linux Hybrid Runbook Worker](automation-linux-hrw-install.md).
59
59
5. Update the runbook to use the [Connect-AzAccount](https://docs.microsoft.com/powershell/module/az.accounts/connect-azaccount?view=azps-3.5.0) cmdlet with the `Identity` parameter to authenticate to Azure resources. This configuration reduces the need to use a Run As account and perform the associated account management.
60
60
61
-
```powershell
61
+
```powershell
62
62
# Connect to Azure using the managed identities for Azure resources identity configured on the Azure VM that is hosting the hybrid runbook worker
63
63
Connect-AzAccount -Identity
64
64
65
65
# Get all VM names from the subscription
66
66
Get-AzVM | Select Name
67
-
```
67
+
```
68
68
69
-
> [!NOTE]
70
-
> `Connect-AzAccount -Identity` works for a Hybrid Runbook Worker using a system-assigned identity and a single user-assigned identity. If you use multiple user-assigned identities on the Hybrid Runbook Worker, your runbook must specify the `AccountId` parameter for `Connect-AzAccount` to select a specific user-assigned identity.
69
+
> [!NOTE]
70
+
> `Connect-AzAccount -Identity` works for a Hybrid Runbook Worker using a system-assigned identity and a single user-assigned identity. If you use multiple user-assigned identities on the Hybrid Runbook Worker, your runbook must specify the `AccountId` parameter for `Connect-AzAccount` to select a specific user-assigned identity.
71
71
72
72
## Use runbook authentication with Run As account
73
73
@@ -79,16 +79,16 @@ The user name for the credential must be in one of the following formats:
79
79
* username@domain
80
80
* username (for accounts local to the on-premises computer)
81
81
82
-
Use the following procedure to specify a Run As account for a Hybrid Runbook Worker group.
82
+
Use the following procedure to specify a Run As account for a Hybrid Runbook Worker group:
83
83
84
84
1. Create a [credential asset](automation-credentials.md) with access to local resources.
85
85
2. Open the Automation account in the Azure portal.
86
-
3. Select the **Hybrid Worker Groups** tile, and then select the group.
86
+
3. Select **Hybrid Worker Groups**, and then select the specific group.
87
87
4. Select **All settings**, followed by **Hybrid worker group settings**.
88
88
5. Change the value of **Run As** from **Default** to **Custom**.
89
89
6. Select the credential and click **Save**.
90
90
91
-
###<aname="runas-script"></a>Install Run As account certificate
91
+
## <a name="runas-script"></a>Install Run As account certificate
92
92
93
93
As part of your automated build process for deploying resources in Azure, you might require access to on-premises systems to support a task or set of steps in your deployment sequence. To provide authentication against Azure using the Run As account, you must install the Run As account certificate.
94
94
@@ -171,29 +171,14 @@ To finish preparing the Run As account:
171
171
3. Edit the runbook, changing the value of the `Password` variable to your own password.
172
172
4. Publish the runbook.
173
173
5. Run the runbook, targeting the Hybrid Runbook Worker group that runs and authenticates runbooks using the Run As account.
174
-
6. Examine the job stream to see that it reports the attempt to import the certificate into the local machine store, and follows with multiple lines. This behavior depends on how many Automation accounts you define in your subscription and the degree of success of the authentication.
175
-
176
-
## Start a runbook on a Hybrid Runbook Worker
177
-
178
-
[Start a runbook in Azure Automation](start-runbooks.md) describes different methods for starting a runbook. Startup for a runbook on a Hybrid Runbook Worker uses a **Run on** option that allows you to specify the name of a Hybrid Runbook Worker group. When a group is specified, one of the workers in that group retrieves and runs the runbook. If your runbook does not specify this option, Azure Automation runs the runbook as usual.
179
-
180
-
When you start a runbook in the Azure portal, you're presented with the **Run on** option for which you can select **Azure** or **Hybrid Worker**. If you select **Hybrid Worker**, you can choose the Hybrid Runbook Worker group from a dropdown.
181
-
182
-
Use the `RunOn` parameter with the [Start-AzAutomationRunbook](https://docs.microsoft.com/powershell/module/Az.Automation/Start-AzAutomationRunbook?view=azps-3.7.0) cmdlet. The following example uses Windows PowerShell to start a runbook named **Test-Runbook** on a Hybrid Runbook Worker group named MyHybridGroup.
> You should [download the latest PowerShell version](https://azure.microsoft.com/downloads/) if you have an earlier one installed. Only install this version on the workstation where you are starting the runbook from PowerShell. You do not need to install it on the Hybrid Runbook Worker computer unless you intend to start runbooks from this computer.
174
+
6. Examine the job stream to see that it reports the attempt to import the certificate into the local machine store, followed by multiple lines. This behavior depends on how many Automation accounts you define in your subscription and the degree of success of the authentication.
190
175
191
176
## Work with signed runbooks on a Windows Hybrid Runbook Worker
192
177
193
-
You can configure a Windows Hybrid Runbook Worker to run only signed runbooks.
178
+
You can configure a Windows Hybrid Runbook Worker to run only signed runbooks.
194
179
195
180
> [!IMPORTANT]
196
-
> Once you have configured a Hybrid Runbook Worker to run only signed runbooks, runbooks that have not been signed will fail to execute on the worker.
181
+
> Once you've configured a Hybrid Runbook Worker to run only signed runbooks, unsigned runbooks fail to execute on the worker.
197
182
198
183
### Create signing certificate
199
184
@@ -223,7 +208,7 @@ $SigningCert.Thumbprint
223
208
224
209
### Import certificate and configure workers for signature validation
225
210
226
-
Copy the certificate that you have created to each Hybrid Runbook Worker in a group. Run the following script to import the certificate and configure the workers to use signature validation on runbooks.
211
+
Copy the certificate that you've created to each Hybrid Runbook Worker in a group. Run the following script to import the certificate and configure the workers to use signature validation on runbooks.
227
212
228
213
```powershell
229
214
# Install the certificate into a location that will be used for validation.
@@ -253,11 +238,11 @@ When a runbook has been signed, you must import it into your Automation account
253
238
To be able to work with signed runbooks, a Linux Hybrid Runbook Worker must have the [GPG](https://gnupg.org/index.html) executable on the local machine.
254
239
255
240
> [!IMPORTANT]
256
-
> Once you have configured a Hybrid Runbook Worker to run only signed runbooks, runbooks that have not been signed will fail to execute on the worker.
241
+
> Once you've configured a Hybrid Runbook Worker to run only signed runbooks, unsigned runbooks fail to execute on the worker.
257
242
258
243
### Create a GPG keyring and keypair
259
244
260
-
To create the GPG keyring and keypair, use the Hybrid Runbook Worker **nxautomation** account.
245
+
To create the GPG keyring and keypair, use the Hybrid Runbook Worker [nxautomation account](automation-runbook-execution.md#log-analytics-agent-for-linux).
261
246
262
247
1. Use the sudo application to sign in as the **nxautomation** account.
Once you have configured signature validation, use the following GPG command to sign a runbook.
283
+
Once you have configured signature validation, use the following GPG command to sign the runbook.
299
284
300
285
```bash
301
286
gpg –-clear-sign <runbook name>
@@ -305,9 +290,20 @@ The signed runbook is called **<runbook name>.asc**.
305
290
306
291
You can now upload the signed runbook to Azure Automation and execute it like a regular runbook.
307
292
293
+
## Start a runbook on a Hybrid Runbook Worker
294
+
295
+
[Start a runbook in Azure Automation](start-runbooks.md) describes different methods forstarting a runbook. Startup for a runbook on a Hybrid Runbook Worker uses a **Run on** option that allows you to specify the name of a Hybrid Runbook Worker group. When a group is specified, one of the workersin that group retrieves and runs the runbook. If your runbook does not specify this option, Azure Automation runs the runbook as usual.
296
+
297
+
When you start a runbook in the Azure portal, you're presented with the **Run on** option for which you can select **Azure** or **Hybrid Worker**. If you select **Hybrid Worker**, you can choose the Hybrid Runbook Worker group from a dropdown.
298
+
299
+
When starting a runbook using PowerShell, use the `RunOn` parameter with the [Start-AzAutomationRunbook](https://docs.microsoft.com/powershell/module/Az.Automation/Start-AzAutomationRunbook?view=azps-3.7.0) cmdlet. The following example uses Windows PowerShell to start a runbook named **Test-Runbook** on a Hybrid Runbook Worker group named MyHybridGroup.
* To understand how to use the textual editor to work with PowerShell runbooks in Azure Automation, see [Editing a Runbook in Azure Automation](automation-edit-textual-runbook.md).
311
307
* If your runbooks aren't completing successfully, review the troubleshooting guide for [runbook execution failures](troubleshoot/hybrid-runbook-worker.md#runbook-execution-fails).
312
308
* For more information on PowerShell, including language reference and learning modules, refer to the [PowerShell Docs](https://docs.microsoft.com/powershell/scripting/overview).
313
309
* For a PowerShell cmdlet reference, see [Az.Automation](https://docs.microsoft.com/powershell/module/az.automation/?view=azps-3.7.0#automation
0 commit comments