Question

Azure CLI commands not working in VSCode-bash on Mon, 25 May 2020 20:17:51


Hi all,

I've followed the tutorial more than once for https://docs.microsoft.com/en-us/learn/modules/chain-azure-functions-data-using-bindings/5-read-data-with-input-bindings-portal-lab?pivots=javascript

The function executes when I follow the first part with the query params "name" and returns "Hello {name}". 

After I add the CosmosDB input binding I'm getting 500 internal server error.  I checked the code and the setup at least 10 times and it doesn't work. 

module.exports = function (context, req) {
    
    var bookmark = context.bindings.bookmark
    
    if(bookmark){
            context.res = {
            body: { "url": bookmark.url },
            headers: {
            'Content-Type': 'application/json'
            }
        };
    }
    else {
        
        context.res = {
            status: 404,
            body : "No bookmarks found",
            headers: {
            'Content-Type': 'application/json'
            }
        };
    }

    context.done();
};
{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },
    {
      "name": "bookmark",
      "direction": "in",
      "type": "cosmosDB",
      "databaseName": "func-io-learn-db",
      "collectionName": "Bookmarks",
      "connectionStringSetting": "func-io-learn-db_DOCUMENTDB",
      "id": "{id}",
      "partitionKey": "{id}",
      "sqlQuery": ""
    }
  ]
}


2020-05-25T20:05:25Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)
2020-05-25T20:05:25Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)
2020-05-25T20:05:30Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:30Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:30Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:30Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:25Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)
2020-05-25T20:05:25Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)
2020-05-25T20:05:30Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:30Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=f68bed7d-322b-4dcc-a4fb-c81d72b99e9f)
2020-05-25T20:05:25Z   [Error]   Executed 'Functions.find-bookmark' (Failed, Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)
2020-05-25T20:05:25Z   [Information]   Executing 'Functions.find-bookmark' (Reason='This function was programmatically called via the host APIs.', Id=53d55bdd-9c3b-40cd-ac4c-554ffb447b96)


Replies

Mike Urnun (Azure) on Mon, 01 Jun 2020 06:22:04


Hi there - Most of the times, it's usually the installation process of the CosmosDB extension had an issue resulting in the 500 error from the IIS server. As it's called out in the Learn module, it's important to wait and let the installation process complete before navigating elsewhere in the Portal.