Azure / Azure/bicep

Undeployable ARM Template generated

Open
#4,815 7 comments 0 reactions 0 assignees View on GitHub
bug provider bug top 10 committed
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
Bicep CLI version 0.4.613 (d826ce8411)

**Describe the bug**
The below template compiles successfully, but fails at deployment time with the error "The template function 'reference' is not expected at this location".

This feels like either a code generation issue, or something that should be caught by the type system and produce a compilation error.

**To Reproduce**
```bicep
param webAppName string

resource webApp 'Microsoft.Web/sites@2021-01-01' existing = {
name: webAppName

resource scmCreds 'basicPublishingCredentialsPolicies' = {
name: 'scm'
location: webApp.location
properties: {
allow: false
}
}
}
```

Error
```json
{
"error": {
"code": "InvalidTemplate",
"message": "Deployment template validation failed: 'The template resource 'REDACTED/scm' at line '13' and column '5' is not valid: The template function 'reference' is not expected at this location. Please see https://aka.ms/arm-template-expressions for usage details.. Please see https: //aka.ms/arm-template-expressions for usage details.'.",
"additionalInfo": [
{
"type": "TemplateViolation",
"info": {
"lineNumber": 13,
"linePosition": 5,
"path": "properties.template.resources[0]"
}
}
]
}
}
```

**Additional context**
There is a type issue with the `location` property for `basicPublishingCredentialsPolicies` being missing in the type definitions, so this could be a knock on error from that
![image](https://user-images.githubusercontent.com/289860/136960352-dbcf3b43-a1d6-424e-b3c9-fc4d63404d53.png)

Contributor guide

Open the contributing guide

Research direction

Compile the supplied Bicep template with Bicep CLI 0.4.613 and inspect the generated ARM template, focusing on the nested existing basicPublishingCredentialsPolicies resource and its location property. Compare the generated resource structure with ARM template expression rules; done means the example either produces a clear compilation error or deploys successfully without the reference-function validation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud
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.