简体   繁体   中英

How to update properties in ASP.NET Core Service (DI)

I have the Chatbot, the data for the chatbot is stored in the Azure Cosmos DB. If I change the data in Cosmos DB, I have to restart my web app because the service used for fetching the data from Cosmos is registered in Startup.cs as Singleton.

So my requirement is to update the service properties (data) from Cosmos without restarting the app; also it should not lead to a deadlock.

Can anyone help me with the way to achieve this?

CosmosClient provides a client-side logical representation of the Azure Cosmos DB account. This client can be used to configure and execute requests in the Azure Cosmos DB database service.

CosmosClient is thread-safe. It's recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance.

CosmosDB Client will get the data that is actually present in the database unless you are caching it. Moreover, make sure, you are using the right consistency level and redundancy .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM