azure static web app not starting after successful build and deployment

Leonard Kong 1 Reputation point
2023-09-04T13:49:26.39+00:00

Although my action, azure-static-web-apps-agreeable-sky-odd2be310.yml, appears to build and deploy correctly (green check), my app does not load. If I open the Build and Deploy job, and look at the Build and Deploy section I see:

Try to validate location at: '/github/workspace/FoodTruckNotification/FoodTruckNotification.Wasm/bin/Release/net7.0/dist'.
App Directory Location: 'FoodTruckNotification/FoodTruckNotification.Wasm/bin/Release/net7.0/dist' was found.
Try to validate location at: '/github/workspace/swa-db-connections'.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
Oryx will build app with the following custom override command: dotnet build
---Oryx build logs---


Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20230717.2, Commit: 174f4287104c15e6f9ea3a4cf6e9f80accba3cf3, ReleaseTagName: 20230717.2

Build Operation ID: 1074f932d13cc62b
OS Type           : bullseye
Image Type        : jamstack

Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.


---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
Finished building app with Oryx
Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.
No Api directory specified. Azure Functions will not be created.
Either no Api directory was specified, or the specified directory was not found. Azure Functions will not be created.
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0600334(s)
Status: Succeeded. Time: 15.1100465(s)
Deployment Complete :)
Visit your site at: https://agreeable-sky-0dd2be310-63.centralus.3.azurestaticapps.net
Unexectedly failed to add GitHub comment.
Thanks for using Azure Static Web Apps!
Exiting

I have looked at the online help and made adjustments to my action, including removing the api_location and adding the app_build_command to the build and deploy section.

name: Azure Static Web Apps CI/CD

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

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
      - name: Setup dotnet
        uses: actions/setup-dotnet@v3.2.0
        with: 
          dotnet-version: '7.0.100'
      - run: |
          cd FoodTruckNotification/FoodTruckNotification.Wasm
          dotnet restore
          dotnet build -c Release    
      - 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_AGREEABLE_SKY_0DD2BE310 }}
          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: "FoodTruckNotification/FoodTruckNotification.Wasm/bin/Release/net7.0/dist" # App source code path
          ### api_location: "" # Api source code path - optional
          output_location: "FoodTruckNotification/FoodTruckNotification.Wasm/bin/Release/net7.0/publish/wwwroot" # Built app content directory - optional
          app_build_command: "dotnet build"
          ###### 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: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AGREEABLE_SKY_0DD2BE310 }}
          action: "close"

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
903 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 27,771 Reputation points Microsoft Employee
    2023-09-05T22:46:20.48+00:00

    Hi @Leonard Kong

    In looking at your yaml, it almost seems like you're building a Blazor server app. If you created your project using Visual Studio, and selected the ASP.NET Server hosting, then this may be the issue.

    User's image

    If you are, then you need to set to the app_location to the folder of the client app; using the example above, it would be /BlazorApp1.Client. Your app should start up, but if you're leveraging elements from the shared project, you'll likely run into reference issues. If that's the case, then you'll need to deploy your project to an app service as the Static Web App is client-side hosting.


    EDIT 13 Sept 2023: We determined that there was nothing wrong with your yaml configuration. Your Uno landing page was displaying but your app wasn't available. You changed your yaml to deploy -c Debug configuration your application ran as expected. Upon further investigation, you discovered that a shared folder was missing from your -c Release configuration.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.