Skip to content

Commit 7fa4cd9

Browse files
authored
Merge pull request #101801 from tfitzmac/012020ref
add reference for managed identity
2 parents 255756d + 0af1c12 commit 7fa4cd9

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

articles/azure-resource-manager/templates/error-not-found.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Resource not found errors
3-
description: Describes how to resolve errors when a resource cannot be found when deploying with an Azure Resource Manager template.
3+
description: Describes how to resolve errors when a resource can't be found when deploying with an Azure Resource Manager template.
44
ms.topic: troubleshooting
5-
ms.date: 06/06/2018
5+
ms.date: 01/21/2020
66
---
77
# Resolve not found errors for Azure resources
88

@@ -81,4 +81,16 @@ Look for an expression that includes the [reference](template-functions-resource
8181

8282
```json
8383
"[reference(resourceId('exampleResourceGroup', 'Microsoft.Storage/storageAccounts', 'myStorage'), '2017-06-01')]"
84+
```
85+
86+
## Solution 4 - get managed identity from resource
87+
88+
If you're deploying a resource that implicitly creates a [managed identity](../../active-directory/managed-identities-azure-resources/overview.md), you must wait until that resource is deployed before retrieving values on the managed identity. If you pass the managed identity name to the [reference](template-functions-resource.md#reference) function, Resource Manager attempts to resolve the reference before the resource and identity are deployed. Instead, pass the name of the resource that the identity is applied to. This approach ensures the resource and the managed identity are deployed before Resource Manager resolves the reference function.
89+
90+
In the reference function, use `Full` to get all of the properties including the managed identity.
91+
92+
For example, to get the tenant ID for a managed identity that is applied to a virtual machine scale set, use:
93+
94+
```json
95+
"tenantId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('vmNodeType0Name')), variables('vmssApiVersion'), 'Full').Identity.tenantId]"
8496
```

articles/azure-resource-manager/templates/template-functions-resource.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Template functions - resources
33
description: Describes the functions to use in an Azure Resource Manager template to retrieve values about resources.
44
ms.topic: conceptual
5-
ms.date: 01/06/2020
5+
ms.date: 01/20/2020
66
---
77
# Resource functions for Azure Resource Manager templates
88

@@ -529,6 +529,16 @@ For example:
529529
`Microsoft.Compute/virtualMachines/myVM/extensions/myExt` is correct
530530
`Microsoft.Compute/virtualMachines/extensions/myVM/myExt` is not correct
531531

532+
### Get managed identity
533+
534+
[Managed identities for Azure resources](../../active-directory/managed-identities-azure-resources/overview.md) are [extension resource types](extension-resource-types.md) that are created implicitly for some resources. Because the managed identity isn't explicitly defined in the template, you must reference the resource that the identity is applied to. Use `Full` to get all of the properties, including the implicitly created identity.
535+
536+
For example, to get the tenant ID for a managed identity that is applied to a virtual machine scale set, use:
537+
538+
```json
539+
"tenantId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('vmNodeType0Name')), variables('vmssApiVersion'), 'Full').Identity.tenantId]"
540+
```
541+
532542
### Reference example
533543

534544
The following [example template](https://github.com/Azure/azure-docs-json-samples/blob/master/azure-resource-manager/functions/referencewithstorage.json) deploys a resource, and references that resource.

0 commit comments

Comments
 (0)