8

I'm trying to deploy a Next.js Static Web App to Azure, that uses serverless functions for API routes (Auth, SSR, etc). I followed this guide: https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs. There's a general guide for adding APIs to Azure SWAs but I haven't been able to apply that to my Next.js app.

Next.js has a config option to set serverless apps as the build target.

module.exports = {
  target: 'serverless',
}

What I imagine I would essentially need is a postbuild step that could convert the build output for the api functions into a format that Azure understands. This would run during the GitHub Action build and deploy step.

There's a node module that does this for Netlify, https://github.com/netlify/next-on-netlify but the build output isn't directly compatible with Azure. There's also this for AWS Serverless.

Has anyone had any luck with this sort of setup on Azure?

0 Answers0