You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`references(symbolic name of a resource collection, ['Full', 'Properties])`
611
+
612
+
The `references` function works similarly as [`reference`](#reference). Instead of returning an object presenting a resource's runtime state, the `references` function returns an array of objects representing a collection of resource's runtime states. This function requires ARM template language version `1.10-experimental` and with [symbolic name](../bicep/file.md#resources) enabled:
In Bicep, there is no explicit `references` function. Instead, symbolic collection usage is employed directly, and during code generation, Bicep translates it to an ARM template that utilizes the ARM template `references` function. The forthcoming release of Bicep will include the translation feature that converts symbolic collections to ARM templates using the `references` function.
624
+
625
+
### Parameters
626
+
627
+
| Parameter | Required | Type | Description |
628
+
|:--- |:--- |:--- |:--- |
629
+
| Symbolic name of a resource collection |Yes |string |Symbolic name of a resource collection that is defined in the current template. The `references` function does not support referencing resources external to the current template. |
630
+
| 'Full', 'Properties' |No |string |Value that specifies whether to return an array of the full resource objects. The default value is `'Properties'`. If you don't specify `'Full'`, only the properties objects of the resources are returned. The full object includes values such as the resource ID and location. |
631
+
632
+
### Return value
633
+
634
+
An array of the resource collection. Every resource type returns different properties for the `reference` function. Also, the returned value differs based on the value of the `'Full'` argument. For more information, see [reference](#reference).
635
+
636
+
The output order of `references` is always arranged in ascending order based on the copy index. Therefore, the first resource in the collection with index 0 is displayed first, followed by index 1, and so on. For instance, *[worker-0, worker-1, worker-2, ...]*.
637
+
638
+
In the preceding example, if *worker-0* and *worker-2* are deployed while *worker-1* is not due to a false condition, the output of `references` will omit the non-deployed resource and display the deployed ones, ordered by their numbers. The output of `references` will be *[worker-0, worker-2, ...]*. If all of the resources are omitted, the function returns an empty array.
639
+
640
+
### Valid uses
641
+
642
+
The `references` function can't be used within [resource copy loops](./copy-resources.md) or [Bicep for loop](../bicep/loops.md). For example, `references` is not allowed in the following scenario:
643
+
644
+
```json
645
+
{
646
+
resources: {
647
+
"resourceCollection": {
648
+
"copy": { ... },
649
+
"properties": {
650
+
"prop": "[references(...)]"
651
+
}
652
+
}
653
+
}
654
+
}
655
+
```
656
+
657
+
To use the `references` function or any `list*` function in the outputs section of a nested template, you must set the `expressionEvaluationOptions` to use [inner scope](linked-templates.md#expression-evaluation-scope-in-nested-templates) evaluation or use a linked instead of a nested template.
658
+
659
+
### Implicit dependency
660
+
661
+
By using the `references` function, you implicitly declare that one resource depends on another resource. You don't need to also use the `dependsOn` property. The function isn't evaluated until the referenced resource has completed deployment.
662
+
663
+
### Reference example
664
+
665
+
The following example deploys a resource collection, and references that resource collection.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/templates/template-functions.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Template functions
3
3
description: Describes the functions to use in an Azure Resource Manager template (ARM template) to retrieve values, work with strings and numerics, and retrieve deployment information.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-arm-template
6
-
ms.date: 05/12/2023
6
+
ms.date: 08/03/2023
7
7
---
8
8
9
9
# ARM template functions
@@ -202,6 +202,7 @@ Resource Manager provides the following functions for getting resource values:
0 commit comments