title: Azure DocumentDB Read Document Resource Not Found
body: <p>I'm building a .Net Console application to read information in a DocumentDB. The console app has data coming from an EventHub and inserts/updates recent data as it comes into the cloud.</p>
  
  <p>I am trying to read a singular document from DocumentDB and I can confirm that the Document Exists prior to requesting the Document.</p>
  
  <pre><code> if (DocumentDBRepository&lt;DocumentDBItem&gt;.DoesItemExist(name))
   {
       device = await DocumentDBRepository&lt;DocumentDBItem&gt;.GetItemAsync(name);
   }
  </code></pre>
  
  <p>I used <a href="https://docs.microsoft.com/en-us/azure/documentdb/documentdb-dotnet-application" rel="noreferrer">this</a> tutorial from Microsoft about building a Repository for accessing the DocumentDB records, and was successful at using almost all of the methods. I can update/delete/query the DB but I cannot read a singular Item.</p>
  
  <p>First it was throwing an exception requesting a PartitionKey. So I modified the method to add the PartitionKey being used by the DB to the request. As soon as I added the PartitionKey it throws another exception with a message, "Resource Not Found"</p>
  
  <pre><code>public static async Task&lt;T&gt; GetItemAsync(string id)
  {
      try
      {
          RequestOptions options = new RequestOptions();
          options.PartitionKey = new PartitionKey("DeviceId");
          Document document = await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), options);
          return (T)(dynamic)document;
      }
      catch (DocumentClientException e)
      {
          if (e.StatusCode == HttpStatusCode.NotFound)
          {
              return null;
          }
          else
          {
              throw;
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RMps2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RMps2.png" alt="PartitionKeyFromAzure"></a></p>
  
  <p>I've already modified my calls to use "GetItemsAsyc" and get an IEnumerable of Documents and get the First item in the list, but it doesn't make sense why I can use all of the other methods from the tutorial but this one continues to throw exceptions saying, "Resource Not Found".</p>
  
  <p>Exception I'm getting:</p>
  
  <pre><code>"Message: {\"Errors\":[\"Resource Not Found\"]}\r\nActivityId: e317ae66-6500-476c-b70e-c986c4cbf1d9, Request URI: /apps/e842e452-2347-4a8e-8588-2f5f8b4803ad/services/2c490552-a24d-4a9d-a786-992c07356545/partitions/0281cfdd-0c60-499f-be4a-289723a7dbf9/replicas/131336364114731886s"
  </code></pre>