Deploy to Azure Functions
This guide explains how to avoid common issues when deploying a Node.js-based function app to Azure using Azure Functions.
Azure Functions is a serverless deployment platform. You do not need to maintain infrastructure to deploy your code. With Azure Functions, the fundamental building block is the function app. A function app provides an execution context in Azure in which your functions run. It is comprised of one or more individual functions that Azure manages, deploys, and scales together. You can organize and collectively manage multiple functions as a single logical unit.
If Prisma’s Rust engine binaries cause large bundle sizes, slow builds, or deployment issues (for example, in serverless or edge environments), you can switch to the queryCompiler
Preview feature introduced in v6.7.0.
When enabled, Prisma Client is generated without a Rust-based query engine binary, reducing build artifacts and removing native binary dependencies:
generator client {
provider = "prisma-client-js"
previewFeatures = ["queryCompiler", "driverAdapters"]
}
Note that the driverAdapters
Preview feature is required alongside queryCompiler
.
When using this architecture:
- No Rust query engine binary is downloaded or shipped.
- The database connection pool is maintained by the native JS database driver you install (e.g.,
@prisma/adapter-pg
for PostgreSQL).
This setup can simplify deployments in serverless or edge runtimes. Learn more in the docs here. Curious why we're moving away from the Rust engine? Take a look at why we're transitioning from Rust binary engines to an all-TypeScript approach for a faster, lighter Prisma ORM in our blog post.
Prerequisites
- An existing function app project with Prisma ORM
Things to know
While Prisma ORM works well with Azure functions, there are a few things to take note of before deploying your application.
Define multiple binary targets
When deploying a function app, the operating system that Azure functions runs a remote build is different from the one used to host your functions. Therefore, we recommend specifying the following binaryTargets
options in your Prisma schema:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
Connection pooling
Generally, when you use a FaaS (Function as a Service) environment to interact with a database, every function invocation can result in a new connection to the database. This is not a problem with a constantly running Node.js server. Therefore, it is beneficial to pool DB connections to get better performance. To solve this issue, you can use the Prisma Accelerate. For other solutions, see the connection management guide for serverless environments.
Summary
For more insight into Prisma Client's API, explore the function handlers and check out the Prisma Client API Reference