Azure Static Web app Github workflow stop working after upgrade api code from .net 6 to .net 8

Zhan Liu 20 Reputation points
2024-10-23T22:34:36.0933333+00:00

I'm running static web app with Azure function as backend. After I upgrade Azure function code from .net 6 to .net 8 and create pull request. The Github action flow simply don't work due to below error.

Is there anyone experiencing the same?

The function language version detected is unsupported or invalid. The following dotnet language versions are valid: 3.1, 6.0. If you are not using Azure Functions, you can skip this check by removing the 'api_location' input from the workflow file.
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
975 questions
{count} votes

Accepted answer
  1. Shree Hima Bindu Maganti 395 Reputation points Microsoft Vendor
    2024-10-25T16:56:51.7333333+00:00

    Hi @Zhan Liu ,

    Welcome to the Microsoft Q&A Platform!
    The error message you’re seeing is due to the fact that the GitHub Actions runner for Azure Static Web Apps doesn’t currently support .NET 8 for Azure Functions in the api_location.
    The workflow is set to detect only specific supported versions (3.1 and 6.0), so .NET 8 triggers the "unsupported or invalid" language version error. Here are a few options to address it:

    Downgrade to .NET 6

    • Revert your Azure Function code to .NET 6.
    • This ensures compatibility with the current GitHub Actions workflow
    1. Remove api_location from Workflow

    Edit your GitHub Actions YAML to remove the api_location line if your API is not critical for deployment:

    - name: Build and deploy app
      uses: Azure/static-web-apps-deploy@v1
      with:
        azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
        app_location: "/"
        # api_location: "api"  <-- Remove or comment out this line
        output_location: "build"
    
    1. Deploy Function App Separately
    • Create a separate GitHub Actions workflow for your Azure Function using .NET 8
      name: Deploy Function App
    on:
      push:
        branches:
          - main
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout code
            uses: actions/checkout@v2
          - name: Set up .NET
            uses: actions/setup-dotnet@v2
            with:
              dotnet-version: '8.0.x'
          - name: Publish to Azure Functions
            run: |
              dotnet publish -c Release -o publish_output
              az functionapp deployment source config-zip --resource-group <YourResourceGroup> --name <YourFunctionAppName> --src publish_output.zip
    
    1. Monitor for Official Support
    • Since .NET 8 is relatively new, it may be officially supported in the GitHub Action soon.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.