Building your first Azure Static Web App
One of the more interesting running Web outgrowth concepts is
With Jamstack there are no dependencies on app servers or technologies like node.js. Instead theres only measure markup that can be built and tested anywhere and pushed to your servers as you update both full and code. This measure works well with present_ devops-driven build processes_ fitting in with CI_CD continuous integration_continuous liberatey platforms such as GitHub_ where collaborative outgrowth can happen in code memberes precedently pull requests populate a deployment member and an automated deployment to your site host.
That loosely coupled measure makes a lot of perception when youre thinking almost adding front ends to cloud-native applications. Both front end and back end can layer independently_ using low-latency metropolitan full liberatey to cache markup near users_ prompt to take gain of those CDN platforms cache tools to liberate Web applications to users without having to spin up multiple servers. If youre using a labor such as Azure_ the measure can propose expressive cost savings_ as well as lessen the lag between requesting and spinning up a host VM and liberateing a response. As fast as Azure can be_ its frequently quiet too slow to keep a mannerer occupied.
Introducing Azure Static Web Apps
Build 2020 saw
Microsoft unveil its own platform for supporting Jamstack-style applications: Azure Static Web Apps. Available in preview_ it brings unitedly GitHub_ Azure App Service_ and Azure Functions in a one workflow_ with a Visual Studio Code plug-in to drive outgrowth and deployment.
At the core of the Azure Static Web Apps workflow are
GitHub Actions_ with a deployment action automatically formd when you link your application repository to Azure. This action monitors a specific member_ and when commits are made to the member it automatically runs a build and deploys the app to Azure. The same process runs when you merge a pull request. <_aside>
You need both GitHub and Azure accounts to get started. Once these are set up_ form a repository for your site. GitHub provides advantageous templates for ordinary static Web application frameworks_ including Angular_ React_ and Vue. Use these templates to set up scaffolding for a site that can be used to build an app. Repositories can be cloned to local outgrowth devices_ giving developers approach to their common toolchain.
Building your leading static Web app
Once you have a repository for your app with some code in locate_ go to the Azure Portal and form a new Static Web App. You can add it to an existing subscription or use a free test_ creating a new resource cluster or working with an existing one_ giving your app a name and choosing a country. Next_ sign in to your GitHub account in Azure to connect your repository. Choose the repository and member you want to use. You can now form your Static Web App. In the gate_ configure your app settings_ including the build settings.
Once thats all prompt_ review your settings and form the app. You can change settings by editing the workflow file that is formd as part of the setup process. Initial setup should be very fast_ with details of the site URL in the resource details.
With your app configured in both Azure and GitHub_ the Azure Portal will enlighten you that it has not accepted any full yet and to check the status of your GitHub Actions. This link takes you back to your GitHub repository and the workflow that setting up your app has installed. When your code is complete and prompt to deploy_ run the workflow to build and deploy your site.
Adding API support with Azure Functions
Microsoft has released a preview of
a Visual Studio Code extension for working with Azure Static Web Apps_ though it only works in the preview Insider release at present. It integrates with the rest of the Visual Studio Code Azure tools_ so you only have to log in once to use it. Its a advantageous tool_ especially if youre integrating Azure Functions with your site_ using them to host APIs for your applications and labors. <_aside>
async await<_code> support questioning your API. A question is accepted by the API HTTP end point_ which spins up and runs a Function_ liberateing a response to your application. Youre not limited to Azure Functions with Azure Static Web Apps. You can call any RESTful API and parse the resulting JSON in your code_ in the browser.
Theres an interesting front to this measure that touches another part of Microsofts developer story: Azure Static Web Apps are an excellent way to deploy both PWAs progressive Web apps and WebAssembly apps to users. Both implicate liberateing static full that then executes on a users computer. Using CDNs can expressively increase the extend of an app without needing to invest in expressive infrastructure.
Its easy to see a forthcoming where Visual Studios PWA tooling will automatically configure the appropriate workflow to use both GitHub and Azure Static Web Apps_ going from editor to deployment in a few clicks of the mouse.