# Deploying to Azure

> Source: https://agilitycms.com/docs/sveltekit/deploying-to-azure

Two good ways to run the [SvelteKit starter](https://github.com/agility/sveltekit-starter) on Azure: **Static Web Apps** (SWA) for a managed static + functions setup, or **App Service** running the Node build. Either way, remember the starter's config comes from `$env/static/private`, which is **inlined at build time** — the Agility variables must be present when `npm run build` runs.

## Option A — Azure Static Web Apps

SWA doesn't have an official SvelteKit adapter, so use the community adapter [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa):

```bash
npm i -D svelte-adapter-azure-swa
```

```js
// svelte.config.js
import adapter from 'svelte-adapter-azure-swa';
export default { kit: { adapter: adapter() } };
```

1. Create a **Static Web App** in the Azure portal and connect your GitHub repo — Azure generates a GitHub Actions workflow.
2. In the workflow, set `app_location: "/"` and `api_location: "build/server"` per the adapter's README (check its docs for the current values).
3. Add the Agility variables as **GitHub Actions secrets** and pass them as `env:` on the build step — SWA's portal “application settings” apply at *runtime*, which is too late for build-time-inlined values:

| Variable | Value |
| --- | --- |
| `AGILITY_GUID` | Your instance GUID |
| `AGILITY_API_FETCH_KEY` | Fetch (live) API key |
| `AGILITY_API_PREVIEW_KEY` | Preview API key |
| `AGILITY_SITEMAP` | e.g. `website` |
| `AGILITY_LOCALES` | e.g. `en-us` |

**Rebuild on publish:** the site is prerendered, so point an Agility publish webhook at something that re-runs the workflow — the simplest is a small Azure Function or Logic App that calls GitHub's [`repository_dispatch`](https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event) API, with the workflow listening for that event.

## Option B — Azure App Service (Node)

Run SvelteKit as a Node server with the official Node adapter:

```bash
npm i -D @sveltejs/adapter-node@5
```

> The starter uses SvelteKit 2. `@sveltejs/adapter-node` 6 and later require SvelteKit 3, so install version 5 until you upgrade the starter to SvelteKit 3.

```js
// svelte.config.js
import adapter from '@sveltejs/adapter-node';
export default { kit: { adapter: adapter() } };
```

1. Create an **App Service** on the **Node 24 LTS** runtime (Node 22 also works; Node 20 and earlier are end of life), deploy via GitHub Actions or `az webapp up`.
2. Build with the Agility env vars present; start the server with `node build`.
3. Same publish-webhook → rebuild wiring as above (re-run your deployment workflow).

App Service suits teams already standardized on Azure compute or needing server features SWA doesn't offer.

> **Preview mode note:** the starter's preview toggle is for local dev; production serves **published** content.

---

Index of every docs page: https://agilitycms.com/docs/llms.txt
