Skip to content

Commit 60386f4

Browse files
committed
Remove reference to Azure AD PowerShell module
1 parent 65fa8d9 commit 60386f4

File tree

1 file changed

+2
-65
lines changed

1 file changed

+2
-65
lines changed

articles/active-directory/managed-identities-azure-resources/how-to-assign-app-role-managed-identity-powershell.md

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Managed identities for Azure resources provide Azure services with an identity i
2525
> [!NOTE]
2626
> The tokens that your application receives are cached by the underlying infrastructure, which means that any changes to the managed identity's roles can take significant time to take effect. For more information, see [Limitation of using managed identities for authorization](managed-identity-best-practice-recommendations.md#limitation-of-using-managed-identities-for-authorization).
2727
28-
In this article, you learn how to assign a managed identity to an application role exposed by another application using Azure AD PowerShell.
28+
In this article, you learn how to assign a managed identity to an application role exposed by another application using the Microsoft Graph PowerShell SDK.
2929

3030
## Prerequisites
3131

3232
- If you're unfamiliar with managed identities for Azure resources, check out the [overview section](overview.md). **Be sure to review the [difference between a system-assigned and user-assigned managed identity](overview.md#managed-identity-types)**.
3333
- If you don't already have an Azure account, [sign up for a free account](https://azure.microsoft.com/free/) before continuing.
3434
- To run the example scripts, you have two options:
3535
- Use the [Azure Cloud Shell](../../cloud-shell/overview.md), which you can open using the **Try It** button on the top-right corner of code blocks.
36-
- Run scripts locally by installing the latest version of [the Az PowerShell module](/powershell/azure/install-az-ps). You can also use the [Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/get-started).
36+
- Run scripts locally by installing the latest version of the [Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/get-started).
3737

3838
## Assign a managed identity access to another application's app role
3939

@@ -59,20 +59,10 @@ In this article, you learn how to assign a managed identity to an application ro
5959
6060
1. Find the object ID of the service application's service principal. You can find this using the Azure portal. Go to Azure Active Directory and open the **Enterprise applications** page, then find the application and look for the **Object ID**. You can also find the service principal's object ID by its display name using the following PowerShell script:
6161
62-
# [Azure PowerShell](#tab/azurepowershell)
63-
64-
```powershell
65-
$serverServicePrincipalObjectId = (Get-AzureADServicePrincipal -Filter "DisplayName eq '$applicationName'").ObjectId
66-
```
67-
68-
# [Microsoft Graph](#tab/microsoftgraph)
69-
7062
```powershell
7163
$serverServicePrincipalObjectId = (Get-MgServicePrincipal -Filter "DisplayName eq '$applicationName'").Id
7264
```
7365
74-
---
75-
7666
> [!NOTE]
7767
> Display names for applications are not unique, so you should verify that you obtain the correct application's service principal.
7868
@@ -105,18 +95,6 @@ In this article, you learn how to assign a managed identity to an application ro
10595
10696
Execute the following PowerShell command to add the role assignment:
10797
108-
# [Azure PowerShell](#tab/azurepowershell)
109-
110-
```powershell
111-
New-AzureADServiceAppRoleAssignment `
112-
-ObjectId $serverServicePrincipalObjectId `
113-
-ResourceId $serverServicePrincipalObjectId `
114-
-Id $appRoleId `
115-
-PrincipalId $managedIdentityObjectId
116-
```
117-
118-
# [Microsoft Graph](#tab/microsoftgraph)
119-
12098
```powershell
12199
New-MgServicePrincipalAppRoleAssignment `
122100
-ServicePrincipalId $managedIdentityObjectId `
@@ -125,51 +103,10 @@ In this article, you learn how to assign a managed identity to an application ro
125103
-AppRoleId $appRoleId
126104
```
127105
128-
---
129-
130106
## Complete script
131107
132108
This example script shows how to assign an Azure web app's managed identity to an app role.
133109
134-
# [Azure PowerShell](#tab/azurepowershell)
135-
136-
```powershell
137-
# Install the module. This step requires you to be an administrator on your machine.
138-
# Install-Module AzureAD
139-
140-
# Your tenant ID (in the Azure portal, under Azure Active Directory > Overview).
141-
$tenantID = '<tenant-id>'
142-
143-
# The name of your web app, which has a managed identity that should be assigned to the server app's app role.
144-
$webAppName = '<web-app-name>'
145-
$resourceGroupName = '<resource-group-name-containing-web-app>'
146-
147-
# The name of the server app that exposes the app role.
148-
$serverApplicationName = '<server-application-name>' # For example, MyApi
149-
150-
# The name of the app role that the managed identity should be assigned to.
151-
$appRoleName = '<app-role-name>' # For example, MyApi.Read.All
152-
153-
# Look up the web app's managed identity's object ID.
154-
$managedIdentityObjectId = (Get-AzWebApp -ResourceGroupName $resourceGroupName -Name $webAppName).identity.principalid
155-
156-
Connect-AzureAD -TenantId $tenantID
157-
158-
# Look up the details about the server app's service principal and app role.
159-
$serverServicePrincipal = (Get-AzureADServicePrincipal -Filter "DisplayName eq '$serverApplicationName'")
160-
$serverServicePrincipalObjectId = $serverServicePrincipal.ObjectId
161-
$appRoleId = ($serverServicePrincipal.AppRoles | Where-Object {$_.Value -eq $appRoleName }).Id
162-
163-
# Assign the managed identity access to the app role.
164-
New-AzureADServiceAppRoleAssignment `
165-
-ObjectId $serverServicePrincipalObjectId `
166-
-ResourceId $serverServicePrincipalObjectId `
167-
-Id $appRoleId `
168-
-PrincipalId $managedIdentityObjectId
169-
```
170-
171-
# [Microsoft Graph](#tab/microsoftgraph)
172-
173110
```powershell
174111
# Install the module.
175112
# Install-Module Microsoft.Graph -Scope CurrentUser

0 commit comments

Comments
 (0)