Start the API server with the Azure Static Web App CLI

In Azure Static Web Apps, you can use the integrated managed Functions to add API endpoints to your application. You can run an Azure Functions app locally using Azure Functions core tools CLI. The core tools CLI gives you the opportunity to run and debug your API endpoints locally.

You can start the core tools manually or automatically.

Manual start

To use the SWA CLI emulator alongside the API server:

  1. Start API server using the Azure Functions core tools CLI or the Visual Studio Code Extension.

    Copy the URL of the local API server, once the core tools are running.

    func host start
    
  2. In a separate terminal, start the SWA CLI using the --api-devserver-url option to pass it the local API Server URI.

    For example:

    swa start ./my-dist --api-devserver-url http://localhost:7071
    

Automatic start

To set up an automatic start, you first need to have an Azure Functions application project located in an api folder in your local development environment.

  1. Launch the API server alongside the SWA emulator

    swa start ./my-dist --api-location ./api
    
  2. Combine the launch with usage of a running dev server

    swa start http://localhost:3000 --api-location ./api
    

Next steps