You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -164,6 +175,10 @@ Common use cases include: installing dependencies for the front-end app and API
164
175
```azstatic-cli
165
176
swa build
166
177
[--app-location]
178
+
[--api-location]
179
+
[--output-location]
180
+
[--app-build-command]
181
+
[--api-build-command]
167
182
[--auto]
168
183
```
169
184
@@ -229,8 +244,16 @@ Start the Azure Static Web Apps emulator from a directory or bind to a running d
229
244
230
245
By default, the CLI starts and serves any static content from the current working directory `./`:
231
246
247
+
```azstatic-cli
248
+
swa start
249
+
```
250
+
232
251
If the artifact folder of your static app is under a different folder (for example, `./my-dist`), then run the CLI and provide that folder:
233
252
253
+
```azstatic-cli
254
+
swa start ./my-dist
255
+
```
256
+
234
257
### Serve from a dev server
235
258
236
259
When developing your front-end app locally, it's often useful to use the dev server that comes with your front end framework's CLI. Using the framework CLI allows you to use built-in features like "livereload" and HMR (hot module replacement).
@@ -241,12 +264,39 @@ To use SWA CLI with your local dev server, follow these two steps:
241
264
242
265
1. In a separate terminal, run `swa start` with the URI provided by the dev server, in the following format:
When developing your backend locally, sometimes it's useful to run Azure Functions Core Tools separately to serve your API. This allows you to use built-in features like debugging and rich editor support.
@@ -267,9 +325,17 @@ To use the CLI with your local API backend dev server, follow these two steps:
267
325
268
326
2. In a separate terminal, run the SWA CLI with the `--api-location` flag and the URI of the local API server, in the following format:
To start your application with a [database connection](database-overview.md), use the `--data-api-location` parameter and point to the folder containing the *staticwebapp.database.config.json* file.
334
+
To start your application with a [database connection](database-overview.md), use the `--data-api-location` parameter and point to the folder containing the _staticwebapp.database.config.json_ file.
@@ -389,8 +455,18 @@ The SWA CLI supports deploying using a deployment token. This is often useful wh
389
455
390
456
- If you are using the [Azure CLI](https://aka.ms/azcli), you can get the deployment token of your project using the following command:
391
457
458
+
```azstatic-cli
459
+
az staticwebapp secrets list --name <APPLICATION_NAME> --query "properties.apiKey"
460
+
```
461
+
392
462
- If you are using the Azure Static Web Apps CLI, you can use the following command:
393
463
464
+
```azstatic-cli
465
+
swa deploy --print-token
466
+
```
467
+
468
+
You can then use that value with the `--deployment-token <TOKEN>` or you can create an environment variable called `SWA_CLI_DEPLOYMENT_TOKEN` and set it to the deployment token.
469
+
394
470
> **Important**: Don't store the deployment token in a public repository. This value must remain a secret.
395
471
396
472
### Deploy a front end app without an API
@@ -401,6 +477,11 @@ You can deploy a front end application without an API to Azure Static Web Apps b
401
477
402
478
**Option 1:** From build folder you would like to deploy, run the deploy command:
403
479
480
+
```azstatic-cli
481
+
cd build/
482
+
swa deploy
483
+
```
484
+
404
485
> **Note**: The `build` folder must contain the static content of your app that you want to deploy.
405
486
406
487
**Option 2:** You can also deploy a specific folder:
@@ -409,14 +490,102 @@ You can deploy a front end application without an API to Azure Static Web Apps b
409
490
410
491
2. Deploy your app:
411
492
493
+
```azstatic-cli
494
+
swa deploy ./my-dist
495
+
```
496
+
412
497
### Deploy a front-end app with an API
413
498
414
499
To deploy both the front end app and an API to Azure Static Web Apps, use the following steps:
415
500
501
+
1. If your front end application requires a build step, run `swa build` or refer to your application build instructions.
502
+
503
+
2. Make sure the API language runtime version in the `staticwebapp.config.json` file is set correctly, for example:
504
+
505
+
```json
506
+
{
507
+
"platform": {
508
+
"apiRuntime": "node:16"
509
+
}
510
+
}
511
+
```
512
+
513
+
> **Note**: If your project doesn't have any `staticwebapp.config.json` file, add one under your `outputLocation` folder.
514
+
515
+
3. Deploy your app:
516
+
517
+
```azstatic-cli
518
+
swa deploy ./my-dist --api-location ./api
519
+
```
520
+
521
+
### Deploy a Blazor app
522
+
523
+
To deploy a Blazor app with an optional API to Azure Static Web Apps, use the following steps:
524
+
525
+
1. Build your Blazor app in **Release** mode:
526
+
527
+
```azstatic-cli
528
+
dotnet publish -c Release -o bin/publish
529
+
```
530
+
531
+
2. From the root of your project, run the `deploy` command:
0 commit comments