Masahigo / azure-swa-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Static Web Apps demo

Demo for showcasing a simple React based SPA and backend API deployed to SWA.

Combines a couple of examples from the MS docs

Prerequisites

npm install -g azure-functions-core-tools
npm install -g @azure/static-web-apps-cli

Getting started

Running locally from Azure Static Web Apps emulator

Against local build

npm run build
swa start client/build --api-location api

Against dev server

In another terminal:

npm run start

In main terminal:

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

Test API

curl http://localhost:7071/api/message
{
  "text": "Hello from the API"
}

Deploying to Azure

az login

az group create \
  --name my-swa-group \
  --location "westeurope"

az staticwebapp create \
  --name swa-demo-app \
  --resource-group my-swa-group \
  --location "westeurope"

swa deploy client/build --api-location ./api --app-name swa-demo-app

About


Languages

Language:HTML 69.0%Language:JavaScript 31.0%