Azure静态Web应用托管函数部署失败求助
Azure静态Web应用托管函数部署失败求助
我现在快急死了😭,尝试把带托管函数的静态Web应用部署到Azure,但函数部署一直失败,完全找不到原因。我已经试过这些操作了:
- 切换过Node.js v20和v18版本
- 降级了依赖库
- 试过网上能找到的各种项目结构
- 现在已经把函数简化到最基础的测试版本了,但还是部署失败
下面是我的各个配置文件,有没有大佬能帮我看看哪里出问题了?
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!" }; }, });
function.json
{ "bindings": [ { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "req", "methods": ["get", "post"] }, { "type": "http", "direction": "out", "name": "res" } ], "scriptFile": "index.js" }
GitHub Actions 配置 (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: "."
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" } }
host.json
{ "version": "2.0", "logging": { "applicationInsights": { "samplingSettings": { "isEnabled": true, "excludedTypes": "Request" } } }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.*, 5.0.0)" } }
内容来源于stack exchange
相关产品推荐
相关产品推荐

