Skip to content

Commit 422b63d

Browse files
author
Ankita Dutta
committed
PM and peer review
1 parent 07c2ca9 commit 422b63d

File tree

1 file changed

+21
-136
lines changed

1 file changed

+21
-136
lines changed

articles/site-recovery/how-to-migrate-run-as-accounts-managed-identity.md

Lines changed: 21 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: ankitaduttaMSFT
55
ms.service: site-recovery
66
ms.author: ankitadutta
77
ms.topic: how-to
8-
ms.date: 02/21/2023
8+
ms.date: 02/23/2023
99
---
1010

1111
# Migrate from a Run As account to Managed Identities
@@ -14,32 +14,22 @@ ms.date: 02/21/2023
1414
> - Azure Automation Run As Account will retire on September 30, 2023 and will be replaced with Managed Identities. Before that date, you'll need to start migrating your runbooks to use [managed identities](/articles/automation/automation-security-overview.md#managed-identities). For more information, see [migrating from an existing Run As accounts to managed identity](/articles/automation/migrate-run-as-accounts-managed-identity?tabs=run-as-account#sample-scripts).
1515
> - Delaying the feature has a direct impact on our support burden, as it would cause upgrades of mobility agent to fail.
1616
17-
This article shows you how to migrate a Managed Identities for Azure Site Recovery applications. Azure Automation Accounts are used by Azure Site Recovery customers to auto-update the agents of their protected virtual machines. Site Recovery creates Azure Automation Run As Accounts when you enable replication via the IaaS VM Blade and Recovery Services Vault.
17+
This article shows you how to migrate your runbooks to use a Managed Identities for Azure Site Recovery. Azure Automation Accounts are used by Azure Site Recovery customers to auto-update the agents of their protected virtual machines. Site Recovery creates Azure Automation Run As Accounts when you enable replication via the IaaS VM Blade and Recovery Services Vault.
1818

1919
On Azure, managed identities eliminate the need for developers having to manage credentials by providing an identity for the Azure resource in Azure Active Directory (Azure AD) and using it to obtain Azure AD tokens.
2020

2121
## Prerequisites
2222

23-
Before you migrate from a Run As account to a managed identity:
24-
25-
1. Create a [system-assigned](../automation/enable-managed-identity-for-automation.md) or [user-assigned](../automation/add-user-assigned-identity.md) managed identity, or create both types. To learn more about the differences between them, see [Managed identity types](../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types).
26-
27-
> [!NOTE]
28-
> - User-assigned identities are supported for cloud jobs only. It isn't possible to use the Automation account's user-managed identity on a hybrid runbook worker. To use hybrid jobs, you must create system-assigned identities.
29-
> - There are two ways to use managed identities in hybrid runbook worker scripts: either the system-assigned managed identity for the Automation account *or* the virtual machine (VM) managed identity for an Azure VM running as a hybrid runbook worker.
30-
> - The VM's user-assigned managed identity and the VM's system-assigned managed identity will *not* work in an Automation account that's configured with an Automation account's managed identity. When you enable the Automation account's managed identity, you can use only the Automation account's system-assigned managed identity and not the VM managed identity. For more information, see [Use runbook authentication with managed identities](../automation/automation-hrw-run-runbooks.md).
31-
32-
1. Assign the same role to the managed identity to access the Azure resources that match the Run As account. Follow the steps in [Check the role assignment for the Azure Automation Run As account](../automation/manage-run-as-account.md#check-role-assignment-for-azure-automation-run-as-account).
33-
34-
Ensure that you don't assign high-privilege permissions like contributor or owner to the Run As account. Follow the role-based access control (RBAC) guidelines to limit the permissions from the default contributor permissions assigned to a Run As account by using [this script](../automation/manage-run-as-account.md#limit-run-as-account-permissions).
23+
Before you migrate from a Run As account to a managed identity, ensure that you have the appropriate roles to create a system-assigned identity for your automation account and to assign it the Contributor role in the corresponding recovery services vault.
3524

3625
## Benefits of managed identities
3726

3827
Here are some of the benefits of using managed identities:
3928

40-
- You don't need to manage credentials. Credentials aren’t even accessible to you.
41-
- You can use managed identities to authenticate to any resource that supports [Azure AD authentication](../authentication/overview-authentication.md), including your own applications.
42-
- Managed identities can be used at no extra cost.
29+
- **Credentials access** - You don't need to manage credentials.
30+
- **Simplified authentication** - You can use managed identities to authenticate to any resource that supports [Azure AD authentication](/articles/authentication/overview-authentication.md), including your own applications.
31+
- **Cost effective** - Managed identities can be used at no extra cost.
32+
- **Double encryption** - Managed identity is also used to encrypt/decrypt data and metadata using the customer-managed key stored in Azure Key Vault, providing double encryption.
4333

4434
> [!NOTE]
4535
> Managed identities for Azure resources is the new name for the service formerly known as Managed Service Identity (MSI).
@@ -58,19 +48,19 @@ You can configure your managed identities through:
5848
> For more information about migration cadence and the support timeline for Run As account creation and certificate renewal, see the [frequently asked questions](../automation/automation-managed-identity-faq.md).
5949
6050

61-
### Portal experience
51+
### From Azure portal
6252

6353
**To migrate your Azure Automation account authentication type from a Run As to a managed identity authentication, follow these steps:**
6454

65-
1. In the [Azure portal](https://portal.azure.com), navigate and select the recovery services vault that you want to migrate.
55+
1. In the [Azure portal](https://portal.azure.com), select the recovery services vault for which you want to migrate the runbooks.
6656

6757
1. On the homepage of your recovery services vault page, do the following:
68-
1. On the left pane, under the **Manage** section, select **Site Recovery infrastructure**.
58+
1. On the left pane, under **Manage**, select **Site Recovery infrastructure**.
6959
:::image type="content" source="./media/how-to-migrate-from-run-as-to-managed-identities/manage-section.png" alt-text="Screenshot of the **Site Recovery infrastructure** page.":::
70-
1. Under the **For Azure virtual machines** section, select **Extension update settings**.
60+
1. Under **For Azure virtual machines**, select **Extension update settings**.
7161
This page details the authentication type for the automation account that is being used to manage the Site Recovery extensions.
7262

73-
1. On this page, select the **Migrate** option to migrate the authentication type for your automation accounts to use Managed Identities.
63+
1. On this page, select **Migrate** to migrate the authentication type for your automation accounts to use Managed Identities.
7464

7565
:::image type="content" source="./media/how-to-migrate-from-run-as-to-managed-identities/extension-update-settings.png" alt-text="Screenshot of the Create Recovery Services vault page.":::
7666

@@ -85,142 +75,37 @@ When you successfully migrate from a Run As to a Managed Identities account, the
8575

8676
### Link an existing managed identity account to vault
8777

88-
You can link an existing managed identity Automation account to your Recovery Services vault. To do so, follow these steps:
78+
To link an existing managed identity Automation account to your Recovery Services vault. Follow these steps:
8979

9080
#### Enable the managed identity for the vault
9181

92-
1. Go to your selected managed identity automation account. Under under **Account settings**, select **Identity**.
82+
1. Go to the automation account that you have selected. Under **Account settings**, select **Identity**.
9383

9484
:::image type="content" source="./media/how-to-migrate-from-run-as-to-managed-identities/mi-automation-account.png" alt-text="Screenshot that shows the identity settings page.":::
9585

96-
1. Under the **System assigned** section, change the **Status** to **On** and select **Save**.
86+
1. Under the **System assigned**, change the **Status** to **On** and select **Save**.
9787

9888
An Object ID is generated. The vault is now registered with Azure Active
9989
Directory.
10090
:::image type="content" source="./media/hybrid-how-to-enable-replication-private-endpoints/enable-managed-identity-in-vault.png" alt-text="Screenshot that shows the system identity settings page.":::
10191

102-
1. Navigate back to your recovery services vault. On the left pane, select the **Access control (IAM)** option.
92+
1. Go back to your recovery services vault. On the left pane, select the **Access control (IAM)** option.
10393
:::image type="content" source="./media/how-to-migrate-from-run-as-to-managed-identities/add-mi-iam.png" alt-text="Screenshot that shows IAM settings page.":::
10494
1. Select **Add** > **Add role assignment** > **Contributor** to open the **Add role assignment** page.
105-
1. On the **Add role assignment** page, ensure that the **Managed identity** option is selected.
106-
1. Select the **Select members** option. This opens the **Select managed identities** pane. On this pane do the following:
107-
1. In the **Select** field, paste the name of the managed identity automation account.
95+
1. On the **Add role assignment** page, ensure to select **Managed identity**.
96+
1. Select the **Select members**. In the **Select managed identities** pane, do the following:
97+
1. In the **Select** field, enter the name of the managed identity automation account.
10898
1. In the **Managed identity** field, select **All system-assigned managed identities**.
10999
1. Select the **Select** option.
110100
:::image type="content" source="./media/how-to-migrate-from-run-as-to-managed-identities/select-mi.png" alt-text="Screenshot that shows select managed identity settings page.":::
111101
1. Select **Review + assign**.
112102

113103

114-
### Azure CLI sample scripts
115-
116-
The following examples of runbook scripts fetch the Resource Manager resources by using the Run As account (service principal) and the managed identity. You would notice the difference in runbook code at the beginning of the runbook, where it authenticates against the resource.
117-
118-
# [Run As account](#tab/run-as-account)
119-
120-
```powershell-interactive
121-
$connectionName = "AzureRunAsConnection"
122-
try
123-
{
124-
# Get the connection "AzureRunAsConnection"
125-
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
126-
127-
"Logging in to Azure..."
128-
Add-AzureRmAccount `
129-
-ServicePrincipal `
130-
-TenantId $servicePrincipalConnection.TenantId `
131-
-ApplicationId $servicePrincipalConnection.ApplicationId `
132-
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
133-
}
134-
catch {
135-
if (!$servicePrincipalConnection)
136-
{
137-
$ErrorMessage = "Connection $connectionName not found."
138-
throw $ErrorMessage
139-
} else{
140-
Write-Error -Message $_.Exception
141-
throw $_.Exception
142-
}
143-
}
144-
145-
#Get all Resource Manager resources from all resource groups
146-
$ResourceGroups = Get-AzureRmResourceGroup
147-
148-
foreach ($ResourceGroup in $ResourceGroups)
149-
{
150-
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
151-
$Resources = Find-AzureRmResource -ResourceGroupNameContains $ResourceGroup.ResourceGroupName | Select ResourceName, ResourceType
152-
ForEach ($Resource in $Resources)
153-
{
154-
Write-Output ($Resource.ResourceName + " of type " + $Resource.ResourceType)
155-
}
156-
Write-Output ("")
157-
}
158-
```
159-
160-
# [System-assigned managed identity](#tab/sa-managed-identity)
161-
162-
>[!NOTE]
163-
> Enable appropriate RBAC permissions for the system identity of this Automation account. Otherwise, the runbook might fail.
164-
165-
```powershell-interactive
166-
try
167-
{
168-
"Logging in to Azure..."
169-
Connect-AzAccount -Identity
170-
}
171-
catch {
172-
Write-Error -Message $_.Exception
173-
throw $_.Exception
174-
}
175-
176-
#Get all Resource Manager resources from all resource groups
177-
$ResourceGroups = Get-AzResourceGroup
178-
179-
foreach ($ResourceGroup in $ResourceGroups)
180-
{
181-
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
182-
$Resources = Get-AzResource -ResourceGroupName $ResourceGroup.ResourceGroupName
183-
foreach ($Resource in $Resources)
184-
{
185-
Write-Output ($Resource.Name + " of type " + $Resource.ResourceType)
186-
}
187-
Write-Output ("")
188-
}
189-
```
190-
# [User-assigned managed identity](#tab/ua-managed-identity)
191-
192-
```powershell-interactive
193-
try
194-
{
195-
196-
"Logging in to Azure..."
197-
198-
$identity = Get-AzUserAssignedIdentity -ResourceGroupName <myResourceGroup> -Name <myUserAssignedIdentity>
199-
Connect-AzAccount -Identity -AccountId $identity.ClientId
200-
}
201-
catch {
202-
Write-Error -Message $_.Exception
203-
throw $_.Exception
204-
}
205-
#Get all Resource Manager resources from all resource groups
206-
$ResourceGroups = Get-AzResourceGroup
207-
foreach ($ResourceGroup in $ResourceGroups)
208-
{
209-
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
210-
$Resources = Get-AzResource -ResourceGroupName $ResourceGroup.ResourceGroupName
211-
foreach ($Resource in $Resources)
212-
{
213-
Write-Output ($Resource.Name + " of type " + $Resource.ResourceType)
214-
}
215-
Write-Output ("")
216-
}
217-
```
218-
---
219104

220105
## Next steps
221106

222107
Learn more about:
223-
- [Managed identities](../active-directory/managed-identities-azure-resources/overview).
108+
- [Managed identities](/articles/active-directory/managed-identities-azure-resources/overview).
224109
- [Implementing managed identities for Microsoft Azure Resources](https://www.pluralsight.com/courses/microsoft-azure-resources-managed-identities-implementing).
225-
- [FAQ for migrating from a Run As account to a managed identity](../automation/automation-managed-identity-faq).
110+
- [FAQ for migrating from a Run As account to a managed identity](/articles/automation/automation-managed-identity-faq).
226111
- [FAQ for Managed Identities](../active-directory/managed-identities-azure-resources/managed-identities-faq.md)

0 commit comments

Comments
 (0)