@@ -5,7 +5,7 @@ author: mumian
5
5
ms.author : jgao
6
6
ms.topic : conceptual
7
7
ms.custom : devx-track-bicep
8
- ms.date : 09/09/2022
8
+ ms.date : 06/20/2023
9
9
---
10
10
11
11
# Resource functions for Bicep
@@ -68,7 +68,7 @@ param allowedLocations array = [
68
68
'australiacentral'
69
69
]
70
70
71
- resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2019-09 -01' = {
71
+ resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2021-06 -01' = {
72
72
name: 'locationRestriction'
73
73
properties: {
74
74
policyType: 'Custom'
@@ -88,7 +88,7 @@ resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2019-09-01'
88
88
}
89
89
}
90
90
91
- resource policyAssignment 'Microsoft.Authorization/policyAssignments@2019-09 -01' = {
91
+ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2022-06 -01' = {
92
92
name: 'locationAssignment'
93
93
properties: {
94
94
policyDefinitionId: policyDefinition.id
@@ -146,7 +146,7 @@ param adminLogin string
146
146
@secure()
147
147
param adminPassword string
148
148
149
- resource sqlServer 'Microsoft.Sql/servers@2020-11 -01-preview' = {
149
+ resource sqlServer 'Microsoft.Sql/servers@2022-08 -01-preview' = {
150
150
...
151
151
}
152
152
```
@@ -161,7 +161,7 @@ param subscriptionId string
161
161
param kvResourceGroup string
162
162
param kvName string
163
163
164
- resource keyVault 'Microsoft.KeyVault/vaults@2019-09 -01' existing = {
164
+ resource keyVault 'Microsoft.KeyVault/vaults@2023-02 -01' existing = {
165
165
name: kvName
166
166
scope: resourceGroup(subscriptionId, kvResourceGroup )
167
167
}
@@ -234,7 +234,7 @@ Other `list` functions have different return formats. To see the format of a fun
234
234
The following example deploys a storage account and then calls ` listKeys ` on that storage account. The key is used when setting a value for [ deployment scripts] ( ../templates/deployment-script-template.md ) .
235
235
236
236
``` bicep
237
- resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06 -01' = {
237
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' = {
238
238
name: 'dscript${uniqueString(resourceGroup().id)}'
239
239
location: location
240
240
kind: 'StorageV2'
@@ -243,7 +243,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
243
243
}
244
244
}
245
245
246
- resource dScript 'Microsoft.Resources/deploymentScripts@2019 -10-01-preview ' = {
246
+ resource dScript 'Microsoft.Resources/deploymentScripts@2020 -10-01' = {
247
247
name: 'scriptWithStorage'
248
248
location: location
249
249
...
@@ -325,9 +325,9 @@ The possible uses of `list*` are shown in the following table.
325
325
| Microsoft.DevTestLab/labs/schedules | [ ListApplicable] ( /rest/api/dtl/schedules/listapplicable ) |
326
326
| Microsoft.DevTestLab/labs/users/serviceFabrics | [ ListApplicableSchedules] ( /rest/api/dtl/servicefabrics/listapplicableschedules ) |
327
327
| Microsoft.DevTestLab/labs/virtualMachines | [ ListApplicableSchedules] ( /rest/api/dtl/virtualmachines/listapplicableschedules ) |
328
- | Microsoft.DocumentDB/databaseAccounts | [ listConnectionStrings] ( /rest/api/cosmos-db-resource-provider/2022-05 -15/database-accounts/list-connection-strings ) |
329
- | Microsoft.DocumentDB/databaseAccounts | [ listKeys] ( /rest/api/cosmos-db-resource-provider/2022-05 -15/database-accounts/list-keys ) |
330
- | Microsoft.DocumentDB/databaseAccounts/notebookWorkspaces | [ listConnectionInfo] ( /rest/api/cosmos-db-resource-provider/2022-05 -15/notebook-workspaces/list-connection-info ) |
328
+ | Microsoft.DocumentDB/databaseAccounts | [ listConnectionStrings] ( /rest/api/cosmos-db-resource-provider/2022-11 -15/database-accounts/list-connection-strings ) |
329
+ | Microsoft.DocumentDB/databaseAccounts | [ listKeys] ( /rest/api/cosmos-db-resource-provider/2022-11 -15/database-accounts/list-keys ) |
330
+ | Microsoft.DocumentDB/databaseAccounts/notebookWorkspaces | [ listConnectionInfo] ( /rest/api/cosmos-db-resource-provider/2022-11 -15/notebook-workspaces/list-connection-info ) |
331
331
| Microsoft.DomainRegistration | [ listDomainRecommendations] ( /rest/api/appservice/domains/listrecommendations ) |
332
332
| Microsoft.DomainRegistration/topLevelDomains | [ listAgreements] ( /rest/api/appservice/topleveldomains/listagreements ) |
333
333
| Microsoft.EventGrid/domains | [ listKeys] ( /rest/api/eventgrid/controlplane-version2022-06-15/domains/list-shared-access-keys ) |
@@ -354,9 +354,9 @@ The possible uses of `list*` are shown in the following table.
354
354
| Microsoft.Logic/workflows/versions/triggers | [ listCallbackUrl] ( /rest/api/logic/workflowversions/listcallbackurl ) |
355
355
| Microsoft.MachineLearning/webServices | [ listkeys] ( /rest/api/machinelearning/webservices/listkeys ) |
356
356
| Microsoft.MachineLearning/Workspaces | listworkspacekeys |
357
- | Microsoft.MachineLearningServices/workspaces/computes | [ listKeys] ( /rest/api/azureml/2022-10 -01/compute/list-keys ) |
358
- | Microsoft.MachineLearningServices/workspaces/computes | [ listNodes] ( /rest/api/azureml/2022-10 -01/compute/list-nodes ) |
359
- | Microsoft.MachineLearningServices/workspaces | [ listKeys] ( /rest/api/azureml/2022-10 -01/workspaces/list-keys ) |
357
+ | Microsoft.MachineLearningServices/workspaces/computes | [ listKeys] ( /rest/api/azureml/2023-04 -01/compute/list-keys ) |
358
+ | Microsoft.MachineLearningServices/workspaces/computes | [ listNodes] ( /rest/api/azureml/2023-04 -01/compute/list-nodes ) |
359
+ | Microsoft.MachineLearningServices/workspaces | [ listKeys] ( /rest/api/azureml/2023-04 -01/workspaces/list-keys ) |
360
360
| Microsoft.Maps/accounts | [ listKeys] ( /rest/api/maps-management/accounts/listkeys ) |
361
361
| Microsoft.Media/mediaservices/assets | [ listContainerSas] ( /rest/api/media/assets/listcontainersas ) |
362
362
| Microsoft.Media/mediaservices/assets | [ listStreamingLocators] ( /rest/api/media/assets/liststreaminglocators ) |
@@ -507,31 +507,33 @@ Returns an object representing a resource's runtime state.
507
507
508
508
Namespace: [ az] ( bicep-functions.md#namespaces-for-functions ) .
509
509
510
- The reference function is available in Bicep files, but typically you don't need it . Instead, use the symbolic name for the resource.
510
+ 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 .
511
511
512
- The following example deploys a storage account. It uses the symbolic name ` storageAccount ` for the storage account to return a property .
512
+ The following example deploys a storage account. The two outputs show the usage of both the reference function and the symbolic name .
513
513
514
514
``` bicep
515
- param storageAccountName string
515
+ param storageAccountName string = uniqueString(resourceGroup().id)
516
+ param location string = resourceGroup().location
516
517
517
- resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06 -01' = {
518
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' = {
518
519
name: storageAccountName
519
- location: 'eastus'
520
+ location: location
520
521
kind: 'Storage'
521
522
sku: {
522
523
name: 'Standard_LRS'
523
524
}
524
525
}
525
526
526
- output storageEndpoint object = storageAccount.properties.primaryEndpoints
527
+ output storageEndpointReference object = reference(storageAccountName).primaryEndpoints
528
+ output storageEndpointSymbolic object = storageAccount.properties.primaryEndpoints
527
529
```
528
530
529
531
To get a property from an existing resource that isn't deployed in the template, use the ` existing ` keyword:
530
532
531
533
``` bicep
532
534
param storageAccountName string
533
535
534
- resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06 -01' existing = {
536
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' existing = {
535
537
name: storageAccountName
536
538
}
537
539
@@ -563,10 +565,11 @@ For example:
563
565
564
566
``` bicep
565
567
param storageAccountName string
568
+ param location string = resourceGroup().location
566
569
567
- resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06 -01' = {
570
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' = {
568
571
name: storageAccountName
569
- location: 'eastus'
572
+ location: location
570
573
kind: 'Storage'
571
574
sku: {
572
575
name: 'Standard_LRS'
@@ -581,7 +584,7 @@ To get the resource ID for a resource that isn't deployed in the Bicep file, use
581
584
``` bicep
582
585
param storageAccountName string
583
586
584
- resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06 -01' existing = {
587
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09 -01' existing = {
585
588
name: storageAccountName
586
589
}
587
590
@@ -638,7 +641,7 @@ var roleDefinitionId = {
638
641
}
639
642
}
640
643
641
- resource roleAssignment 'Microsoft.Authorization/roleAssignments@2018-09 -01-preview ' = {
644
+ resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04 -01' = {
642
645
name: guid(resourceGroup().id, principalId, roleDefinitionId[builtInRoleType].id)
643
646
properties: {
644
647
roleDefinitionId: roleDefinitionId[builtInRoleType].id
@@ -687,7 +690,7 @@ param allowedLocations array = [
687
690
var mgScope = tenantResourceId('Microsoft.Management/managementGroups', targetMG)
688
691
var policyDefinitionName = 'LocationRestriction'
689
692
690
- resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2020-03 -01' = {
693
+ resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2021-06 -01' = {
691
694
name: policyDefinitionName
692
695
properties: {
693
696
policyType: 'Custom'
@@ -707,7 +710,7 @@ resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2020-03-01'
707
710
}
708
711
}
709
712
710
- resource location_lock 'Microsoft.Authorization/policyAssignments@2020-03 -01' = {
713
+ resource location_lock 'Microsoft.Authorization/policyAssignments@2021-06 -01' = {
711
714
name: 'location-lock'
712
715
properties: {
713
716
scope: mgScope
@@ -744,7 +747,7 @@ param policyDefinitionID string = '0a914e76-4921-4c19-b460-a2d36003525a'
744
747
@description('Specifies the name of the policy assignment, can be used defined or an idempotent name as the defaultValue provides.')
745
748
param policyAssignmentName string = guid(policyDefinitionID, resourceGroup().name)
746
749
747
- resource policyAssignment 'Microsoft.Authorization/policyAssignments@2019-09 -01' = {
750
+ resource policyAssignment 'Microsoft.Authorization/policyAssignments@2022-06 -01' = {
748
751
name: policyAssignmentName
749
752
properties: {
750
753
scope: subscriptionResourceId('Microsoft.Resources/resourceGroups', resourceGroup().name)
0 commit comments