This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Azure Static Web Apps publishes a website to a production environment by building apps from a GitHub repository supported by a serverless backend. The following tutorial shows how to deploy C# Blazor WebAssembly app that displays weather data returned by a serverless API.
Note
For steps to deploy a Blazor app via Visual Studio, seeDeploy a Blazor app on Azure Static Web Apps.
This article uses a GitHub template repository to make it easy for you to get started. The template features a starter app that you can deploy to Azure Static Web Apps.
Now that the repository is created, create a static web app from the Azure portal.
Go to theAzure portal.
SelectCreate a Resource.
Search forStatic Web Apps.
SelectStatic Web App.
SelectCreate.
On theBasics tab, enter the following values.
| Property | Value |
|---|---|
| Subscription | Your Azure subscription name. |
| Resource group | my-blazor-group |
| Name | my-first-static-blazor-app |
| Plan type | Free |
| Region for Azure Functions API and staging environments | Select a region closest to you. |
| Source | GitHub |
SelectSign in with GitHub and authenticate with GitHub, if you're prompted.
Enter the following GitHub values.
| Property | Value |
|---|---|
| Organization | Select your desired GitHub organization. |
| Repository | Selectmy-first-static-blazor-app. |
| Branch | Selectmain. |
Note
If you don't see any repositories, you may need to authorize Azure Static Web Apps on GitHub. Then browse to your GitHub repository and go toSettings > Applications > Authorized OAuth Apps, selectAzure Static Web Apps, and then selectGrant. For organization repositories, you must be an owner of the organization to grant the permissions.
In theBuild Details section, selectBlazor from theBuild Presets drop-down and the following values are populated.
| Property | Value | Description |
|---|---|---|
| App location | Client | Folder containing the Blazor WebAssembly app |
| API location | Api | Folder containing the Azure Functions app |
| Output location | wwwroot | Folder in the build output containing the published Blazor WebAssembly application |
SelectReview + Create to verify the details are all correct.
SelectCreate to start the creation of the static web app and provision a GitHub Actions for deployment.
Once the deployment is completed, selectGo to resource.
SelectGo to resource.

There are two aspects to deploying a static app. The first provisions the underlying Azure resources that make up your app. The second is a GitHub Actions workflow that builds and publishes your application.
Before you can go to your new static web app, the deployment build must first finish running.
The Static Web Apps overview window displays a series of links that help you interact with your web app.
Select the banner that says,Click here to check the status of your GitHub Actions runs to see the GitHub Actions running against your repository. Once you verify the deployment job is complete, then you can go to your website via the generated URL.

Once GitHub Actions workflow is complete, you can select theURL link to open the website in new tab.

Together, the following projects make up the parts required to create a Blazor WebAssembly application running in the browser supported by an Azure Functions API backend.
| Visual Studio project | Description |
|---|---|
| Api | The C# Azure Functions application implements the API endpoint that provides weather information to the Blazor WebAssembly app. TheWeatherForecastFunction returns an array ofWeatherForecast objects. |
| Client | The front-end Blazor WebAssembly project. Afallback route is implemented to ensure client-side routing is functional. |
| Shared | Holds common classes referenced by both the Api and Client projects, which allow data to flow from API endpoint to the front-end web app. TheWeatherForecast class is shared among both apps. |
Blazor static web app
The app exposes URLs like/counter and/fetchdata, which map to specific routes of the app. Since this app is implemented as a single page, each route is served theindex.html file. To ensure that requests for any path returnindex.html, afallback route gets implemented in thestaticwebapp.config.json file found in the client project's root folder.
{ "navigationFallback": { "rewrite": "/index.html" }}The JSON configuration ensures that requests to any route in the app return theindex.html page.
If you're not going to use this application, you can delete the Azure Static Web Apps instance through the following steps:
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?