The error you're encountering seems to be related to the Prisma client package, specifically that the module .prisma/client/index
cannot be found. Since the issue appeared suddenly across all environments without any changes from your side, it's possible that something external has impacted your setup. Here are some potential causes and troubleshooting steps:
Potential Causes:
- File Path Issues: It seems like the deployment may have been corrupted or missed files during the ZIP deployment. Specifically, the Prisma client files are not being found, which could indicate they weren't properly included in the deployed package.
- Prisma Client Generation: The Prisma client files are generated at build time. If Prisma wasn’t properly generated during the build, the necessary files won’t be available at runtime.
- Node.js Update/Compatibility: Since you're using Node 18 LTS, there might have been an update or a compatibility issue introduced either by Azure or within your deployment pipeline, causing certain packages or files to not load correctly.
- Platform Issues (Azure): Given that it’s affecting all environments, there could be an underlying issue with Azure Functions or the Linux platform you're running on, particularly if Azure updated the runtime or infrastructure without notice.
Troubleshooting Steps:
- Rebuild and Redeploy:
- Try to manually regenerate the Prisma client by running
npx prisma generate
and ensure thenode_modules/.prisma/client
folder is present. - Rebuild your project and deploy it again using ZIP deployment, ensuring all dependencies are included.
- Try to manually regenerate the Prisma client by running
- Check
run-from-package
Setting:- When using
run-from-package
, Azure Functions run directly from the ZIP package. Ensure that the ZIP package includes all the necessarynode_modules
files, including Prisma. - Double-check that
WEBSITE_RUN_FROM_PACKAGE
is set correctly in your application settings and points to the correct ZIP package.
- When using
- Verify the Node.js Version:
- Confirm that the version of Node.js being used on Azure is indeed Node 18 LTS and matches your local environment. You can check this in the Azure Function's settings.
- Ensure that all dependencies are compatible with Node 18 LTS, including Prisma.
- Prisma and SQLite Cache:
- Prisma might cache certain binaries depending on the environment. You can try clearing Prisma's cache by running
npx prisma generate --force
before deployment.
- Prisma might cache certain binaries depending on the environment. You can try clearing Prisma's cache by running
- Check for Azure Platform Issues:
- Check if there are any ongoing Azure platform issues, particularly related to the Azure Functions Linux EP1 instance or Prisma-related services. Sometimes Azure may push updates to the platform that could introduce breaking changes.
- You can check the Azure Status page or reach out to Azure Support to confirm if any recent changes might have impacted your environments.
- Local Testing:
- Test the function locally with the same Node.js version to ensure it works before deploying it to Azure. This will help you identify if the issue is with the deployment process or the Azure environment.
- API Management Settings:
- Test if removing API Management from the flow resolves the issue. This will help identify if the problem is specific to Azure API Management or to the Azure Function itself.
If the issue persists:
- Consider turning on detailed logging in Azure Functions and Application Insights to capture more detailed errors or stack traces that may provide additional clues.
- Reach out to Azure Support if you're unable to resolve the issue, as this could be related to Azure's infrastructure changes.
Let me know how the troubleshooting goes or if you need further assistance!