Azure / Azure/bicep

Unclear where a resource is referencing itself

Open
#13,659 9 comments 0 reactions 0 assignees View on GitHub
bug story: symbolic names
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 4h
Merged PRs (30d)
81

Description

**Bicep version**

It's whatever version is used by azd, presumably fairly recent.

**Describe the bug**

I keep getting the error that a template resource is referencing itself. I've been trying for an hour to delete changes to see what it means, but I am very flummoxed. Is there any way to get a better hint as to where the reference is?

This is for an `azd provision` using a number of Bicep files, but I have only added one file and changed a few files, as you can see in this diff between my branch and a working branch:
https://github.com/jamesc/chatgpt-quickstart/compare/auth-enabled...pamelafox:chatgpt-quickstart:bicep?expand=1

Full error

```
ERROR: deployment failed: failing invoking action 'provision', error deploying infrastructure: starting deployment to subscription: PUT https://management.azure.com/subscriptions/b24b5122-ed51-497e-94f7-406bf93e7bfc/providers/Microsoft.Resources/deployments/authbicep-1710806274
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: InvalidTemplate
--------------------------------------------------------------------------------
{
"error": {
"code": "InvalidTemplate",
"message": "Deployment template validation failed: 'The template resource 'Microsoft.Resources/resourceGroups/authbicep-rg' cannot reference itself. Please see https://aka.ms/arm-function-reference for usage details.'.",
"additionalInfo": [
{
"type": "TemplateViolation",
"info": {
"lineNumber": 0,
"linePosition": 0,
"path": ""
}
}
]
}
}
--------------------------------------------------------------------------------
```
 
**To Reproduce**

You can check out that repo at my branch, run `azd env set USE_AUTHENTICATION true` and then `azd up`.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure from the linked repository by setting USE_AUTHENTICATION true and running azd up, then inspect the Bicep files and the full InvalidTemplate response. Trace how the self-reference in Microsoft.Resources/resourceGroups/authbicep-rg is reported; done means the diagnostic identifies where the reference occurs or otherwise provides a more actionable location.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.