Skip to content

Commit 3c15bb6

Browse files
Merge pull request #209543 from craigshoemaker/swa/ext/add-api
[Static Web Apps] Update: Add API
2 parents 9f2ad14 + fa7fd54 commit 3c15bb6

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

articles/static-web-apps/add-api.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: Add an API to Azure Static Web Apps with Azure Functions
33
description: Get started with Azure Static Web Apps by adding a Serverless API to your static web app using Azure Functions.
44
services: static-web-apps
5-
author: manekinekko
5+
author: craigshoemaker
66
ms.service: static-web-apps
77
ms.topic: how-to
8-
ms.date: 12/03/2021
9-
ms.author: wachegha
8+
ms.date: 08/29/2022
9+
ms.author: cshoe
1010
ms.custom: devx-track-js
1111
---
1212

@@ -28,7 +28,7 @@ You can add serverless APIs to Azure Static Web Apps that are powered by Azure F
2828

2929
## Create the static web app
3030

31-
Before adding an API, create and deploy a frontend application to Azure Static Web Apps. Use an existing app that you have already deployed or create one by following the [Building your first static site with Azure Static Web Apps](getting-started.md) quickstart.
31+
Before adding an API, create and deploy a frontend application to Azure Static Web Apps. Use an existing app that you've already deployed or create one by following the [Building your first static site with Azure Static Web Apps](getting-started.md) quickstart.
3232

3333
In Visual Studio Code, open the root of your app's repository. The folder structure contains the source for your frontend app and the Static Web Apps GitHub workflow in _.github/workflows_ folder.
3434

@@ -46,7 +46,7 @@ You create an Azure Functions project for your static web app's API. By default,
4646

4747
1. Press <kbd>F1</kbd> to open the Command Palette.
4848

49-
1. Select **Azure Static Web Apps: Create HTTP Function...**. If you're prompted to install the Azure Functions extension, install it and re-run this command.
49+
1. Select **Azure Static Web Apps: Create HTTP Function...**. If you're prompted to install the Azure Functions extension, install it and rerun this command.
5050

5151
1. When prompted, enter the following values:
5252

@@ -117,7 +117,7 @@ Update the content of the _src/index.html_ file with the following code to fetch
117117
(async function() {
118118
const { text } = await( await fetch(`/api/message`)).json();
119119
document.querySelector('#name').textContent = text;
120-
}())
120+
}());
121121
</script>
122122
</body>
123123
@@ -215,29 +215,23 @@ export default {
215215

216216
## Run the frontend and API locally
217217

218-
To run your frontend app and API together locally, Azure Static Web Apps provides a CLI that emulates the cloud environment. The CLI leverages the Azure Functions Core Tools to run the API.
218+
To run your frontend app and API together locally, Azure Static Web Apps provides a CLI that emulates the cloud environment. The CLI uses the Azure Functions Core Tools to run the API.
219219

220220
### Install command line tools
221221

222222
Ensure you have the necessary command line tools installed.
223223

224-
1. Install Azure Static Web Apps CLI.
225-
```bash
226-
npm install -g @azure/static-web-apps-cli
227-
```
228-
229-
1. Install Azure Functions Core Tools V3.
230-
```bash
231-
npm install -g azure-functions-core-tools@3
232-
```
224+
```bash
225+
npm install -g @azure/static-web-apps-cli
226+
```
233227

234228
### Build frontend app
235229

236230
If your app uses a framework, build the app to generate the output before running the Static Web Apps CLI.
237231

238232
# [No Framework](#tab/vanilla-javascript)
239233

240-
There is no need to build the app.
234+
There's no need to build the app.
241235

242236
# [Angular](#tab/angular)
243237

@@ -277,7 +271,7 @@ Run the frontend app and API together by starting the app with the Static Web Ap
277271
# [No Framework](#tab/vanilla-javascript)
278272

279273
Pass the current folder (`src`) and the API folder (`api`) to the CLI.
280-
274+
281275
```bash
282276
swa start src --api-location api
283277
```
@@ -308,7 +302,7 @@ Run the frontend app and API together by starting the app with the Static Web Ap
308302

309303
---
310304

311-
1. When the CLI processes start, access your app at `http://localhost:4280/`. Notice how the page calls the API and displays its output, `Hello from the API`.
305+
1. When the CLI processes start, access your app at [http://localhost:4280/](http://localhost:4280/). Notice how the page calls the API and displays its output, `Hello from the API`.
312306

313307
1. To stop the CLI, type <kbd>Ctrl + C</kbd>.
314308

@@ -329,7 +323,7 @@ To publish changes to your static web app in Azure, commit and push your code to
329323

330324
1. Select the **Git: Commit All** command.
331325

332-
1. When prompted for a commit message, enter **add API** and commit all changes to your local git repository.
326+
1. When prompted for a commit message, enter **feat: add API** and commit all changes to your local git repository.
333327

334328
1. Press <kbd>F1</kbd> to open the Command Palette.
335329

0 commit comments

Comments
 (0)