Azure / Azure/bicep

Deployment should fail for `existing` resources that do not exist, even when the `reference()` call is not required for transpile

Open
#10,097 22 comments 0 reactions 1 assignee Claimed by @alex-frankel View on GitHub
intermediate language Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
v0.14.85

**Describe the bug**
The documentation says:
_If you attempt to reference a resource that doesn't exist, you get the NotFound error and your deployment fails. Check the name and scope of the resource you're trying to reference._ [Link](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/existing-resource#troubleshooting)

This is not true. The deployment will not fail if only referring to the name or id of the referenced existing resource. In this case, Bicep does not "resolve" the resource from Azure Resource Manager because Bicep can construct the resource id and get the name from the resource existing block without having to fetch the properties from Azure.

**To Reproduce**
Steps to reproduce the behavior:

**Additional context**
The resource existing block should allow enforcing validation or documentation should be updated to explain better the behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.