Azure is Microsoft’s native hosting platform, with a variety of services including serverless features and static website hosting through Azure Static Web Apps. The Azure Static Web Apps service also includes support for a built-in CDN, authentication, continuous deployment, and HTTPS. In order to utilize Azure as your static site host, your Gatsby site needs to be available in a source repository.
After signing in to Azure, search for the Static Web Apps service, select it, and click Add to add a new static site. Then, configure your new Azure application and link it to your source repository by entering the required project details (your Azure subscription and an Azure resource group) and Static Web Apps configuration (name and region) before authenticating with your source control provider. Identify the source repository and the code branch.
Azure will then bring you to a build configuration wizard, which will allow you to specify the following build settings:
- App location. This can be left blank if your Gatsby project is located at the root of your source repository. If the repository includes both frontend and backend code in separate directories, identify only the Gatsby site’s directory.
- API location. This can be left blank or filled in with the location of a backend API; the default value is
api
. - App artifact location. This field should be filled in with the directory containing the build artifacts generated by each Azure build, such as public, which is Gatsby’s default public directory.
Once your application is created in Azure, the Static Web Apps service will initiate a deployment for you automatically, after which you can view your site. With the GitHub Action Azure creates on your behalf in the GitHub repository, Azure will notify you once the deployment is ready for review. This process takes several minutes.
Leave a Reply