How to Host and Deploy Blazor WebAssembly with Netlify and Azure Pipelines

Build a standalone Blazor WebAssembly app in Azure Pipelines and deploy its static publish output to Netlify with secure CI variables.

Article guideContents, topics, tags, and RSS
Get new notes via RSS

A standalone Blazor WebAssembly application can run from any static host. The build produces HTML, CSS, JavaScript, WebAssembly, and .NET assemblies; Netlify only needs the contents of the published wwwroot directory.

This guide uses Azure Pipelines to publish the app and Netlify CLI to deploy it. The steps follow the current Blazor deployment, Azure Pipelines for .NET, and Netlify CLI documentation.

Create or connect the Netlify project

You can create a project in the Netlify dashboard or with a local CLI installation:

npm install --save-dev netlify-cli
npx netlify login
npx netlify sites:create

Record the Netlify project ID. Then create a personal access token under your Netlify user applications. In Azure Pipelines, add both values as variables:

  • NETLIFY_SITE_ID: the Netlify project ID.
  • NETLIFY_AUTH_TOKEN: the personal access token, marked as secret.

Do not put the token in the repository or echo it from a pipeline step.

Add the single-page application rewrite

Client-side Blazor routes need to fall back to index.html when someone opens a deep link directly. Add a file named _redirects to the Blazor project’s wwwroot directory:

/*    /index.html    200

Netlify copies this file with the rest of the publish output and applies it as a rewrite.

Build and deploy in Azure Pipelines

The following pipeline targets the current .NET SDK. Change 10.x and the project path to match your supported application. The important boundary is the publish output: deploy wwwroot, not the source project.

trigger:
  - main

pool:
  vmImage: ubuntu-latest

variables:
  buildConfiguration: Release
  publishDirectory: $(Build.ArtifactStagingDirectory)/publish

steps:
  - task: UseDotNet@2
    displayName: Use .NET SDK
    inputs:
      packageType: sdk
      version: 10.x

  - task: DotNetCoreCLI@2
    displayName: Publish Blazor WebAssembly
    inputs:
      command: publish
      publishWebProjects: false
      projects: src/MyBlazorApp/MyBlazorApp.csproj
      arguments: --configuration $(buildConfiguration) --output $(publishDirectory)
      zipAfterPublish: false
      modifyOutputPath: false

  - script: npm install --no-save netlify-cli
    displayName: Install Netlify CLI

  - script: >
      npx netlify deploy
      --prod
      --dir "$(publishDirectory)/wwwroot"
      --site "$(NETLIFY_SITE_ID)"
      --auth "$(NETLIFY_AUTH_TOKEN)"
    displayName: Deploy to Netlify
    env:
      NETLIFY_SITE_ID: $(NETLIFY_SITE_ID)
      NETLIFY_AUTH_TOKEN: $(NETLIFY_AUTH_TOKEN)

If your solution publishes several projects, point projects at the standalone Blazor project and inspect the publish artifact once before deploying. The expected directory contains index.html, _framework, and your static assets.

Verify the deployment

After the first deployment:

  1. Open the home page and one client-side route directly.
  2. Reload the client-side route to confirm the rewrite works.
  3. Check the browser network panel for missing files under _framework.
  4. Rotate the Netlify token if it was ever printed or committed.

The original sample repository remains available at zarxor/Blazor.NetlifyDeploy, but its pinned package and SDK versions are historical. Use the pipeline above as the current reference.

Johan Boström smiling in a navy jacket and white shirt.
Author portrait

About the author

Johan Boström

Technology leader · Solution architect · Developer

My primary work is leading developers and working as a solution architect. I still develop when hands-on work helps the team or the solution.

I mainly work across systems, integrations, and AI. This archive keeps the practical details, lessons, and implementation notes worth finding again.