[Bug Report]: paritionKey should be required by the container resource for a NoSQL database
Describe the bug
The NoSQL Container resource requires properties.resources.partitionKey but it isn't marked as required. The API rejects a container with a partition key with this error:
A Partition key definition is not specified in the request.
To reproduce
Deploy a container to a NoSQL database without specifying the partitionKey.
Code snippet
param databaseAccountName string
param databaseName string
param containerName string
resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2023-09-15' existing = {
name: databaseAccountName
}
resource alertDatabase 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2023-09-15' = {
name: databaseName
parent: cosmosDbAccount
properties: {
resource: {
id: databaseName
}
}
}
resource alertSpecificationContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2023-09-15' = {
name: containerName
parent: alertDatabase
properties: {
resource: {
id: containerName
}
}
}
Relevant log output
No response
Hey @krbar, could you check this via the AVM module you're working on. To do so, I guess we should have a test cases that does not provide the partition key (which should fail as per @carlin-q-scott's bug description) and then update the module accordingly before publishing.
Thanks for raising this @carlin-q-scott and sorry for the late response. The current migration to the Public Registry binds a lot of resources and we try to get through it as fast as possible.
Looking closer at the resource though, I can't help but wonder about one thing though. The property in the resource is designed as follows:
https://github.com/Azure/ResourceModules/blob/3b5965bab8461ed6dd00acec57db591b49cd0879/modules/document-db/database-account/sql-database/container/main.bicep#L86-L89
The individual values all the while are: https://github.com/Azure/ResourceModules/blob/3b5965bab8461ed6dd00acec57db591b49cd0879/modules/document-db/database-account/sql-database/container/main.bicep#L35-L36 https://github.com/Azure/ResourceModules/blob/3b5965bab8461ed6dd00acec57db591b49cd0879/modules/document-db/database-account/sql-database/container/main.bicep#L44-L50
So if you don't provide anything, the value it tries to use should be
partitionKey: {
paths: []
kind: 'Hash'
}
In other words, the value is never empty unless you overwrite the default.
So, just to clarify @carlin-q-scott - is the issue you're having with our module, or is it with the resource provider itself, which, as you stated, may be incorrect in not specifying 'partitionKey' as required. If the later we have to redirekt this to the product group as this Repository is not populated by the Product Groups themselves.
@AlexanderSehr I did not specify the partitionKey at all, so I'm guessing an empty array for the paths is what is not allowed by the resource provider. Their error message is a bit misleading I guess.
I will look at this issue together with @bryansan-msft Please note that the solution will be implemented in the BRM Repo as the module has already been migrated to AVM. I will drop a comment, once the fix is finished.
@AlexanderSehr could you close this one?
I can @bryansan-msft (cc: @krbar), just before I do - was this covered in the meantime? If not, I could also offer to migrate it to BRM instead and then handle it there :)
Yes, see the PR linked to this issue
From: Alexander Sehr @.> Sent: Saturday, May 25, 2024 1:30 PM To: Azure/ResourceModules @.> Cc: Mention @.>; Comment @.> Subject: Re: [Azure/ResourceModules] [Bug Report]: paritionKey should be required by the container resource for a NoSQL database (Issue #4278)
I can @bryansan-msfthttps://github.com/bryansan-msft (cc: @krbarhttps://github.com/krbar), just before I do - was this covered in the meantime? If not, I could also offer to migrate it to BRM instead and then handle it there :)
— Reply to this email directly, view it on GitHubhttps://github.com/Azure/ResourceModules/issues/4278#issuecomment-2131223903 or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4BPQLRNAOR3I3FTO6RQ5EDZEBY6PBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZTENZRHAZDONRXGWSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJTHE3TIMJRGAYTHAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDEMBQGUZTONZVHEYYFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIZTENZRHAZDONRXGWTXI4TJM5TWK4VGMNZGKYLUMU. You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.