Linter rule - use parent property
When defined outside of the parent resource, you use slashes to include the parent name in the name of the child resource. Defining the full resource name with the parent resource name isn't recommended. The parent
property can be used to simplify the syntax. See Full resource name outside parent.
Linter rule code
Use the following value in the Bicep configuration file to customize rule settings:
use-parent-property
Solution
The following example fails this test because of the name values for service
and share
:
param location string = resourceGroup().location
resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: 'examplestorage'
location: location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}
resource service 'Microsoft.Storage/storageAccounts/fileServices@2023-05-01' = {
name: 'examplestorage/default'
dependsOn: [
storage
]
}
resource share 'Microsoft.Storage/storageAccounts/fileServices/shares@2023-05-01' = {
name: 'examplestorage/default/exampleshare'
dependsOn: [
service
]
}
You can fix the problem by using the parent
property:
param location string = resourceGroup().location
resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: 'examplestorage'
location: location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}
resource service 'Microsoft.Storage/storageAccounts/fileServices@2023-05-01' = {
parent: storage
name: 'default'
}
resource share 'Microsoft.Storage/storageAccounts/fileServices/shares@2023-05-01' = {
parent: service
name: 'exampleshare'
}
Use Quick Fix to simplify the syntax:
Next steps
For more information about the linter, see Use Bicep linter.