Unable to Create Stored Procedure in Azure Cosmos DB Container

Kirankumar Bharsadiya 60 Reputation points
2025-04-23T14:00:59.5133333+00:00

Experiencing an issue when attempting to create a new stored procedure in a specific container within Azure Cosmos DB. The error encountered is as follows:

Error while creating stored procedure spSelectCount: Message: {"code":"NotFound","message":"Entity with the specified id does not exist in the system. More info: https://aka.ms/cosmosdb-tsg-not-found\r\nActivityId: d5d84b7c-aba3-45da-95fd-349e866afb65, Microsoft.Azure.Documents.Common/2.14.0"}, Request URI: /dbs/myDatabaseName/colls/myContainerName/sprocs/spSelectCount, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Documents.Common/2.14.0 ActivityId: ea9f2fee-8b77-4bfd-9b9f-28afb2866665, Microsoft.Azure.Documents.Common/2.14.0

The following verifications have been made:

  • The stored procedure does not exist in the container where the creation is attempted.
  • The stored procedure exists in a different container with the same ID.

It is unexpected to receive a "Not Found" error upon creation, as a conflict should ideally occur if the stored procedure already existed. Assistance is needed to resolve this conflicting scenario.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,843 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Azar 27,520 Reputation points MVP
    2025-04-23T16:37:08.79+00:00

    Hi there Kirankumar Bharsadiya

    Thanks for using QandA platform

    This typically indicates that the specified container or database doesn't exist or isn't accessible at the time of the request not that the stored procedure itself is missing. Even if the stored procedure doesn't already exist (which should normally result in a conflict error if it did), Cosmos DB will return a "NotFound" error if the parent container path is incorrect or not found.

    verify that your SDK client is correctly configured with the right endpoint and keys. This issue can also happen if the container creation hasn’t completed yet in scripts or CI/CD flows. You can refer to the official docs on stored procedures and the troubleshooting guide for NotFound errors

    If this helps kindly accept the answer thanks much.


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.