Skip to content

Conversation

@TheovanKraay
Copy link
Contributor

Provides an implementation of the ChatMemoryRepository interface using Azure Cosmos DB for NoSQL as the backing store.

Features

  • Async operations using Azure Cosmos DB SDK
  • Configurable database and container names
  • Automatic container initialization with proper partitioning
  • Thread-safe operations

Note: Integration tests will only run when the AZURE_COSMOSDB_ENDPOINT environment variable is set, and "test-database" exists in the Azure Cosmos DB account (following the same pattern as other Azure services in Spring AI).

The integration tests use Azure authentication (DefaultAzureCredential) to connect to the Cosmos DB account, which requires authenticatio via:

  • Azure CLI: az login
  • Environment variables
  • Managed identity (when running on Azure)
  • Or other Azure authentication methods

@TheovanKraay TheovanKraay force-pushed the cosmosdb-chat-memory-respository branch from 218d7a3 to 69c45a4 Compare September 4, 2025 19:02
@TheovanKraay
Copy link
Contributor Author

Hi @sobychacko - I know there are a lot of PRs. Just wondered if I could get an indication when this one could be looked at? Thank you.

@sobychacko
Copy link
Contributor

@TheovanKraay Thanks for this PR. Pinging @markpollack to see when we can prioritize this. Do you happen to have a testing environment where we can easily test the PR? Thanks!

@eddumelendez
Copy link
Contributor

eddumelendez commented Sep 8, 2025

Hi, I think Testcontainers Azure module module can help here because it offers CosmosDBEmulatorContainer.

@TheovanKraay
Copy link
Contributor Author

Hi, I think Testcontainers Azure module module can help here because it offers CosmosDBEmulatorContainer.

Thanks for the input @eddumelendez. Sadly, testcontainers have some issues currently, something we are looking to address. @sobychacko I don't have an environment I can share, but will discuss with team about this. Ultimately we recognise the need for testcontainers to work properly, hopefully you are able to procure a cloud environment in the meantime. Free tier should work more than adequately to test this PR - https://learn.microsoft.com/azure/cosmos-db/free-tier

@eddumelendez
Copy link
Contributor

eddumelendez commented Sep 9, 2025

@TheovanKraay can you share the issues you are having with Testcontainers and CosmosDB Emulator? I have built demos with it in the past with no issues. Or is this related to the new version, see Azure/azure-cosmos-db-emulator-docker#160? (Sorry for hijacking the thread)

@TheovanKraay
Copy link
Contributor Author

TheovanKraay commented Sep 9, 2025

@TheovanKraay can you share the issues you are having with Testcontainers and CosmosDB Emulator? I have built demos with it in the past with no issues. Or is this related to the new version, see Azure/azure-cosmos-db-emulator-docker#160? (Sorry for hijacking the thread)

@eddumelendez they can work for demos but they are not reliable for test pipelines and unit tests. We will need to make improvements (including eventually GA of vNext emulator). Both legacy version and vNext can have intermittent issues with startup, SSL, and neither support Entra ID/data-plane RBAC.

@sobychacko
Copy link
Contributor

@TheovanKraay Did all the tests pass in your envrionment? Also, do you think you will have the bandwidth to help with any bug reports, enhancements etc. with this module (and other cosmosdb support). Thanks!

@TheovanKraay
Copy link
Contributor Author

@TheovanKraay Did all the tests pass in your envrionment? Also, do you think you will have the bandwidth to help with any bug reports, enhancements etc. with this module (and other cosmosdb support). Thanks!

They did pass in my environment. Yes of course, I and others in Cosmos DB SDK team will support. Until now we have not been monitoring but if you can tag me to issues I will help or delegate to someone as needed.

@sobychacko
Copy link
Contributor

@TheovanKraay Thanks for the updates. We will merge the PR then after a review. Also, will tag you any Cosmos DB related issues/PR's. Thanks again!

<suppress files="RedisVectorStore.java" checks="FinalClass"/>


</suppressions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we having this new file in a non-standard place? Can you add any checkstyle suppressions at the project root src/main/checkstyle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we having this new file in a non-standard place? Can you add any checkstyle suppressions at the project root src/main/checkstyle?

Will address it early next week, thanks

@sobychacko
Copy link
Contributor

@TheovanKraay Can you please add the relevant docs for these changes?

@TheovanKraay
Copy link
Contributor Author

@TheovanKraay Can you please add the relevant docs for these changes?

Ok, can you help me find where the relevant docs should be for memory repository? I could not find anything for the existing ones

@sobychacko
Copy link
Contributor

This one? https://github.com/spring-projects/spring-ai/blob/main/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat-memory.adoc

Signed-off-by: Theo van Kraay <[email protected]>
Signed-off-by: Theo van Kraay <[email protected]>
Signed-off-by: Theo van Kraay <[email protected]>
@TheovanKraay TheovanKraay force-pushed the cosmosdb-chat-memory-respository branch from 21f3400 to 2e1feb6 Compare September 24, 2025 13:02
@TheovanKraay
Copy link
Contributor Author

@sobychacko I have made updates as discussed. Please let me know if any further issues. For future issues, you can also tag @kushagraThapar who is dev lead for Cosmos DB Java SDKs and connectors.

@TheovanKraay
Copy link
Contributor Author

Hey @sobychacko, any problems with merging the PR? Sorry to chase, you probably have many others to look at :-)

@sobychacko
Copy link
Contributor

@TheovanKraay Sorry for the delay in merging. It is now merged upstream via this commit: 1a35e8a.

@sobychacko sobychacko closed this Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants