You can use the feature of Nested Partition Key Path in azure-spring-data-cosmos to solve the unique key problem in spring - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/README.md#nested-partition-key-support.