How to fix @azure/cosmos not installing in npm Azure function deployment

Brian Betancourt 0 Reputation points
2023-05-12T13:03:29.2466667+00:00

For some reason in my latest Azure Functions push, I've noticed all of my deployed functions are failing to start due to missing a dependency: @azure/cosmos . This is required in my index.js file.

If I look through the files on my Azure Functions App, I can see my package.json has correclty identified @azure/cosmos as a dependency but I can't find any node_modules/ folder.

More troubling is that looking for solutions directs me to use the "Kudu Console", which seems to not exist for my function app. I don't have the "CMD" or "Debug" option if I attempt to connect to https://<myapp>.azurewebsites.net

Any suggestions would be greatly appreciated

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,119 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,402 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 12,985 Reputation points
    2023-05-13T18:07:50.9766667+00:00

    Ensure that you're using a deployment method that includes node_modules. If you're deploying only the function's code files and package.json, without node_modules, Azure Functions runs npm install --production for you. If that's not working, you might try deploying with node_modules.

    The Kudu Console or Advanced Tools (also called "Kudu services") can be accessed from the Azure portal. Navigate to your Azure Function App in the portal. Then, in the left pane, look for "Advanced Tools" under the "Development Tools" section and click "Go".

    Inside Kudu, you can manually run npm install in the console (Debug console -> CMD), which might give you more information if the install is failing for some reason.

    0 comments No comments