title: Failed to parse the value '' as ResourceId in Cosmos DocumentQuery in Azure Function
body: <p>I have an Azure Function 2.0.12562 that is getting the following error when trying to query CosmosDB.</p>
  
  <blockquote>
    <p>Error: DoesCosmosContain failed: Failed to parse the value '' as
    ResourceId., Windows/10.0.18362 documentdb-netcore-sdk/2.4.0</p>
  </blockquote>
  
  <p>An entry in Cosmos looks like</p>
  
  <pre><code>{
      "id": "851a3506-3915-4f7c-9e32-32d927055555",
      "_rid": "Tg8ZAI-iVnQBAAAAAAAADQ==",
      "_self": "dbs/Tg8ZAA==/colls/Tg8ZAI-iVnQ=/docs/Tg8ZAI-iVnQBAAAAAAAADQ==/",
      "_etag": "\"0f00e289-0000-0500-0000-5d1676600000\"",
      "Prop_0": "555",
      "Prop_1": "5551234",
      "_attachments": "attachments/",
      "_ts": 1561755555
  }
  </code></pre>
  
  <p>This Azure function receives all the DB connectors in the POST and that working.
  The error throws on the ExecuteNextAsync line.</p>
  
  <pre><code>[FunctionName("DoesCosmosContain")]
      public static async Task&lt;bool&gt; DoesCosmosContain([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
      {
          try
          {
              MyCosmosInformation scaleParams = await MyCosmosInformation.CreateAsync(req);
  
              // shimming out locals
              string key = scaleParams.CosmosKey;
              string uri = scaleParams.CosmosUri;
              Uri cosmosUri = new Uri(uri);
              string offerLink = scaleParams.OfferLink;
  
              using (DocumentClient client = new DocumentClient(cosmosUri, key))
              {
                  IDocumentQuery&lt;PhoneNumber&gt; query = client.CreateDocumentQuery&lt;PhoneNumber&gt;(offerLink)
                  .Where(p =&gt; p.AreaCode=="555" &amp;&amp; p.Number=="5551234")
                  .AsDocumentQuery();
  
                  while (query.HasMoreResults)
                  {
                      foreach (PhoneNumber result in await query.ExecuteNextAsync())
                      {
                          return true;
                      }
                  }
  
                  return false;
              }
          }
          catch (Exception e)
          {
              string error = $"DoesCosmosContain failed: {e.Message}";
              log.Error(error);
          }
              return true;
      }
  </code></pre>
  
  <p>This is the wrapper class to help parse the POST JSON to create the DB Connection.</p>
  
  <pre><code>// Wrapper Class for Post Json data
  public class MyCosmosInformation
  {
      public async static Task&lt;MyCosmosInformation&gt; CreateAsync(HttpRequestMessage req)
      {
          string data = await req.Content.ReadAsStringAsync();
          MyCosmosInformation returnValue = JsonConvert.DeserializeObject&lt;MyCosmosInformation&gt;(data);
  
          if (returnValue == null)
          {
              throw new ArgumentNullException("Unable to correctly parse post body into MyCosmosInformation");
          }
  
          return returnValue;
      }
  
      public int Throughput { get; set; }
      public string OfferLink { get; set; }
      public string CosmosUri { get; set; }
      public string CosmosKey { get; set; }
      public string CosmosDbId { get; set; }
      public string CosmosCollectionId { get; set; }
  }
  </code></pre>
  
  <p>This is the posted JSON. Censored for my secrets.</p>
  
  <pre><code>{
  "CosmosCollectionId" : "myCollectionId",
  "CosmosUri": "https://myEndpoint.documents.azure.com:443",  
  "CosmosKey": "MyCosmosKey8eXXXbkrYVSENSOREDgy8eeOMITTED==",
  "CosmosDbId": "myDBId",
  "OfferLink": "offers/MYID/",
  }
  </code></pre>
  
  <p>The PhoneNumberClass</p>
  
  <pre><code>internal sealed class PhoneNumber
  {
      [JsonProperty(PropertyName = "Prop_0")]
      public string AreaCode { get; set; }
  
      [JsonProperty(PropertyName = "Prop_1")]
      public string Number { get; set; }
  
      public string ResourceId { get; set; }
  }
  </code></pre>