Skip to content

Commit 9328298

Browse files
authored
Merge pull request #173353 from dagiro/1880151
1880151 - Automation CS - learn/automation-tutorial-runbook-textual.md
2 parents 61160bf + 871cf30 commit 9328298

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

articles/automation/learn/automation-tutorial-runbook-textual.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Tutorial - Create a PowerShell Workflow runbook in Azure Automation
33
description: This tutorial teaches you to create, test, and publish a PowerShell Workflow runbook.
44
services: automation
55
ms.subservice: process-automation
6-
ms.date: 09/20/2021
6+
ms.date: 09/23/2021
77
ms.topic: tutorial
88
ms.custom: devx-track-azurepowershell
99
#Customer intent: As a developer, I want use workflow runbooks so that I can automate the parallel starting of VMs.
@@ -184,19 +184,18 @@ You've tested and published your runbook, but so far it doesn't do anything usef
184184
Disable-AzContextAutosave -Scope Process
185185
186186
# Connect to Azure with system-assigned managed identity
187-
Connect-AzAccount -Identity
187+
$AzureContext = (Connect-AzAccount -Identity).context
188188
189189
# set and store context
190-
$subID = (Get-AzContext).Subscription.Id
191-
$AzureContext = Set-AzContext -SubscriptionId $subID
190+
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext
192191
}
193192
```
194193

195194
Edit the `$resourceGroup` variable with a valid value representing your resource group.
196195

197196
1. If you want the runbook to execute with the system-assigned managed identity, leave the code as-is. If you prefer to use a user-assigned managed identity, then:
198-
1. From line 9, remove `Connect-AzAccount -Identity`,
199-
1. Replace it with `Connect-AzAccount -Identity -AccountId <ClientId>`, and
197+
1. From line 9, remove `$AzureContext = (Connect-AzAccount -Identity).context`,
198+
1. Replace it with `$AzureContext = (Connect-AzAccount -Identity -AccountId <ClientId>).context`, and
200199
1. Enter the Client ID you obtained earlier.
201200

202201
1. Select **Save** and then **Test pane**.
@@ -234,7 +233,7 @@ Your runbook currently starts the VM that you've hardcoded in the runbook. It wi
234233

235234
1. Replace the previous `Start-AzVM` command with the following:
236235

237-
```powewrshell
236+
```powershell
238237
Start-AzVM -Name $VMName -ResourceGroupName $resourceGroup -DefaultProfile $AzureContext
239238
```
240239

@@ -262,11 +261,10 @@ You can use the `ForEach -Parallel` construct to process commands for each item
262261
Disable-AzContextAutosave -Scope Process
263262
264263
# Connect to Azure with system-assigned managed identity
265-
Connect-AzAccount -Identity
264+
$AzureContext = (Connect-AzAccount -Identity).context
266265
267266
# set and store context
268-
$subID = (Get-AzContext).Subscription.Id
269-
$AzureContext = Set-AzContext -SubscriptionId $subID
267+
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext
270268
271269
# Start or stop VMs in parallel
272270
if($action -eq "Start")
@@ -290,8 +288,8 @@ You can use the `ForEach -Parallel` construct to process commands for each item
290288
```
291289
292290
1. If you want the runbook to execute with the system-assigned managed identity, leave the code as-is. If you prefer to use a user-assigned managed identity, then:
293-
1. From line 13, remove `Connect-AzAccount -Identity`,
294-
1. Replace it with `Connect-AzAccount -Identity -AccountId <ClientId>`, and
291+
1. From line 13, remove `$AzureContext = (Connect-AzAccount -Identity).context`,
292+
1. Replace it with `$AzureContext = (Connect-AzAccount -Identity -AccountId <ClientId>).context`, and
295293
1. Enter the Client ID you obtained earlier.
296294
297295
1. Select **Save**, then **Publish**, and then **Yes** when prompted.
@@ -322,4 +320,4 @@ If you're not going to continue to use this runbook, delete it with the followin
322320
In this tutorial, you created a PowerShell workflow runbook. For a look at Python 3 runbooks, see:
323321
324322
> [!div class="nextstepaction"]
325-
> [Tutorial: Create a Python 3 runbook (preview)](automation-tutorial-runbook-textual-python-3.md)
323+
> [Tutorial: Create a Python 3 runbook (preview)](automation-tutorial-runbook-textual-python-3.md)

0 commit comments

Comments
 (0)