Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Azure Static Web Apps with .NET and Blazor

#1
Azure Static Web Apps with .NET and Blazor

aapowell

Aaron

Azure Static Web Apps is a service that automatically builds and deploys full stack web apps from a GitHub repository. Azure Static Web Apps consist of a static web frontend, and an Azure Functions based backend. When you create a Static Web Apps resource, Azure sets up a GitHub Actions workflow in the app’s source code repository that monitors a branch of your choice. Every time you push commits to the watched branch, the GitHub Action automatically builds and deploys your app and its API.

As of today, Azure Static Web Apps now has first-class support for Blazor WebAssembly and .NET Functions in preview, available in all supported regions. This was one of the top user requests since Static Web Apps was announced at Build. You can develop and deploy a frontend and a serverless API written entirely in .NET.

Let’s give it a try!

Getting Started


To help you get started, we’ve created a GitHub repository template, which you can use as a starting point for your own projects.

In GitHub, click on the Use this template button to create a new GitHub repository using the template, providing it a name of your choosing (we’ll use my-blazor-app here) and click Create repository from template.

There are three folders in the template:

  • Client: The Blazor WebAssembly sample application
  • API: A C# Azure Functions API, which the Blazor application will call
  • Shared: A C# class library with a shared data model between the Blazor and Functions application

To run the app locally, start both the API and Client projects. The “Fetch data” page in the Blazor app requests weather forecast data form the backend Function API and display it on the page.

To run the app from the command-line, you’ll need to install the Azure Functions Core Tools for your platform of choice.

Deploying to Static Web Apps


To deploy this app as an Azure Static Web App, log into your Azure account (sign up for a free one here) and search for Static Web Apps.

Static Web Apps in the portal

Click Create, provide a Subscription, Resource Group and name for the application.

Next, sign into GitHub and locate your GitHub repo (my-blazor-app) and select the branch you wish to deploy.

Finally, select Blazor from the Build Presets, which will populate the App location, API location and App artifact location with Client, API and wwwroot. The first and second values are the path within the Git repository to where the project files for the Blazor and Functions app resides, so if you’ve modified the structure of the Git repository, make sure these values are updated to reflect. The third value is the output path that Blazor will compile into and doesn’t need updating.

Azure Static Web App wizard

Complete the wizard and Static Web Apps will create the GitHub Actions workflow file for you and deploy your application to Azure.

gif of Action completing and then going to the portal to open the deployed app

Summary


We started by forking a GitHub repository (but you could’ve also used a project created in Visual Studio/Visual Studio Code/etc.), created a Static Web App in Azure, and it setup a GitHub Actions workflow for us, automatically building and deploying our Blazor and Functions application. We’ve now got a statically hosted application with a serverless backend, ready to scale for our demands.

Additional Resources


To learn more about Blazor WebAssembly and .NET Functions on Static Web Apps, check out the quickstart docs, the Microsoft Learn module, as well as the comprehensive Static Web Apps docs.

Give Feedback


We’re excited to have Blazor WebAssembly and .NET Functions supported by Azure Static Web Apps, and can’t wait to see what you build with them. Let us know what you think by filing an issue on GitHub.



https://www.sickgaming.net/blog/2020/09/...nd-blazor/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Free e-book: Blazor for ASP.NET Web Forms Developers xSicKxBot 0 52 09-11-2020, 02:22 PM
Last Post: xSicKxBot
  Hybrid Blazor apps in the Mobile Blazor Bindings July update xSicKxBot 0 48 09-10-2020, 10:29 PM
Last Post: xSicKxBot
  Announcing Experimental Mobile Blazor Bindings May update xSicKxBot 0 62 09-08-2020, 02:28 PM
Last Post: xSicKxBot
  Hybrid Blazor apps in the Mobile Blazor Bindings July update xSicKxBot 0 122 07-24-2020, 11:57 AM
Last Post: xSicKxBot
  Announcing Experimental Mobile Blazor Bindings May update xSicKxBot 0 145 06-05-2020, 05:00 PM
Last Post: xSicKxBot
  Blazor WebAssembly 3.2.0 now available xSicKxBot 0 155 06-05-2020, 02:10 AM
Last Post: xSicKxBot
  Configuring Azure Services and emulators using Visual Studio xSicKxBot 0 135 06-04-2020, 12:16 PM
Last Post: xSicKxBot
  Blazor WebAssembly 3.2.0 Release Candidate now available xSicKxBot 0 128 06-04-2020, 05:07 AM
Last Post: xSicKxBot
  Blazor WebAssembly 3.2.0 Preview 5 release now available xSicKxBot 0 138 06-03-2020, 10:43 PM
Last Post: xSicKxBot
  Blazor WebAssembly 3.2.0 Preview 4 release now available xSicKxBot 0 132 06-03-2020, 08:20 AM
Last Post: xSicKxBot

Forum Jump:

Become a Patron!
[-]
Upcoming Events

[-]
Latest Threads
(Indie Deal) FREE Ghost Sweeper, ? NBA 2...
Last Post: xSicKxBot
Today 08:16 AM
» Replies: 0
» Views: 3
(Free Game Key) BigFish Game of Your Cho...
Last Post: xSicKxBot
Today 08:16 AM
» Replies: 0
» Views: 4
News - Random: Not Everyone Is Happy Wit...
Last Post: xSicKxBot
Today 08:15 AM
» Replies: 0
» Views: 2
News - Xbox Could Offer Streaming Stick ...
Last Post: xSicKxBot
Today 08:15 AM
» Replies: 0
» Views: 3
microStudio Game Engine Hands-On
Last Post: xSicKxBot
Today 12:22 AM
» Replies: 0
» Views: 4
Fedora - Contribute at the Fedora Test W...
Last Post: xSicKxBot
Today 12:22 AM
» Replies: 0
» Views: 3
News - Review: Pumpkin Jack – The Perfec...
Last Post: xSicKxBot
Today 12:22 AM
» Replies: 0
» Views: 3
News - Marvel's Spider-Man: Miles Morale...
Last Post: xSicKxBot
Today 12:22 AM
» Replies: 0
» Views: 4
[Tut] How to Read a File Line-By-Line an...
Last Post: xSicKxBot
Yesterday 06:12 PM
» Replies: 0
» Views: 3
(Indie Deal) Alien Cat Bundle, RIDE 4 re...
Last Post: xSicKxBot
Yesterday 06:11 PM
» Replies: 0
» Views: 3

[-]
Twitter

[-]
Sponsored
Get the Deal of the Week at RefurBees.com

Copyright © SickGaming.net 2012-2020