What is best practice for a Functions App to update a Cosmos NoSQL container configuration?

David Hunsicker 0 Reputation points
2025-01-03T17:18:20.3066667+00:00

Much more details here: https://stackoverflow.com/questions/79325429/azure-functions-app-cannot-update-cosmos-db-container-configuration-using-ihoste

Essentially in my app service plan I made a Functions app that uses IHostedService added to the service configuration. The application starts with await host.RunAsync() which kicks off the StartAsync() of the DatabaseInitializerService

My application is connected to the cosmos db in azure and can read and write to it. It has contributor access.

When I run locally with the Cosmos DB Emulator I can see that the function is able to mutate the indexing policy and TTL settings on the Cosmos DB container. In azure this does not happen.

What could be the cause? If using IHostedService StartAsync to do these kinds of DB updates is bad practice, what's better practice for a Functions app updating its container configurations?

In my role I don't have access to Terraform and I have very limited access to Azure itself when it comes to write permissions in Azure Portal. The SDK must have a best practice since it has the public methods available.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,278 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,717 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.