Azure Function stoped returning documents from input RRS feed

  • Question

  • just like that this code stoped returning documents, why? 

    public static class GetStatsByDate
            public static async Task<HttpResponseMessage> Run(
                [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "GetStatsByDate/{type}/")]HttpRequestMessage req,
                string type,
                [DocumentDB(Manager.DatabaseName, "devs", ConnectionStringSetting = Manager.DbConnString, SqlQuery = "SELECT c.date, c.count FROM c where c.type={type} and c.count>0 order by c.date desc")] IEnumerable<object> documents,
                TraceWriter log)
                  var docs = documents.ToList();
                  log.Info("C# HTTP trigger function processed a request. Found documents: " + docs.Count);
                 return req.CreateResponse(HttpStatusCode.OK, docs, "application/json");

    I got a warning message in cosmos db, some thing about RUs being at limit, so I changed from 400RUs to 1000RUs but nothing happens. Everything looks fine in Azure portal. 

    108mb of data, 1500 document in "devs" container. I have no partition key. 

    I have blogged about the solution here, https://devblog.gosso.se/2018/10/http-trigger-azure-functions-with-cosmosdb-sql-api/

    all functions has stoped deliver documents with the DocumentDB input param.

    Thanks for any help! 

    • Edited by Luc Gosso EMVP Thursday, August 29, 2019 1:17 PM c._ts was c.date (string)
    Tuesday, August 27, 2019 7:50 AM

All replies

  • Hi Luc,

    Can you log into the Azure Portal and access the 'devs' database instance and use the query explorer to run the following query:

    SELECT c.date, c.count FROM c where c.type={type} and c.count>0 order by c._ts desc"

    where c.type={type} is manually populated with a specific value. If that works, can you write the output of "string type" to log.info? Or does docs.Count provide a value greater than 0 in the log output? If docs.Count is returning a value greater than zero, then the function is working. If you are receiving an RU/s exceeded, you might be returning too many documents and will need to implement a continuation token to step through the result set. If that is not the issue, we will need to enable logging for the Azure Functions piece. The following document walks you through setting this up: https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring

    If the query works directly against the Cosmos DB instance and the query scope returns a result-set that your current RU/s throughput can handle, then we need to look at Azure Functions.



    Tuesday, August 27, 2019 9:54 PM
  • Thanks for guidance, 

    Turned out that i had "order by c.date desc" where c.date is a string. if I use c._ts it works, but _ts is modified date ticks. 

    I probably need to Index it right. This is how it looks for now:

        "indexingMode": "consistent",
        "automatic": true,
        "includedPaths": [
                "path": "/*",
                "indexes": [
                        "kind": "Range",
                        "dataType": "Number",
                        "precision": -1
                        "kind": "Hash",
                        "dataType": "String",
                        "precision": 3
        "excludedPaths": []

    If i want c.date to be indexed, how should my indexing policy look like to make it work? thx

    Thursday, August 29, 2019 1:15 PM
  • Thanks for getting back to us with the resolution to your initial issue. I am going to propose that as the answer but will investigate the indexing item and get back with you.



    Friday, August 30, 2019 12:16 AM