Skip to content

Commit 688c143

Browse files
authored
Merge pull request #111413 from aaronpowell/aapowell/assa-gatsby
Gastby tutorial
2 parents 995840c + 3a61954 commit 688c143

File tree

6 files changed

+118
-154
lines changed

6 files changed

+118
-154
lines changed
54.1 KB
Loading
25.4 KB
Loading
59.6 KB
Loading
62.2 KB
Loading
67.5 KB
Loading
Lines changed: 118 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,142 @@
11
---
2-
title: "Tutorial: Publish a Gatsby site to App Service Static Apps"
3-
description: #Required; article description that is displayed in search results.
4-
services: #Required for articles that deal with a service; service slug assigned to your service by ACOM.
2+
title: "Tutorial: Publish a Gatsby site to Azure Static Web Apps"
3+
description: This tutorial shows you how to deploy a Gatsby application to Azure Static Web Apps.
4+
services: static-web-apps
55
author: aaronpowell
6-
ms.service: azure-functions
7-
ms.topic: tutorial
6+
ms.service: static-web-apps
7+
ms.topic: tutorial
88
ms.date: 05/08/2020
99
ms.author: aapowell
1010
---
1111

12-
<!--
13-
Refer to the following guide for more details:
14-
https://review.docs.microsoft.com/en-us/help/contribute/contribute-how-to-mvc-tutorial?branch=master
15-
-->
12+
# Tutorial: Publish a Gatsby site to Azure Static Web Apps
1613

17-
<!---Recommended: Removal all the comments in this template before you sign-off or merge to master.--->
14+
This article demonstrates how to create and deploy a [Gatsby](https://gatsbyjs.org) web application to [Azure Static Web Apps](overview.md). The final result is a new Static Web Apps site (with the associated GitHub Actions) that give you control over how the app is built and published.
1815

19-
# Tutorial: Publish a Gatsby site to App Service Static Apps
16+
In this tutorial, you learn how to:
2017

21-
<!---Required:
22-
Starts with "Tutorial: "
23-
Make the first word following "Tutorial:" a verb.
24-
--->
18+
> [!div class="checklist"]
19+
>
20+
> - Create a Gatsby app
21+
> - Setup an Azure Static Web Apps site
22+
> - Deploy the Gatsby app to Azure
2523
26-
Introductory paragraph.
24+
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
2725

28-
<!---Required:
29-
Lead with a light intro that describes, in customer-friendly language,
30-
what the customer will learn, or do, or accomplish. Answer the
31-
fundamental "why would I want to do this?" question.
32-
--->
26+
## Prerequisites
3327

34-
In this tutorial, you learn how to:
28+
- An Azure account with an active subscription. If you don't have one, you can [create an account for free](https://azure.microsoft.com/free/).
29+
- A GitHub account. If you don't have one, you can [create an account for free](https://github.com/join).
30+
- [Node.js](https://nodejs.org) installed.
3531

36-
> [!div class="checklist"]
37-
> * All tutorials include a list summarizing the steps to completion
38-
> * Each of these bullet points align to a key H2
39-
> * Use these green checkboxes in a tutorial
40-
<!---Required:
41-
The outline of the tutorial should be included in the beginning and at
42-
the end of every tutorial. These will align to the **procedural** H2
43-
headings for the activity. You do not need to include all H2 headings.
44-
Leave out the prerequisites, clean-up resources and next steps--->
45-
46-
If you don't have a <service> subscription, create a free trial account...
47-
<!--- Required, if a free trial account exists
48-
Because tutorials are intended to help new customers use the product or
49-
service to complete a top task, include a link to a free trial before the
50-
first H2, if one exists. You can find listed examples in
51-
[Write tutorials](contribute-how-to-mvc-tutorial.md)
52-
--->
53-
54-
<!---Avoid notes, tips, and important boxes. Readers tend to skip over
55-
them. Better to put that info directly into the article text.--->
32+
## Create a Gatsby App
5633

57-
## Prerequisites
34+
Create a Gatsby app using the Gatsby Command Line Interface (CLI):
5835

59-
- First prerequisite
60-
- Second prerequisite
61-
- Third prerequisite
62-
<!---If you need them, make Prerequisites your first H2 in a tutorial. If
63-
there's something a customer needs to take care of before they start (for
64-
example, creating a VM) it's OK to link to that content before they
65-
begin.--->
66-
67-
## Sign in to <service/product/tool name>
68-
69-
Sign in to the <service> portal.
70-
<!---If you need to sign in to the portal to do the tutorial, this H2 and
71-
link are required.--->
72-
73-
## Procedure 1
74-
75-
<!---Required:
76-
Tutorials are prescriptive and guide the customer through an end-to-end
77-
procedure. Make sure to use specific naming for setting up accounts and
78-
configuring technology.
79-
Don't link off to other content - include whatever the customer needs to
80-
complete the scenario in the article. For example, if the customer needs
81-
to set permissions, include the permissions they need to set, and the
82-
specific settings in the tutorial procedure. Don't send the customer to
83-
another article to read about it.
84-
In a break from tradition, do not link to reference topics in the
85-
procedural part of the tutorial when using cmdlets or code. Provide customers what they need to know in the tutorial to successfully complete
86-
the tutorial.
87-
For portal-based procedures, minimize bullets and numbering.
88-
For the CLI or PowerShell based procedures, don't use bullets or
89-
numbering.
90-
--->
91-
92-
Include a sentence or two to explain only what is needed to complete the
93-
procedure.
94-
95-
1. Step 1 of the procedure
96-
1. Step 2 of the procedure
97-
1. Step 3 of the procedure
98-
99-
<!---Use screenshots but be judicious to maintain a reasonable length.
100-
Make sure screenshots align to the
101-
[current standards](https://review.docs.microsoft.com/help/contribute/contribute-how-to-create-screenshot?branch=master).
102-
If users access your product/service via a web browser the first
103-
screenshot should always include the full browser window in Chrome or
104-
Safari. This is to show users that the portal is browser-based - OS
105-
and browser agnostic.--->
106-
1. Step 4 of the procedure
107-
108-
## Procedure 2
109-
110-
Include a sentence or two to explain only what is needed to complete the procedure.
111-
112-
1. Step 1 of the procedure
113-
1. Step 2 of the procedure
114-
1. Step 3 of the procedure
115-
116-
## Procedure 3
117-
118-
Include a sentence or two to explain only what is needed to complete the
119-
procedure.
120-
<!---Code requires specific formatting. Here are a few useful examples of
121-
commonly used code blocks. Make sure to use the interactive functionality
122-
where possible.
123-
124-
For the CLI or PowerShell based procedures, don't use bullets or
125-
numbering.
126-
--->
127-
128-
Here is an example of a code block for Java:
129-
130-
```java
131-
cluster = Cluster.build(new File("src/remote.yaml")).create();
132-
...
133-
client = cluster.connect();
134-
```
135-
136-
or a code block for Azure CLI:
137-
138-
```azurecli-interactive
139-
az vm create --resource-group myResourceGroup --name myVM --image win2016datacenter --admin-username azureuser --admin-password myPassword12
140-
```
141-
142-
or a code block for Azure PowerShell:
143-
144-
```azurepowershell-interactive
145-
New-AzureRmContainerGroup -ResourceGroupName myResourceGroup -Name mycontainer -Image microsoft/iis:nanoserver -OsType Windows -IpAddressType Public
146-
```
36+
1. Open a terminal
37+
1. Use the [npx](https://www.npmjs.com/package/npx) tool to create a new app with the Gatsby CLI. This may take a few minutes.
14738

39+
```bash
40+
npx gatsby new static-web-app
41+
```
14842

149-
## Clean up resources
43+
1. Navigate to the newly created app
15044

151-
If you're not going to continue to use this application, delete
152-
<resources> with the following steps:
45+
```bash
46+
cd static-web-app
47+
```
15348

154-
1. From the left-hand menu...
155-
2. ...click Delete, type...and then click Delete
49+
1. Initialize a git repo
15650

157-
<!---Required:
158-
To avoid any costs associated with following the tutorial procedure, a
159-
Clean up resources (H2) should come just before Next steps (H2)
160-
--->
51+
```bash
52+
git init
53+
git add -A
54+
git commit -m "initial commit"
55+
```
16156

162-
## Next steps
57+
## Push your application to GitHub
58+
59+
You need to have a repository on GitHub to create a new Azure Static Web Apps resource.
60+
61+
1. Create a blank GitHub repository (don't create a README) from [https://github.com/new](https://github.com/new) named **gatsby-static-web-app**.
62+
63+
1. Next, add the GitHub repository you just created as a remote to your local repo. Make sure to add your GitHub username in place of the `<YOUR_USER_NAME>` placeholder in the following command.
64+
65+
```bash
66+
git remote add origin https://github.com/<YOUR_USER_NAME>/gatsby-static-web-app
67+
```
68+
69+
1. Push your local repository up to GitHub.
70+
71+
```bash
72+
git push --set-upstream origin master
73+
```
74+
75+
## Deploy your web app
76+
77+
The following steps show you how to create a new static site app and deploy it to a production environment.
78+
79+
### Create the application
80+
81+
1. Navigate to the [Azure portal](https://portal.azure.com).
82+
83+
1. Select **Create a Resource** and search for **Static Web Apps**.
84+
85+
:::image type="content" source="./media/static-web-apps-publish-gatsby/create-in-portal.png" alt-text="Create a Static Web Apps (Preview) in the portal":::
86+
87+
1. For _Subscription_, accept the subscription that is listed or select a new one from the drop-down list.
88+
89+
1. In _Resource group_, select **New**. In _New resource group name_, enter **gatsby-static-web-app** and select **OK**.
90+
91+
1. Next, provide a globally unique name for your app in the **Name** box. Valid characters include `a-z`, `A-Z`, `0-9` and `-`. This value is used as the URL prefix for your Static Web App in the format of `https://<YOUR_APP_NAME>.azurestaticapps.net`.
92+
93+
1. For _Region_, select an available region close to you.
16394

164-
<!-- Uncomment this block and add the appropriate link
95+
1. For _SKU_, select **Free**.
96+
97+
:::image type="content" source="./media/static-web-apps-publish-gatsby/basic-app-details.png" alt-text="Details filled out":::
98+
99+
1. Click the **Sign in with GitHub** button.
100+
101+
1. Select the **Organization** under which you created the repository.
102+
103+
1. Select the **gatsby-static-web-app** as the _Repository_ .
104+
105+
1. For the _Branch_ select **master**.
106+
107+
:::image type="content" source="./media/static-web-apps-publish-gatsby/completed-github-info.png" alt-text="Completed GitHub information":::
108+
109+
### Build
110+
111+
Next, add configuration settings that the build process uses to build your app.
112+
113+
1. Click the **Next: Build >** button to edit the build configuration
114+
115+
1. To configure the settings of the step in GitHub Actions, set the _App location_ to **/**.
116+
117+
1. Set _App artifact location_ to **public**.
118+
119+
A value for _API location_ isn't necessary as you aren't deploying an API at the moment.
120+
121+
:::image type="content" source="./media/static-web-apps-publish-gatsby/build-details.png" alt-text="Build Settings":::
122+
123+
### Review and create
124+
125+
1. Click the **Review + Create** button to verify the details are all correct.
126+
127+
1. Click **Create** to start the creation of the App Service Static Web App and provision a GitHub Action for deployment.
128+
129+
1. Once the deployment completes click, **Go to resource**.
130+
131+
1. On the resource screen, click the _URL_ link to open your deployed application. You may need to wait a minute or two for the GitHub Action to complete.
132+
133+
:::image type="content" source="./media/static-web-apps-publish-gatsby/deployed-app.png" alt-text="Deployed application":::
134+
135+
## Clean up resources
136+
137+
[!INCLUDE [static-web-apps-cleanup-resource](../../includes/static-web-apps-cleanup-resource.md)]
138+
139+
## Next steps
165140

166141
> [!div class="nextstepaction"]
167-
> [Next steps button](contribute-get-started-mvc.md)
168-
169-
-->
170-
171-
<!--- Required:
172-
Tutorials should always have a Next steps H2 that points to the next
173-
logical tutorial in a series, or, if there are no other tutorials, to
174-
some other cool thing the customer can do. A single link in the blue box
175-
format should direct the customer to the next article - and you can
176-
shorten the title in the boxes if the original one doesn't fit.
177-
Do not use a "More info section" or a "Resources section" or a "See also
178-
section". --->
142+
> [Add a custom domain](custom-domain.md)

0 commit comments

Comments
 (0)