github-actionsblazor-webassemblyazure-deploymentazure-static-web-app

Issue Deploying Blazor WebAssembly App with Domain-Driven Design to Azure Static Web App Using GitHub Actions


I'm encountering an issue while deploying my Blazor WebAssembly application, which follows Domain-Driven Design (DDD) architecture, to Azure Static Web Apps using GitHub Actions. The deployment process fails with the following error message:

"Failed to find a default file in the app artifacts folder (wwwroot). Valid default files: index.html, Index.html."

The error suggests that Azure Static Web Apps is unable to find the required default HTML file (either index.html or Index.html) in the expected folder (wwwroot).

This is my yml file:

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - dev
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - dev

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
          lfs: false
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secret here }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "src/PDANV.Blazor.Client" # App source code path
          api_location: "src/PDANV.HttpApi" # Api source code path - optional
          output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secret here }}
          action: "close"

Project structure

src folder

wwwroot folder

I’ve configured the app_location in my GitHub Actions workflow to point to the root of my Blazor WebAssembly project.

The result was the error previously mentioned.

Any ideas of what I could be doing wrong?

Thanks in advance

Update:

As suggested by one of the answers, I changed the output path to: src/PDANV.Blazor.Client/wwwroot and got the following error:

The app build failed to produce artifact folder: 'src/PDANV.Blazor.Client/wwwroot'. Please ensure this property is configured correctly in your workflow file.

Structure folder


Solution

  • “Failed to find a default file in the app artifacts folder (wwwroot). Valid default files: index.html, Index.html.”

    I got the same error while deploying a sample Blazor WebAssembly application to an Azure Static Web App.

    To resolve the issue, I updated the app_location and output_location in my GitHub Workflow file to match my project structure and make sure thatwwwroot folder contains an index.htm file.

    app_location: "src/Blazor.client/Blazor.client" 
    api_location: "src/Blazor.HttpApi/Blazor.HttpApi" 
    output_location: "wwwroot"
    

    enter image description here

    GitHub Workflow File:

    name: Azure Static Web Apps CI/CD
    on:
      push:
        branches:
          - main
      pull_request:
        types: [opened, synchronize, reopened, closed]
        branches:
          - main
    jobs:
      build_and_deploy_job:
        if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
        runs-on: ubuntu-latest
        name: Build and Deploy Job
        steps:
          - uses: actions/checkout@v3
            with:
              submodules: true
              lfs: false
          - name: Build And Deploy
            id: builddeploy
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SAND_0A1C20F0F }}
              repo_token: ${{ secrets.GITHUB_TOKEN }}         
              app_location: "src/Blazor.client/Blazor.client" 
              api_location: "src/Blazor.HttpApi/Blazor.HttpApi"
              output_location: "wwwroot" 
      close_pull_request_job:
        if: github.event_name == 'pull_request' && github.event.action == 'closed'
        runs-on: ubuntu-latest
        name: Close Pull Request Job
        steps:
          - name: Close Pull Request
            id: closepullrequest
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SAND_0A1C20F0F }}
              action: "close"
    
    

    index.html:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Blazor.client</title>
        <base href="/" />
        <link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css" />
        <link rel="stylesheet" href="css/app.css" />
        <link rel="icon" type="image/png" href="favicon.png" />
        <link href="Blazor.client.styles.css" rel="stylesheet" />
    </head>
    <body>
        <div id="app">
            <svg class="loading-progress">
                <circle r="40%" cx="50%" cy="50%" />
                <circle r="40%" cx="50%" cy="50%" />
            </svg>
            <div class="loading-progress-text"></div>
        </div>
        <div id="blazor-error-ui">
            An unhandled error has occurred.
            <a href="." class="reload">Reload</a>
            <span class="dismiss">🗙</span>
        </div>
        <script src="_framework/blazor.webassembly.js"></script>
    </body>
    </html>
    

    Azure Output:

    enter image description here