scottkuhl / BlazorStaticWebApp

Blazor Azure Static Web App Example
2 stars 0 forks source link

Azure Static Web App

This template is an example and starting point for creating a Azure Static Web App based on Blazor. It goes further than the Blazor Starter provided by Microsoft. The demo uses a basic movie list viewer with a separate lazy loaded area for administration.

TO DO

Azure

  1. Create an Azure Storage account.

  2. Create an Azure Cosmos DB account.

  3. Create an Azure Static Web App and connect it to your new repository.

  4. Update the settings in your new Azure SWA to include the storage and database connection strings. The names for these values are in the local.settings.json file in the API project.

Project Changes

  1. Update this README (title, description, user experience).

  2. Rename the solution and all instances of the application name.

  3. Use custom app icons and images.

  4. Update the privacy policy page.

Tips to Reduce Complexity

  1. Consider replacing the Resource file usage with plain text if you are only going to support one language.

  2. Remove the Lazy Loaded assemblies if the application is not large.

Production Ready Apps

Consider the following to make you application production ready:

  1. Add support channels (Discord, Email, GitHub Discussions, Reddit, Report Abuse).

  2. Add revenue (Ads, Affiliate Links, Paid Accounts, Patreon, Merchandise, Revenue Cat).

  3. Add Help (Wiki, Tango).

  4. Add communication channels (Blog, Newsletter).

Getting Started

  1. Install the latest version of Visual Studio.

  2. Setup your workstation to develop with Blazor. You will also need the .NET WebAssembly build tools optional component.

  3. Add the Azure development workload to Visual Studio.

  4. Install the Azure Static Web Apps CLI. This will launch automatically when the project is opened using the Command Task Runner extension.

  5. Install the Azure Cosmos DB Emulator. This will launch automatically if it is not already running when the project is opened using the Command Task Runner extension.

  6. Install the Markdown Editor extension. You can use this to preview markdown files like this one.

  7. Install the Command Task Runner (64-bit) extension.

  8. Install the CodeMaid extension.

  9. Enable Run Code Cleanup profile on Save in Text Editor > Code Cleanup. The clean up profile should have all options applied. Unfortunately at this time, these options can't be stored in a solution.

Optional: Setup Windows Terminal to close the process exits, fails or crashes instead of closing only when the process exits successfully. This will close the Azure Functions window when you stop debugging.

Visual Studio 2022

Once you clone the project, open the solution in Visual Studio 2022 and follow these steps:

  1. Right-click on the solution and select Set Startup Projects....

  2. Select Multiple startup projects and set the following actions for each project:

    • Api - Start
    • Client - Start
    • Shared - None
  3. Press F5 to launch both the client application and the Functions API app.

Clean Code Rules

  1. CodeMaid - The solution folder contains a basic configuration for it that will automatically apply setting on save.

  2. Roslynator - A extended collection of Rosyln analyzers is included as a NuGet package on all projects.

  3. AsyncFixer - A NuGet package included on all projects that finds and corrects common misuses of async/await.

  4. A starting .editorconfig file with minimal rule changes is included.

  5. Code styles are enforced on build.

  6. Code Cleanup on Save - Use this extension in Visual Studio to apply code cleanup rules on every save.

  7. Changes should not be committed with unresolved compiler Errors, Warning or Messages.

  8. Razor components should use code behind files.

User Experience

EXAMPLE

Architecture

Api

Client

Shared

Reference

These references are presented in a logical order for review from start to finish for gathering a deeper understanding of the code base. There is an assumption that you are already familiar with C# and ASP.NET Core.

Books & Series

Articles & Videos

Documentation

Other