Skip to content

Commit 9c9ba34

Browse files
authored
Merge pull request #198490 from eoinshanley-microsoft/msiassocresources
Msiassocresources
2 parents f49be41 + 5c1f455 commit 9c9ba34

File tree

4 files changed

+185
-0
lines changed

4 files changed

+185
-0
lines changed

articles/active-directory/managed-identities-azure-resources/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115

116116
- name: Manage user-assigned managed identities
117117
href: how-manage-user-assigned-managed-identities.md
118+
- name: View associated resources for a managed identity
119+
href: how-to-view-associated-resources-for-an-identity.md
118120
- name: View managed identity service principals
119121
items:
120122
- name: Portal
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: View associated resources for a user-assigned managed identity
3+
description: Step-by-step instructions for viewing the Azure resources that are associated with a user-assigned managed identity
4+
services: active-directory
5+
documentationcenter: ''
6+
author: barclayn
7+
manager: daveba
8+
editor: ''
9+
10+
ms.service: active-directory
11+
ms.subservice: msi
12+
ms.devlang: na
13+
ms.topic: how-to
14+
ms.tgt_pltfrm: na
15+
ms.workload: identity
16+
ms.date: 06/20/2022
17+
ms.author: barclayn
18+
ms.collection: M365-identity-device-management
19+
---
20+
21+
# View associated Azure resources for a user-assigned managed identity (Preview)
22+
23+
This article will explain how to view the Azure resources that are associated with a user-assigned managed identity. This feature is available in public preview.
24+
25+
## Prerequisites
26+
27+
- If you're unfamiliar with managed identities for Azure resources, check out the [overview section](overview.md).
28+
- If you don't already have an Azure account, [sign up for a free account](https://azure.microsoft.com/free/).
29+
30+
31+
## View resources for a user-assigned managed identity
32+
33+
Being able to quickly see which Azure resources are associated with a user-assigned managed identity gives you greater visibility into your environment. You can quickly identify unused identities that can be safely deleted, and know which resources will be affected by changing the permissions or group membership of a managed identity.
34+
35+
### Portal
36+
37+
- From the **Azure portal** search for **Managed Identities**.
38+
- Select a managed identity
39+
- In the left-hand menu, select the **Associated resources** link
40+
- A list of the Azure resources associated with the managed identity will be displayed
41+
42+
:::image type="content" source="media/viewing-associated-resources/associated-resources-list-cropped.png" alt-text="Screenshot showing a list of associated resources for a user-assigned managed identity.":::
43+
44+
Select the resource name to be brought to its summary page.
45+
46+
#### Filtering and sorting by resource type
47+
Filter the resources by typing in the filter box at the top of the summary page. You can filter by the name, type, resource group, and subscription ID.
48+
49+
Select the column title to sort alphabetically, ascending or descending.
50+
51+
### REST API
52+
53+
The list of associated resources can also be accessed using the REST API. This endpoint is separate to the API endpoint used to retrieve a list of user-assigned managed identities. You'll need the following information:
54+
- Subscription ID
55+
- Resource name of the user-assigned managed identity that you want to view the resources for
56+
- Resource group of the user-assigned managed identity
57+
58+
*Request format*
59+
```
60+
https://management.azure.com/subscriptions/{resourceID of user-assigned identity}/listAssociatedResources?$filter={filter}&$orderby={orderby}&$skip={skip}&$top={top}&$skiptoken={skiptoken}&api-version=2021-09-30-preview
61+
```
62+
63+
*Parameters*
64+
65+
| Parameter | Example |Description |
66+
|---|---|---|
67+
| $filter | ```'type' eq 'microsoft.cognitiveservices/account' and contains(name, 'test')``` | An OData expression that allows you to filter any of the available fields: name, type, resourceGroup, subscriptionId, subscriptionDisplayName, subscriptionId, subscriptionDisplayName<br/><br/>The following operations are supported: ```and```, ```or```, ```eq``` and ```contains``` |
68+
| $orderby | ```name asc``` | An OData expression that allows you to order by any of the available fields |
69+
| $skip | 50 | The number of items you want to skip while paging through the results. |
70+
| $top | 10 | The number of resources to return. 0 will return only a count of the resources. |
71+
72+
Below is a sample request to the REST API:
73+
```http
74+
POST https://management.azure.com/subscriptions/aab111d1-1111-43e2-8d11-3bfc47ab8111/resourceGroups/devrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/devIdentity/listAssociatedResources?$filter={filter}&$orderby={orderby}&$skip={skip}&$top={top}&skipToken={skipToken}&api-version=2021-09-30-preview
75+
```
76+
77+
Below is a sample response from the REST API:
78+
```json
79+
{
80+
"totalCount": 2,
81+
"value": [{
82+
"id": "/subscriptions/{subId}/resourceGroups/testrg/providers/Microsoft.CognitiveServices/accounts/test1",
83+
"name": "test1",
84+
"type": "microsoft.cognitiveservices/accounts",
85+
"resourceGroup": "testrg",
86+
"subscriptionId": "{subId}",
87+
"subscriptionDisplayName": "TestSubscription"
88+
},
89+
{
90+
"id": "/subscriptions/{subId}/resourceGroups/testrg/providers/Microsoft.CognitiveServices/accounts/test2",
91+
"name": "test2",
92+
"type": "microsoft.cognitiveservices/accounts",
93+
"resourceGroup": "testrg",
94+
"subscriptionId": "{subId}",
95+
"subscriptionDisplayName": "TestSubscription"
96+
}
97+
],
98+
"nextLink": "https://management.azure.com/subscriptions/{subId}/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testid?skiptoken=ew0KICAiJGlkIjogIjEiLA0KICAiTWF4Um93cyI6IDIsDQogICJSb3dzVG9Ta2lwIjogMiwNCiAgIkt1c3RvQ2x1c3RlclVybCI6ICJodHRwczovL2FybXRvcG9sb2d5Lmt1c3RvLndpbmRvd3MubmV0Ig0KfQ%253d%253d&api-version=2021"
99+
}
100+
101+
```
102+
103+
### Command Line Interface
104+
To view the associated resources for a user-assigned managed identity, run the following command:
105+
```azurecli
106+
az identity list-resources --resource-group <ResourceGroupName> --name <ManagedIdentityName>
107+
```
108+
109+
The response will look like this:
110+
```json
111+
[
112+
{
113+
"id": "/subscriptions/XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130/resourceGroups/ProductionServices/providers/Microsoft.Compute/virtualMachines/linux-prod-1-US",
114+
"name": "linux-prod-1-US",
115+
"resourceGroup": "productionservices",
116+
"subscriptionDisplayName": "Visual Studio Enterprise Subscription",
117+
"subscriptionId": "XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130",
118+
"type": "microsoft.compute/virtualmachines"
119+
},
120+
{
121+
"id": "/subscriptions/XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130/resourceGroups/ProductionServices/providers/Microsoft.Web/sites/prodStatusCheck-US",
122+
"name": "prodStatusCheck-US",
123+
"resourceGroup": "productionservices",
124+
"subscriptionDisplayName": "Visual Studio Enterprise Subscription",
125+
"subscriptionId": "XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130",
126+
"type": "microsoft.web/sites"
127+
},
128+
{
129+
"id": "/subscriptions/XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130/resourceGroups/ProductionServices/providers/Microsoft.Web/sites/salesApp-US-1",
130+
"name": "salesApp-US-1",
131+
"resourceGroup": "productionservices",
132+
"subscriptionDisplayName": "Visual Studio Enterprise Subscription",
133+
"subscriptionId": "XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130",
134+
"type": "microsoft.web/sites"
135+
},
136+
{
137+
"id": "/subscriptions/XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130/resourceGroups/ProductionServices/providers/Microsoft.Web/sites/salesPortal-us-2",
138+
"name": "salesPortal-us-2",
139+
"resourceGroup": "productionservices",
140+
"subscriptionDisplayName": "Visual Studio Enterprise Subscription",
141+
"subscriptionId": "XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130",
142+
"type": "microsoft.web/sites"
143+
},
144+
{
145+
"id": "/subscriptions/XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130/resourceGroups/vmss/providers/Microsoft.Compute/virtualMachineScaleSets/vmsstest",
146+
"name": "vmsstest",
147+
"resourceGroup": "vmss",
148+
"subscriptionDisplayName": "Visual Studio Enterprise Subscription",
149+
"subscriptionId": "XXXX-XXXX-XXXX-XXXX-XXXfc47ab8130",
150+
"type": "microsoft.compute/virtualmachinescalesets"
151+
}
152+
]
153+
```
154+
155+
### REST API using PowerShell
156+
There's no specific PowerShell command for returning the associated resources of a managed identity, but you can use the REST API in PowerShell by using the following command:
157+
158+
```PowerShell
159+
Invoke-AzRestMethod -Path "/subscriptions/XXX-XXX-XXX-XXX/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity-name/listAssociatedResources?api-version=2021-09-30-PREVIEW&%24orderby=name%20asc&%24skip=0&%24top=100" -Method Post
160+
```
161+
162+
>[!NOTE]
163+
> All resources associated with an identity will be returned, regardless of the user's permissions. The user only needs to have access to read the managed identity. This means that more resources may be visible than the user can see elsewhere in the portal. This is to provide full visibility of the identity's usage. If the user doesn't have access to an associated resource, an error will be displayed if they try to access it from the list.
164+
165+
## Delete a user-assigned managed identity
166+
When you select the delete button for a user-assigned managed identity, you'll see a list of up to 10 associated resources for that identity. The full count will be displayed at the top of the pane. This list allows you to see which resources will be affected by deleting the identity. You'll be asked to confirm your decision.
167+
168+
:::image type="content" source="media/viewing-associated-resources/associated-resources-delete.png" alt-text="Screenshot showing the delete confirmation screen for a user-assigned managed identity.":::
169+
170+
This confirmation process is only available in the portal. To view an identity's resources before deleting it using the REST API, retrieve the list of resources manually in advance.
171+
172+
## Limitations
173+
- This functionality is available in all public regions, and will be available in USGov and China in the coming weeks.
174+
- API requests for associated resources are limited to one per second per tenant. If you exceed this limit, you may receive a `HTTP 429` error. This limit doesn't apply to retrieving a list of user-assigned managed identities.
175+
- Azure Resources types that are in preview, or their support for Managed identities is in preview, may not appear in the associated resources list until fully generally available. This list includes Service Fabric clusters, Blueprints, and Machine learning services.
176+
- This functionality is limited to tenants with fewer than 5,000 subscriptions. An error will be displayed if the tenant has greater than 5,000 subscriptions.
177+
- The list of associated resources will display the resource type, not display name.
178+
- Azure Policy assignments appear in the list, but their names aren't displayed correctly.
179+
- This functionality isn't yet available through PowerShell.
180+
181+
## Next steps
182+
183+
* [Managed identities for Azure resources](./overview.md)
Loading
Loading

0 commit comments

Comments
 (0)