Skip to content

Commit b396cac

Browse files
authored
Merge pull request #225175 from SnehaSudhirG/26Jan-HRW1
Removed install run as section
2 parents 36b18ab + 97cd693 commit b396cac

File tree

1 file changed

+1
-100
lines changed

1 file changed

+1
-100
lines changed

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

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Define permissions for your runbook to run on the Hybrid Runbook Worker in the f
6363

6464
* Have the runbook provide its own authentication to local resources.
6565
* 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).
66-
* Specify a Run As account to provide a user context for all runbooks.
66+
* Specify Hybrid Worker credentials to provide a user context for all runbooks.
6767

6868
### Use runbook authentication to local resources
6969

@@ -217,105 +217,6 @@ By default, the Hybrid jobs run under the context of System account. However, to
217217
>[!NOTE]
218218
>Linux Hybrid Worker doesn't support Hybrid Worker credentials.
219219
220-
## <a name="runas-script"></a>Install Run As account certificate
221-
222-
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.
223-
224-
>[!NOTE]
225-
>This PowerShell runbook currently does not run on Linux machines. It runs only on Windows machines.
226-
227-
228-
The following PowerShell runbook, called **Export-RunAsCertificateToHybridWorker**, exports the Run As certificate from your Azure Automation account. The runbook downloads and imports the certificate into the local machine certificate store on a Hybrid Runbook Worker that is connected to the same account. Once it completes that step, the runbook verifies that the worker can successfully authenticate to Azure using the Run As account.
229-
230-
>[!NOTE]
231-
>This PowerShell runbook is not designed or intended to be run outside of your Automation account as a script on the target machine.
232-
>
233-
234-
```azurepowershell-interactive
235-
<#PSScriptInfo
236-
.VERSION 1.0
237-
.GUID 3a796b9a-623d-499d-86c8-c249f10a6986
238-
.AUTHOR Azure Automation Team
239-
.COMPANYNAME Microsoft
240-
.COPYRIGHT
241-
.TAGS Azure Automation
242-
.LICENSEURI
243-
.PROJECTURI
244-
.ICONURI
245-
.EXTERNALMODULEDEPENDENCIES
246-
.REQUIREDSCRIPTS
247-
.EXTERNALSCRIPTDEPENDENCIES
248-
.RELEASENOTES
249-
#>
250-
251-
<#
252-
.SYNOPSIS
253-
Exports the Run As certificate from an Azure Automation account to a hybrid worker in that account.
254-
255-
.DESCRIPTION
256-
This runbook exports the Run As certificate from an Azure Automation account to a hybrid worker in that account. Run this runbook on the hybrid worker where you want the certificate installed. This allows the use of the AzureRunAsConnection to authenticate to Azure and manage Azure resources from runbooks running on the hybrid worker.
257-
258-
.EXAMPLE
259-
.\Export-RunAsCertificateToHybridWorker
260-
261-
.NOTES
262-
LASTEDIT: 2016.10.13
263-
#>
264-
265-
# Generate the password used for this certificate
266-
Add-Type -AssemblyName System.Web -ErrorAction SilentlyContinue | Out-Null
267-
$Password = [System.Web.Security.Membership]::GeneratePassword(25, 10)
268-
269-
# Stop on errors
270-
$ErrorActionPreference = 'stop'
271-
272-
# Get the management certificate that will be used to make calls into Azure Service Management resources
273-
$RunAsCert = Get-AutomationCertificate -Name "AzureRunAsCertificate"
274-
275-
# location to store temporary certificate in the Automation service host
276-
$CertPath = Join-Path $env:temp "AzureRunAsCertificate.pfx"
277-
278-
# Save the certificate
279-
$Cert = $RunAsCert.Export("pfx",$Password)
280-
Set-Content -Value $Cert -Path $CertPath -Force -Encoding Byte | Write-Verbose
281-
282-
Write-Output ("Importing certificate into $env:computername local machine root store from " + $CertPath)
283-
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
284-
Import-PfxCertificate -FilePath $CertPath -CertStoreLocation Cert:\LocalMachine\My -Password $SecurePassword | Write-Verbose
285-
286-
Remove-Item -Path $CertPath -ErrorAction SilentlyContinue | Out-Null
287-
288-
# Test to see if authentication to Azure Resource Manager is working
289-
$RunAsConnection = Get-AutomationConnection -Name "AzureRunAsConnection"
290-
291-
Connect-AzAccount `
292-
-ServicePrincipal `
293-
-Tenant $RunAsConnection.TenantId `
294-
-ApplicationId $RunAsConnection.ApplicationId `
295-
-CertificateThumbprint $RunAsConnection.CertificateThumbprint | Write-Verbose
296-
297-
Set-AzContext -Subscription $RunAsConnection.SubscriptionID | Write-Verbose
298-
299-
# List automation accounts to confirm that Azure Resource Manager calls are working
300-
Get-AzAutomationAccount | Select-Object AutomationAccountName
301-
```
302-
303-
>[!NOTE]
304-
>For PowerShell runbooks, `Add-AzAccount` and `Add-AzureRMAccount` are aliases for `Connect-AzAccount`. When searching your library items, if you do not see `Connect-AzAccount`, you can use `Add-AzAccount`, or you can update your modules in your Automation account.
305-
306-
To finish preparing the Run As account:
307-
308-
1. Save the **Export-RunAsCertificateToHybridWorker** runbook to your computer with a **.ps1** extension.
309-
1. Import it into your Automation account.
310-
1. Edit the runbook, changing the value of the `Password` variable to your own password.
311-
1. Publish the runbook.
312-
1. Run the runbook, targeting the Hybrid Runbook Worker group that runs and authenticates runbooks using the Run As account.
313-
1. 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.
314-
315-
>[!NOTE]
316-
> In case of unrestricted access, a user with VM Contributor rights or having permissions to run commands against the hybrid worker machine can use the Automation Account Run As certificate from the hybrid worker machine, using other sources like Azure cmdlets which could potentially allow a malicious user access as a subscription contributor. This could jeopardize the security of your Azure environment. </br> </br>
317-
> We recommend that you divide the tasks within the team and grant the required permissions/access to users as per their job. Do not provide unrestricted permissions to the machine hosting the hybrid runbook worker role.
318-
319220
## Start a runbook on a Hybrid Runbook Worker
320221
321222
[Start a runbook in Azure Automation](start-runbooks.md) describes different methods for starting a runbook. Starting 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.

0 commit comments

Comments
 (0)