Skip to content

Commit 05c8372

Browse files
authored
Merge pull request #46884 from bmoore-msft/patch-8
Update template-functions-resource.md
2 parents 5449d6f + 5b4b94b commit 05c8372

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ Returns an object representing a resource's runtime state.
437437

438438
| Parameter | Required | Type | Description |
439439
|:--- |:--- |:--- |:--- |
440-
| resourceName or resourceIdentifier |Yes |string |Name or unique identifier of a resource. When referencing a resource in the current template, provide only the resource name as a parameter. When referencing a previously deployed resource, provide the resource ID. |
440+
| resourceName or resourceIdentifier |Yes |string |Name or unique identifier of a resource. When referencing a resource in the current template, provide only the resource name as a parameter. When referencing a previously deployed resource or when the name of the resource is ambiguous, provide the resource ID. |
441441
| apiVersion |No |string |API version of the specified resource. Include this parameter when the resource isn't provisioned within same template. Typically, in the format, **yyyy-mm-dd**. For valid API versions for your resource, see [template reference](/azure/templates/). |
442442
| 'Full' |No |string |Value that specifies whether to return the full resource object. If you don't specify `'Full'`, only the properties object of the resource is returned. The full object includes values such as the resource ID and location. |
443443

@@ -454,11 +454,11 @@ Typically, you use the **reference** function to return a particular value from
454454
```json
455455
"outputs": {
456456
"BlobUri": {
457-
"value": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '2016-01-01').primaryEndpoints.blob]",
457+
"value": "[reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')).primaryEndpoints.blob]",
458458
"type" : "string"
459459
},
460460
"FQDN": {
461-
"value": "[reference(concat('Microsoft.Network/publicIPAddresses/', parameters('ipAddressName')), '2016-03-30').dnsSettings.fqdn]",
461+
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('ipAddressName')).dnsSettings.fqdn]",
462462
"type" : "string"
463463
}
464464
}
@@ -470,11 +470,11 @@ Use `'Full'` when you need resource values that aren't part of the properties sc
470470
{
471471
"type": "Microsoft.KeyVault/vaults",
472472
"properties": {
473-
"tenantId": "[reference(concat('Microsoft.Compute/virtualMachines/', variables('vmName')), '2017-03-30', 'Full').identity.tenantId]",
473+
"tenantId": "[subscription().tenantId]",
474474
"accessPolicies": [
475475
{
476-
"tenantId": "[reference(concat('Microsoft.Compute/virtualMachines/', variables('vmName')), '2017-03-30', 'Full').identity.tenantId]",
477-
"objectId": "[reference(concat('Microsoft.Compute/virtualMachines/', variables('vmName')), '2017-03-30', 'Full').identity.principalId]",
476+
"tenantId": "[reference(reosurceId('Microsoft.Compute/virtualMachines', variables('vmName')), '2019-03-01', 'Full').identity.tenantId]",
477+
"objectId": "[reference(resourceId('Microsoft.Compute/virtualMachines', variables('vmName')), '2019-03-01', 'Full').identity.principalId]",
478478
"permissions": {
479479
"keys": [
480480
"all"
@@ -514,10 +514,10 @@ When referencing a resource that isn't deployed in the same template, provide th
514514
"value": "[reference(resourceId(parameters('storageResourceGroup'), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2018-07-01')]"
515515
```
516516

517-
To avoid ambiguity about which resource you're referencing, you can provide a fully qualified resource name.
517+
To avoid ambiguity about which resource you're referencing, you can provide a fully qualified resource identifier.
518518

519519
```json
520-
"value": "[reference(concat('Microsoft.Network/publicIPAddresses/', parameters('ipAddressName')))]"
520+
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('ipAddressName'))]"
521521
```
522522

523523
When constructing a fully qualified reference to a resource, the order to combine segments from the type and name isn't simply a concatenation of the two. Instead, after the namespace, use a sequence of *type/name* pairs from least specific to most specific:
@@ -529,14 +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+
To simplify the creation of any resource ID, use the `resourceId()` functions described in this document instead of the `concat()` function.
533+
532534
### Get managed identity
533535

534536
[Managed identities for Azure resources](../../active-directory/managed-identities-azure-resources/overview.md) are [extension resource types](../management/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.
535537

536538
For example, to get the tenant ID for a managed identity that is applied to a virtual machine scale set, use:
537539

538540
```json
539-
"tenantId": "[reference(concat('Microsoft.Compute/virtualMachineScaleSets/', variables('vmNodeType0Name')), variables('vmssApiVersion'), 'Full').Identity.tenantId]"
541+
"tenantId": "[reference(resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('vmNodeType0Name')), '2019-03-01', 'Full').Identity.tenantId]"
540542
```
541543

542544
### Reference example

0 commit comments

Comments
 (0)