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
- 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"
- 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
- 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.