Skip to content

Commit a7d5a6b

Browse files
committed
Fixing task 1667836
1 parent add71e6 commit a7d5a6b

6 files changed

+196
-172
lines changed

articles/automation/automation-hrw-run-runbooks.md

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ ms.topic: conceptual
88
---
99
# Run runbooks on a Hybrid Runbook Worker
1010

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.
1212

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.
1414

1515
>[!NOTE]
1616
>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
2323

2424
## Set up runbook permissions
2525

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

2828
* Have the runbook provide its own authentication to local resources.
2929
* 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).
3030
* Specify a Run As account to provide a user context for all runbooks.
3131

3232
## Use runbook authentication to local resources
3333

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.
3535

3636
```powershell
3737
$Cred = Get-AutomationPSCredential -Name "MyCredential"
@@ -40,34 +40,34 @@ $Computer = Get-AutomationVariable -Name "ComputerName"
4040
Restart-Computer -ComputerName $Computer -Credential $Cred
4141
```
4242

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 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.
4444

4545
## <a name="runbook-auth-managed-identities"></a>Use runbook authentication with managed identities
4646

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

4949
* Export the Run As certificate and then import it into the Hybrid Runbook Worker.
5050
* Renew the certificate used by the Run As account.
5151
* Handle the Run As connection object in your runbook code.
5252

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

5555
1. Create an Azure VM.
5656
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).
5757
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).
5959
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.
6060

61-
```powershell
61+
```powershell
6262
# Connect to Azure using the managed identities for Azure resources identity configured on the Azure VM that is hosting the hybrid runbook worker
6363
Connect-AzAccount -Identity
6464
6565
# Get all VM names from the subscription
6666
Get-AzVM | Select Name
67-
```
67+
```
6868
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.
7171
7272
## Use runbook authentication with Run As account
7373
@@ -79,16 +79,16 @@ The user name for the credential must be in one of the following formats:
7979
* username@domain
8080
* username (for accounts local to the on-premises computer)
8181
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:
8383
8484
1. Create a [credential asset](automation-credentials.md) with access to local resources.
8585
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.
8787
4. Select **All settings**, followed by **Hybrid worker group settings**.
8888
5. Change the value of **Run As** from **Default** to **Custom**.
8989
6. Select the credential and click **Save**.
9090
91-
### <a name="runas-script"></a>Install Run As account certificate
91+
## <a name="runas-script"></a>Install Run As account certificate
9292
9393
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.
9494
@@ -171,29 +171,14 @@ To finish preparing the Run As account:
171171
3. Edit the runbook, changing the value of the `Password` variable to your own password.
172172
4. Publish the runbook.
173173
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.
183-
184-
```azurepowershell-interactive
185-
Start-AzAutomationRunbook –AutomationAccountName "MyAutomationAccount" –Name "Test-Runbook" -RunOn "MyHybridGroup"
186-
```
187-
188-
> [!NOTE]
189-
> 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.
190175

191176
## Work with signed runbooks on a Windows Hybrid Runbook Worker
192177

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.
194179

195180
> [!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.
197182
198183
### Create signing certificate
199184

@@ -223,7 +208,7 @@ $SigningCert.Thumbprint
223208

224209
### Import certificate and configure workers for signature validation
225210

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.
227212

228213
```powershell
229214
# 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
253238
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.
254239

255240
> [!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.
257242
258243
### Create a GPG keyring and keypair
259244

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).
261246

262247
1. Use the sudo application to sign in as the **nxautomation** account.
263248

@@ -295,7 +280,7 @@ sudo python /opt/microsoft/omsconfig/modules/nxOMSAutomationWorker/DSCResources/
295280

296281
### Sign a runbook
297282

298-
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.
299284

300285
```bash
301286
gpg –-clear-sign <runbook name>
@@ -305,9 +290,20 @@ The signed runbook is called **<runbook name>.asc**.
305290

306291
You can now upload the signed runbook to Azure Automation and execute it like a regular runbook.
307292

293+
## Start a runbook on a Hybrid Runbook Worker
294+
295+
[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.
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.
300+
301+
```azurepowershell-interactive
302+
Start-AzAutomationRunbook –AutomationAccountName "MyAutomationAccount" –Name "Test-Runbook" -RunOn "MyHybridGroup"
303+
```
304+
308305
## Next steps
309306
310-
* 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).
311307
* If your runbooks aren't completing successfully, review the troubleshooting guide for [runbook execution failures](troubleshoot/hybrid-runbook-worker.md#runbook-execution-fails).
312308
* For more information on PowerShell, including language reference and learning modules, refer to the [PowerShell Docs](https://docs.microsoft.com/powershell/scripting/overview).
313309
* 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

Comments
 (0)