42

I having the same error icrosoft.Azure.Documents.DocumentClientException: Message: {"Errors":["Owner resource does not exist"]} , this is my scenario. When I deployed my webapp to Azure and try to get some document from docDb it throws this error. The docdb exists in azure and contains the document that i looking for.

The weird is that from my local machine(running from VS) this works fine. I'm using the same settings in Azure and local. Somebody have and idea about this.

Thanks

user1301722
  • 423
  • 1
  • 4
  • 4
  • According to the exception `"Errors":["Owner resource does not exist"]}`, it seems that the document is not existing in the collection. But you mentioned that it is existing. Do you have a try [remote debug the WebApp](https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-dotnet-troubleshoot-visual-studio#a-nameremotedebugaremote-debugging-web-apps). to check the documentId `Uri documentUri = UriFactory.CreateDocumentUri( databaseName, collectionName, documentId);` – Tom Sun - MSFT Apr 24 '17 at 06:44
  • I just can repro the error info while the document is not existing the collection. Do you have a try to config another documentdb to test it? As I know there is no need to do special configuration on the Azure WebApp. More detail please refer to the [document](https://learn.microsoft.com/en-us/azure/documentdb/documentdb-dotnet-application#a-nametoc395637774astep-7-deploy-the-application-to-azure-websites) – Tom Sun - MSFT Apr 24 '17 at 06:48

6 Answers6

72

Owner resource does not exist

occurs when you have given a wrong database name.

For example, while reading a document with client.readDocument(..), where the client is DocumentClient instance, the database name given in docLink is wrong.

Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140
4

This error for sure appears to be related to reading a database/collection/document which does not exist. I got the same exact error for a database that did exist but I input the name as lower case, this error appears to happen regardless of your partition key.

The best solution I could come up with for now is to wrap the

var response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(database, collection, "documentid"));

call in a try catch, not very elegant and I would much rather the response comes back with some more details but this is Microsoft for ya.

Something like the below should do the trick.

                Model myDoc = null;

                try
                {
                    var response = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(database, collection, document));
                    myDoc = (Model )(dynamic)response.Resource;
                }
                catch { }


                if (myDoc != null)
                {
                   //do your work here
                }

That is to get a better idea of the error then create the missing resource so you dont get the error anymore.

A few resources I had to go through before coming to this conclusion: https://github.com/DamianStanger/DocumentDbDemo

Azure DocumentDB Read Document Resource Not Found

Louie Bacaj
  • 1,417
  • 13
  • 18
2

I had the same problem. I found that Visual Studio 2017 is publishing using my Release configuration instead of the Test configuration I've selected. In my case the Release configuration had a different CosmosDB database name that doesn't exist, which resulted in the "owner resource does not exist" error when I published to my Azure test server. Super frustrating and a terrible error message.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Steve Perkins
  • 117
  • 1
  • 7
0

It may also be caused by a not found attachment to a document. This is a common scenario when you move cosmos db contents using Azure Cosmos DB Data Migration tool which moves all the documents with their complete definition but unfortunately not the real attachment content.

Therefore this result in a document that states it has an attachment, and also states the attachment link, but at that given link no attachment can be found because the tool have not moved it.

Now i wrap my code as follow

try{
    var attachments = client.CreateAttachmentQuery(attacmentLink, options);
    [...]
}
catch (DocumentClientException ex)
{
    throw new Exception("Cannot retrieve attachment of document", ex);
}

to have a meaningful hint of what is going on.

Mosè Bottacini
  • 4,016
  • 2
  • 24
  • 28
0

I ran into this because my dependency injection configuration had two instances of CosmosClient being created for different databases. Thus any code trying to query the first database was running against the second database.

My fix was to create a CosmosClientCollection class with named instances of CosmosClient

mdickin
  • 2,365
  • 21
  • 27
0

In NodeJS if the database name has error:

const config = {
      endpoint: "/...",
      key: "...",
      databaseId: "data_base_name_error", // error in name: Owner resource does not exist
      connectionPolicy: { enableEndpointDiscovery: false }
    }
Hamada
  • 1,836
  • 3
  • 13
  • 27