Skip to content

Commit e6d328f

Browse files
author
Ankita Dutta
committed
deleting concept and adding to how-to
1 parent 0193976 commit e6d328f

File tree

2 files changed

+114
-174
lines changed

2 files changed

+114
-174
lines changed

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

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ ms.date: 01/19/2023
1616
1717
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.
1818

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

2022
## Prerequisites
2123

@@ -52,11 +54,121 @@ When a managed identity is added, deleted, or modified on a running container ap
5254

5355
### Portal experience
5456

55-
57+
-
58+
59+
### Azure CLI sample scripts
60+
61+
The following examples of runbook scripts fetch the Resource Manager resources by using the Run As account (service principal) and the managed identity.
62+
63+
# [Run As account](#tab/run-as-account)
64+
65+
```powershell-interactive
66+
$connectionName = "AzureRunAsConnection"
67+
try
68+
{
69+
# Get the connection "AzureRunAsConnection"
70+
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
71+
72+
"Logging in to Azure..."
73+
Add-AzureRmAccount `
74+
-ServicePrincipal `
75+
-TenantId $servicePrincipalConnection.TenantId `
76+
-ApplicationId $servicePrincipalConnection.ApplicationId `
77+
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
78+
}
79+
catch {
80+
if (!$servicePrincipalConnection)
81+
{
82+
$ErrorMessage = "Connection $connectionName not found."
83+
throw $ErrorMessage
84+
} else{
85+
Write-Error -Message $_.Exception
86+
throw $_.Exception
87+
}
88+
}
89+
90+
#Get all Resource Manager resources from all resource groups
91+
$ResourceGroups = Get-AzureRmResourceGroup
92+
93+
foreach ($ResourceGroup in $ResourceGroups)
94+
{
95+
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
96+
$Resources = Find-AzureRmResource -ResourceGroupNameContains $ResourceGroup.ResourceGroupName | Select ResourceName, ResourceType
97+
ForEach ($Resource in $Resources)
98+
{
99+
Write-Output ($Resource.ResourceName + " of type " + $Resource.ResourceType)
100+
}
101+
Write-Output ("")
102+
}
103+
```
104+
105+
# [System-assigned managed identity](#tab/sa-managed-identity)
106+
107+
>[!NOTE]
108+
> Enable appropriate RBAC permissions for the system identity of this Automation account. Otherwise, the runbook might fail.
109+
110+
```powershell-interactive
111+
try
112+
{
113+
"Logging in to Azure..."
114+
Connect-AzAccount -Identity
115+
}
116+
catch {
117+
Write-Error -Message $_.Exception
118+
throw $_.Exception
119+
}
120+
121+
#Get all Resource Manager resources from all resource groups
122+
$ResourceGroups = Get-AzResourceGroup
123+
124+
foreach ($ResourceGroup in $ResourceGroups)
125+
{
126+
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
127+
$Resources = Get-AzResource -ResourceGroupName $ResourceGroup.ResourceGroupName
128+
foreach ($Resource in $Resources)
129+
{
130+
Write-Output ($Resource.Name + " of type " + $Resource.ResourceType)
131+
}
132+
Write-Output ("")
133+
}
134+
```
135+
# [User-assigned managed identity](#tab/ua-managed-identity)
136+
137+
```powershell-interactive
138+
try
139+
{
140+
141+
"Logging in to Azure..."
142+
143+
$identity = Get-AzUserAssignedIdentity -ResourceGroupName <myResourceGroup> -Name <myUserAssignedIdentity>
144+
Connect-AzAccount -Identity -AccountId $identity.ClientId
145+
}
146+
catch {
147+
Write-Error -Message $_.Exception
148+
throw $_.Exception
149+
}
150+
#Get all Resource Manager resources from all resource groups
151+
$ResourceGroups = Get-AzResourceGroup
152+
foreach ($ResourceGroup in $ResourceGroups)
153+
{
154+
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
155+
$Resources = Get-AzResource -ResourceGroupName $ResourceGroup.ResourceGroupName
156+
foreach ($Resource in $Resources)
157+
{
158+
Write-Output ($Resource.Name + " of type " + $Resource.ResourceType)
159+
}
160+
Write-Output ("")
161+
}
162+
```
163+
---
56164

57165
## Next steps
58166

59167
Learn more about:
60168
- [Managed identities](../active-directory/managed-identities-azure-resources/overview).
61169
- [Using a system-assigned managed identity for an Azure Automation account](../automation/enable-managed-identity-for-automation).
62-
- [Using a user-assigned managed identity for an Azure Automation account](../automation/add-user-assigned-identity).
170+
- [Using a user-assigned managed identity for an Azure Automation account](../automation/add-user-assigned-identity).
171+
- [Connecting from your application to resources without handling credentials](../active-directory/managed-identities-azure-resources/overview-for-developers?tabs=portal%2Cdotnet)
172+
- [Implementing managed identities for Microsoft Azure Resources](https://www.pluralsight.com/courses/microsoft-azure-resources-managed-identities-implementing).
173+
- [FAQ for migrating from a Run As account to a managed identity](../automation/automation-managed-identity-faq).
174+
- [FAQ for Managed Identities](../active-directory/managed-identities-azure-resources/managed-identities-faq.md)

articles/site-recovery/site-recovery-managed-identities.md

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)