bicep icon indicating copy to clipboard operation
bicep copied to clipboard

False positive for 'use-resource-id-functions' linter rule when param used in for loop

Open ChristopherGLewis opened this issue 1 year ago • 0 comments

Bicep version bicep --version Bicep CLI version 0.27.1 (4b41cb6d4b)

Describe the bug Similar false positive to https://github.com/Azure/bicep/issues/12419

param vmName string

@description('Array of DCR IDs')
param dcrIDs string[]

//Direct association to avoid scoping changes
resource dcr 'Microsoft.Insights/dataCollectionRuleAssociations@2023-03-11' = [for (id, index) in dcrIDs: {
   name: 'DCRassociation-${vmName}-${index}'
    scope: VM
     properties: {
       dataCollectionRuleId: id
        description: 'DCRassociation-${vmName}-${index}'
     }
}]
bicep build .\test.bicep                                                                  
C:\VSProjects\DevOps\AzureReadyFoundation\BicepModules\VirtualMachine\windowsvm.bicep(249,8) : Warning use-resource-id-functions: If property "dataCollectionRuleId" represents a resource ID, it must use a symbolic resource reference, be a parameter or start with one of these functions: extensionResourceId, guid, if, managementGroupResourceId, reference, resourceId, subscription, subscriptionResourceId, tenantResourceId. [https://aka.ms/bicep/linter/use-resource-id-functions]

To Reproduce Steps to reproduce the behavior:

code as above, bicep build

additional Notes

Removing the for loop and using a single dcrID string parameter eliminates the linting warning.

ChristopherGLewis avatar May 22 '24 04:05 ChristopherGLewis