Skip to content

Commit 9665d4a

Browse files
authored
Merge pull request #301863 from jasminemehndir/automation-update-23June
Content update to 7 files and enhanced images
2 parents d73b761 + ed8590c commit 9665d4a

18 files changed

+270
-191
lines changed

articles/automation/automation-runbook-types.md

Lines changed: 80 additions & 34 deletions
Large diffs are not rendered by default.

articles/automation/learn/powershell-runbook-managed-identity.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Create PowerShell runbook using managed identity in Azure Automation
2+
title: Create PowerShell Runbook Using Managed Identity in Azure Automation
33
description: In this tutorial, you learn how to use managed identities with a PowerShell runbook in Azure Automation.
44
services: automation
55
ms.subservice: process-automation
66
ms.custom: devx-track-azurepowershell
7-
ms.date: 11/24/2021
7+
ms.date: 06/27/2025
88
ms.topic: tutorial
99
#Customer intent: As a developer, I want PowerShell runbooks to execute code using a manged identity.
1010
ms.service: azure-automation
@@ -14,7 +14,7 @@ author: jasminemehndir
1414

1515
# Tutorial: Create Automation PowerShell runbook using managed identity
1616

17-
This tutorial walks you through creating a [PowerShell runbook](../automation-runbook-types.md#powershell-runbooks) in Azure Automation that uses a [managed identity](../automation-security-overview.md#managed-identities), rather than the Run As account to interact with resources. PowerShell runbooks are based on Windows PowerShell. A managed identity from Microsoft Entra ID allows your runbook to easily access other Microsoft Entra protected resources.
17+
This tutorial walks you through creating a [PowerShell runbook](../automation-runbook-types.md#powershell-runbooks) in Azure Automation that uses a [managed identity](../automation-security-overview.md#managed-identities) to interact with resources. PowerShell runbooks are based on Windows PowerShell. A managed identity from Microsoft Entra ID allows your runbook to easily access other Microsoft Entra protected resources.
1818

1919
In this tutorial, you learn how to:
2020

@@ -26,6 +26,8 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2626

2727
## Prerequisites
2828

29+
Before you assign permissions to managed identities, ensure you meet these prerequisites:
30+
2931
* An Azure Automation account with at least one user-assigned managed identity. For more information, see [Using a user-assigned managed identity for an Azure Automation account](../add-user-assigned-identity.md).
3032
* Az modules: `Az.Accounts`, `Az.Automation`, `Az.ManagedServiceIdentity`, and `Az.Compute` imported into the Automation account. For more information, see [Import Az modules](../shared-resources/modules.md#import-az-modules).
3133
* The [Azure Az PowerShell module](/powershell/azure/new-azureps-module-az) installed on your machine. To install or upgrade, see [How to install the Azure Az PowerShell module](/powershell/azure/install-azure-powershell). `Az.ManagedServiceIdentity` is a preview module and not installed as part of the Az module. To install it, run `Install-Module -Name Az.ManagedServiceIdentity`.
@@ -36,7 +38,9 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
3638

3739
Assign permissions to the managed identities to allow them to stop and start a virtual machine.
3840

39-
1. Sign in to Azure interactively using the [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) cmdlet and follow the instructions.
41+
To assign permissions to managed identities, follow these steps:
42+
43+
1. Sign in to Azure interactively using the [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) cmdlet and follow the instructions:
4044

4145
```powershell
4246
# Sign in to your Azure subscription
@@ -49,7 +53,7 @@ Assign permissions to the managed identities to allow them to stop and start a v
4953
# Select-AzSubscription -SubscriptionId <SUBSCRIPTIONID>
5054
```
5155
52-
1. Provide an appropriate value for the variables below and then execute the script.
56+
1. Enter an appropriate value for the variables below and then execute the script.
5357
5458
```powershell
5559
$resourceGroup = "resourceGroupName"
@@ -71,7 +75,7 @@ Assign permissions to the managed identities to allow them to stop and start a v
7175
-RoleDefinitionName $role1
7276
```
7377
74-
1. The same role assignment is needed for the user-assigned managed identity
78+
1. The same role assignment is needed for the user-assigned managed identity.
7579
7680
```powershell
7781
$UAMI = (Get-AzUserAssignedIdentity -ResourceGroupName $resourceGroup -Name $userAssignedManagedIdentity).PrincipalId
@@ -93,20 +97,24 @@ Assign permissions to the managed identities to allow them to stop and start a v
9397
9498
## Create PowerShell runbook
9599
96-
Create a runbook that will allow execution by either managed identity. The runbook will start a stopped VM, or stop a running VM.
100+
Create a runbook that will allow execution by either managed identity. The runbook will start a stopped VM or stop a running VM.
101+
102+
To create a PowerShell runbook, follow these steps:
97103
98104
1. Sign in to the [Azure portal](https://portal.azure.com/), and navigate to your Automation account.
99105
106+
1. In the **Overview** page, select **Try Runtime Environment experience**, if not already in the new experience.
107+
100108
1. Under **Process Automation**, select **Runbooks**.
101109
102-
1. Select **Create a runbook**.
110+
1. Select **Create a runbook** and do the following:
103111
104112
1. Name the runbook `miTesting`.
105113
1. From the **Runbook type** drop-down, select **PowerShell**.
106-
1. From the **Runtime version** drop-down, select either **7.1 (preview)** or **5.1**.
114+
1. From the **Runtime Environment** dropdown, **Select existing** Runtime environment or **Create new** with Runtime PowerShell and version 7.4.
107115
1. Enter an applicable **Description**.
108116
109-
1. Click **Create** to create the runbook.
117+
1. Select **Create** to create the runbook.
110118
111119
1. In the runbook editor, paste the following code:
112120
@@ -231,7 +239,7 @@ Create a runbook that will allow execution by either managed identity. The runbo
231239
232240
## Clean up Resources
233241
234-
To remove any resources no longer needed, run the following runbook.
242+
To remove any resources no longer needed, run the following runbook:
235243
236244
```powershell
237245
#Remove runbook

0 commit comments

Comments
 (0)