Deploy Nitro apps to Azure Static Web apps or functions.

Azure static web apps

Preset: azure

Read more in Azure Static Web Apps.
Integration with this provider is possible with zero configuration.

Azure Static Web Apps are designed to be deployed continuously in a GitHub Actions workflow. By default, Nitro will detect this deployment environment and enable the azure preset.

Local preview

Install Azure Functions Core Tools if you want to test locally.

You can invoke a development environment to preview before deploying.

NITRO_PRESET=azure npx nypm@latest build
npx @azure/static-web-apps-cli start .output/public --api-location .output/server


Azure Static Web Apps are configured using the staticwebapp.config.json file.

Nitro automatically generates this configuration file whenever the application is built with the azure preset.

Nitro will automatically add the following properties based on the following criteria:

platform.apiRuntimeWill automatically set to node:16 or node:14 depending on your package configuration.node:16
navigationFallback.rewriteIs always /api/server/api/server
routesAll prerendered routes are added. Additionally, if you do not have an index.html file an empty one is created for you for compatibility purposes and also requests to /index.html are redirected to the root directory which is handled by /api/server.[]

Custom configuration

You can alter the Nitro generated configuration using azure.config option.

Custom routes will be added and matched first. In the case of a conflict (determined if an object has the same route property), custom routes will override generated ones.

Deploy from CI/CD via GitHub actions

When you link your GitHub repository to Azure Static Web Apps, a workflow file is added to the repository.

When you are asked to select your framework, select custom and provide the following information:


If you miss this step, you can always find the build configuration section in your workflow and update the build configuration:

###### Repository/Build Configurations ######
app_location: '/'
api_location: '.output/server'
output_location: '.output/public'
###### End of Repository/Build Configurations ######

That's it! Now Azure Static Web Apps will automatically deploy your Nitro-powered application on push.

If you are using runtimeConfig, you will likely want to configure the corresponding environment variables on Azure.

Azure functions

Preset: azure_functions

If you encounter any issues, please ensure you're using a Node.js 16+ runtime. You can find more information about how to set the Node version in the Azure docs. Please see unjs/nitro#2114 for some common issues.

Local preview

Install Azure Functions Core Tools if you want to test locally.

You can invoke a development environment from the serverless directory.

NITRO_PRESET=azure_functions npx nypm@latest build
cd .output
func start

You can now visit http://localhost:7071/ in your browser and browse your site running locally on Azure Functions.

Deploy from your local machine

To deploy, just run the following command:

# To publish the bundled zip file
az functionapp deployment source config-zip -g <resource-group> -n <app-name> --src dist/
# Alternatively you can publish from source
cd dist && func azure functionapp publish --javascript <app-name>

Deploy from CI/CD via GitHub actions

First, obtain your Azure Functions Publish Profile and add it as a secret to your GitHub repository settings following these instructions.

Then create the following file as a workflow:

name: azure
      - main
      - main
    runs-on: ${{ matrix.os }}
        os: [ ubuntu-latest ]
        node: [ 14 ]
      - uses: actions/setup-node@v2
          node-version: ${{ matrix.node }}

      - name: Checkout
        uses: actions/checkout@master

      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - uses: actions/cache@v2
        id: yarn-cache
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-azure

      - name: Install Dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: yarn

      - name: Build
        run: npm run build
          NITRO_PRESET: azure_functions

      - name: 'Deploy to Azure Functions'
        uses: Azure/functions-action@v1
          app-name: <your-app-name>
          package: .output/
          publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}

Optimizing Azure functions

Consider turning on immutable packages to support running your app from the zip file. This can speed up cold starts.