Skip to content

Commit f2740b9

Browse files
Merge pull request #242612 from mumian/0622-reference-function
fix an error in the sample code
2 parents 7c50301 + 67c39f5 commit f2740b9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

articles/azure-resource-manager/bicep/bicep-functions-resource.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: mumian
55
ms.author: jgao
66
ms.topic: conceptual
77
ms.custom: devx-track-bicep
8-
ms.date: 06/20/2023
8+
ms.date: 06/22/2023
99
---
1010

1111
# Resource functions for Bicep
@@ -509,7 +509,7 @@ Namespace: [az](bicep-functions.md#namespaces-for-functions).
509509

510510
The Bicep files provide access to the reference function, although it is typically unnecessary. Instead, it is recommended to use the symbolic name of the resource. The reference function can only be used within the `properties` object of a resource and cannot be employed for top-level properties like `name` or `location`. The same generally applies to references using the symbolic name. However, for properties such as `name`, it is possible to generate a template without utilizing the reference function. Sufficient information about the resource name is known to directly emit the name. It is referred to as compile-time properties. Bicep validation can identify any incorrect usage of the symbolic name.
511511

512-
The following example deploys a storage account. The two outputs show the usage of both the reference function and the symbolic name.
512+
The following example deploys a storage account. The first two outputs give you the same results.
513513

514514
```bicep
515515
param storageAccountName string = uniqueString(resourceGroup().id)
@@ -524,8 +524,10 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
524524
}
525525
}
526526
527-
output storageEndpointReference object = reference(storageAccountName).primaryEndpoints
528-
output storageEndpointSymbolic object = storageAccount.properties.primaryEndpoints
527+
output storageObjectSymbolic object = storageAccount.properties
528+
output storageObjectReference object = reference('storageAccount')
529+
output storageName string = storageAccount.name
530+
output storageLocation string = storageAccount.location
529531
```
530532

531533
To get a property from an existing resource that isn't deployed in the template, use the `existing` keyword:

0 commit comments

Comments
 (0)