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,909 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Narendra Pakkirigari 475 Reputation points Microsoft External Staff Moderator
    2025-05-02T08:31:42.88+00:00

    Follow the below steps to create Stored Procedure in Azure Cosmos DB Container:

    Step 1:

    After creating a Azure Cosmos DB account, create a database and a container. Below is my database db1 and a container cont1.

    image

    Step 2:

    You can create Stored Procedure manually, under database db1 you can find a container cont1, under container you can find items, click on ... and select New Stored Procedure or you can find a direct option New Stored Procedure to create it as shown in the below image.

    image (1)

    Database ---> Container ---> Items ---> New Stored Procedure

    New Stored Procedure created successfully, as shown in the below image.

    image (2)

    0 comments No comments

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.