I try to deploy my static webapp with a managed function to Azure but the function deployment always fails and I don't know why. I used Node v20 and v18. I downgraded my libraries. I tried every structure i found online.

I currently only use a very simple function to test, but even that fails. Thats my index.js:
app.setup({
enableHttpStream: true,
});
// Add your function definition
app.http("assessmentStoring", {
methods: ["GET", "POST"],
authLevel: "anonymous",
handler: async (request, context) => {
// Your function logic from assessmentStoring.js
return { status: 200, body: "Hello from Azure Functions!" };
},
});
Thats my function.json:
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["get", "post"]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"scriptFile": "index.js"
}
Thats my action yml:
name: Azure Static Web Apps CI/CD
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [main]
env:
AZURE_FUNCTIONS_ENVIRONMENT: Production
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@v4
with:
submodules: true
lfs: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.18.0"
cache: "npm"
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.TOKEN}}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"
api_location: "api"
output_location: "out"
skip_api_build: false
skip_app_build: false
env:
IS_STATIC_EXPORT: true
AZURE_FUNCTIONS_ENVIRONMENT: Production
NEXT_TELEMETRY_DISABLED: 1
NEXT_BUILD_CACHE: "true"
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.TOKEN}}
action: "close"
app_location: "."
Thats my package.json:
{
"name": "api",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "func start",
"test": "echo \"No tests yet...\""
},
"dependencies": {
"@azure/functions": "^4.0.0"
},
"main": "src/index.js",
"type": "module",
"engines": {
"node": "18.x"
}
}
And thats my host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
Can anybody tell me why it wont work? I am desperate :c
