Build and deploy to Azure Static Web Apps
Up to this point we have focused on authoring our Gatsby app using React, GraphQL and plugins. The next step once you are done authoring is to build your application. After that you are able to deploy to any web server or hosting service that can serve static files.
Build your app
Creating the build
Azure Static Web Apps
Static Web Apps is an Azure service that allows you to take some static files and serve them from the cloud. What you deploy is not a deployment package but just a set of static files. This is a good fit for Gatsby as what Gatsby ends up producing from a build is static files.
Speaking of build, the service actually does the build step for you so there's no need to build anything up front. How it does this is by locating the
build command in the
package.json of the Gatsby project. All you need to do is put your project in a GitHub repository.
Azure Static Web Apps is currently in preview.
Currently your code sits in a directory on your machine, so you'll need to do a few things to deploy Azure:
- Initialize a Git repository: Right now, your Gatsby project is in a directory that hasn't been initialized as a Git repository.
- Create a GitHub repository and push to it: Once you initialize your repository, you'll push it to GitHub.
- Create an Azure Static Web Apps instance: When you use the Azure portal to create an Azure Static Web Apps instance, you'll provide the URL to your GitHub repository and the name for the sub directory where the static files live in your project. In Gatsby's case, this directory is called