Azure / Azure/bicep

Use any() in scope

Open
#3,542 8 comments 6 reactions 0 assignees View on GitHub
enhancement
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe.**
When we have extension resources can we use the any() function to provide the scope.

**Describe the solution you'd like**

For example
```bicep
var resourceType = 'Microsoft.Compute/virtualMachines'
var resourceName = 'vm0001'
resource dcra 'Microsoft.Insights/dataCollectionRuleAssociations@2021-04-01' = {
name: 'dcra1'
scope: any('${resourceType}/${resourceName}')
properties: {
dataCollectionRuleId: ''
description: 'trest12'
}
}
```

This will make it easier to have flexible and dynamic code where people can have input such as resourceType (Microsoft.Compute/virtualMachines) and resourceName (vm0001). The idea is that once a new resource supports dataCollectionRuleAssociations resource extension I do not have to update the code to provide support for that resource. If I have to use the current method once new resource supports the extension I have to do two things:
* add that resource as existing with if statement so it does not apply when different resource type is chosen.
* add another if to scope. You can imagine if I have 20 resource that support that extension the if will be quite big in code.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Bicep example using any('${resourceType}/${resourceName}') as the scope of an extension resource. Review how extension-resource scopes are currently validated and represented; done should allow this dynamic scope without resource-type-specific declarations or conditional scope logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.