Azure / Azure/bicep

Cosmos DatabaseContainer requires `name` and `properties.resource.id` to be identical

Open
#2,577 2 comments 1 reaction 0 assignees View on GitHub
provider improvement
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
Bicep CLI version 0.3.255 (589f0375df)

**Describe the bug**
When creating a cosmos database or container, you have to specify both `name` and `properties\resource\id`. If these values are not the same, you get a runtime error

```json
{
"code": "BadRequest",
"message": "Resource name name in request-uri does not match Resource name id in request-body.\r\nActivityId: cb1466d3-192a-4ee0-a409-ac82eed5408d, Microsoft.Azure.Documents.Common/2.11.0"
}
```

Is it possible to either
1. Not require both properties to be set (If they're required to be identical, seems redundant to need both)
2. Make this into a compile time error

**To Reproduce**

```bicep
resource account 'Microsoft.DocumentDB/databaseAccounts@2021-03-01-preview' = {
kind: 'GlobalDocumentDB'
name: 'acme182'
location: resourceGroup().location
properties: {
createMode: 'Default'
databaseAccountOfferType: 'Standard'
locations: [
{
locationName: resourceGroup().location
}
]
}
}

resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2020-04-01' = {
name: 'Something'
parent: account
properties: {
resource: {
id: 'SomethingElse'
}
options: {
}
}
}

resource container 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2020-04-01' = {
name: 'Something'
parent: database
properties: {
resource: {
id: 'SomethingElse'
partitionKey: {
paths: [
'/id'
]
kind: 'Hash'
}
}
options:{
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the Bicep reproduction for the Cosmos DB SQL database and container resources, focusing on the mismatch between `name` and `properties.resource.id`. Determine whether the issue should be resolved by allowing one value to be omitted or by reporting a compile-time diagnostic, then verify the chosen behavior against the example.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.