Azure / Azure/bicep

@onlyIfNotExists() should support a definable clause

Open
#18,373 1 comment 2 reactions 0 assignees View on GitHub
enhancement OnlyifNotExists
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

Issue:
=====
@onlyIfNotExists() is good, but it appears to validate the resource existence only on the resource name (or Id). There are some cases where the uniqueness of the resource is not in its name/Id but in another property of the resource.

For instance, a private DNS zone supports only one vnet link to any given vnet. That uniqueness is not in the resource Name or Id, but rather in VirtualNetworkId property. @onlyIfNotExists() does not help when there is already a vnet link which was created using a name other than the one you are attempting to check before creating.

`
@onlyIfNotExists()
resource virtualNetworkLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
parent: privateDnsZone
name: vnetName
location: 'global'
properties: {
registrationEnabled: false
virtualNetwork: {
id: vnetId
}
}
}
`

Desired behavior:
============
@onlyIfNotExists() should support specifying a property of the resource to check for existence, or any other valid bicep operation which returns a true/false.
E.g. @onlyIfNotExists('VirtualNetworkId'=='')

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are identified in the issue. Start by locating the implementation and tests for @onlyIfNotExists(), then clarify with maintainers which resource properties or boolean operations are supported and how the predicate should behave before changing code.

Written by the indexing model from the issue text.

Assessment

Domain
cloud, compilers
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.