Incorrect schema in Microsoft.Web/sites/slots, Microsoft.Web/sites?
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 79
Description
**Bicep version**: v0.9.1 (a2950a16df)
**Describe the bug**
Azure requires that a `sites` and a `sites/slot` requires a `properties.serverFarmId`.
**To Reproduce**
Try this bicep script:
```
// param applicationName string = ...
resource serverfarm 'Microsoft.Web/serverfarms@2022-03-01' = {
name: applicationName
location: region
kind: 'app'
sku: {
name: 'P1v2'
tier: 'PremiumV2'
}
properties: {
reserved: true
}
}
resource webapp 'Microsoft.Web/sites@2022-03-01' = {
name: applicationName
location: region
kind: 'app,linux'
identity: {
type: 'SystemAssigned'
}
dependsOn: [ serverfarm ] // No, it's not unnecessary; otherwise it'll error (null reference).
properties: {
siteConfig: {
alwaysOn: true
appSettings: []
ftpsState: 'Disabled'
remoteDebuggingEnabled: env == 'dev' ? true : false
netFrameworkVersion: '5.0'
}
httpsOnly: true
}
}
resource staging 'Microsoft.Web/sites/slots@2022-03-01' = {
name: '${applicationName}/staging'
location: region
dependsOn: [ webapp, serverfarm ]
properties: {
cloningInfo: {
sourceWebAppId: webapp.id
}
siteConfig: {
push: {
properties: {
isPushEnabled: false
}
}
alwaysOn: true
}
}
}
```
However, this one works:
```
resource serverfarm 'Microsoft.Web/serverfarms@2022-03-01' = {
name: applicationName
location: region
kind: 'app'
sku: {
name: 'P1v2'
tier: 'PremiumV2'
}
properties: {
reserved: true
}
}
resource webapp 'Microsoft.Web/sites@2022-03-01' = {
name: applicationName
location: region
kind: 'app,linux'
identity: {
type: 'SystemAssigned'
}
dependsOn: [ serverfarm ]
properties: {
serverFarmId: serverfarm.id
siteConfig: {
alwaysOn: true
appSettings: []
ftpsState: 'Disabled'
remoteDebuggingEnabled: env == 'dev' ? true : false
netFrameworkVersion: '5.0'
}
httpsOnly: true
}
}
resource staging 'Microsoft.Web/sites/slots@2022-03-01' = {
name: '${applicationName}/staging'
location: region
dependsOn: [ webapp, serverfarm ]
properties: {
cloningInfo: {
sourceWebAppId: webapp.id
}
serverFarmId: serverfarm.id
siteConfig: {
push: {
properties: {
isPushEnabled: false
}
}
alwaysOn: true
}
}
}
```
Even though Bicep will allow the script through, and it'll pass ARM pre-checks, it'll always result in a bad request.
Contributor guide
Research direction
Start by locating the schema definitions for Microsoft.Web/sites and Microsoft.Web/sites/slots, then compare their required properties with the Azure API behavior shown in the reproduction. Update the schemas so serverFarmId is required for both resource types and add or adjust validation coverage to confirm the invalid example is rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100