You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Static Web Apps部署Retype应用遇大小限制问题咨询

问题描述

我正尝试通过GitHub Actions将Retype应用部署到Azure Static Web Apps,Retype是一款从Markdown文件生成网站的工具,但部署时出现以下错误:

函数内容过大。此Static Web App的限制为104857600字节。

我检查了存放Retype构建输出的wwwroot文件夹,大小约为50MB(Windows资源管理器显示),整个仓库大小为90MB。我查阅了Azure Static Web Apps的配额文档,标准计划的单应用最大大小为250MB,而我正使用该计划。

因此我有两个问题:

  1. 我是否可以按照文档所述使用250MB的配额?是否存在我忽略或误解的点导致实际限制为100MB?
  2. 若可使用250MB配额,该如何实现?

我已尝试部分解决方案(如删除缓存文件夹、使用打包工具)但无效,且不确定如何应用针对Next.js的方案。

附.github/workflows下的两个yml文件代码:

retype-action.yml

build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    needs: publish
    name: Build and Deploy to Azure Static Web Apps
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.[AZURE SECRET] }}
          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: "/wwwroot/" # App source code path
          api_location: "/" # Api source code path - optional
          output_location: "" # Built app content directory - optional
          app_build_command: 'npm run build-ui-prod'
          api_build_command: 'npm run build-api-prod'
          ###### 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 SECRET] }}
          action: "close"

azure...[secret].yml

name: Azure Static Web Apps CI/CD

on:
  workflow_dispatch:
  push:
    branches:
      - published

  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - published

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.[AZURE SECRET] }}
          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: "/wwwroot/" # App source code path
          api_location: "/" # Api source code path - optional
          output_location: "" # Built app content directory - optional
          app_build_command: 'npm run build-ui-prod'
          api_build_command: 'npm run build-api-prod'
          ###### 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 SECRET] }}
          action: "close"

参考方案中提到的Next.js配置无效,该方案为:

app_build_command: 'npm run build'
api_build_command: 'rm -rf ./node_modules/@next/swc-* && rm -rf ./.next/cache'
解决方案

问题1:是否能使用250MB配额?

标准计划的Azure Static Web Apps确实支持单应用最大250MB的静态内容存储配额,但你遇到的100MB限制是函数应用的代码包大小限制——Azure Static Web Apps的后端函数(即使未显式配置)默认受限于函数应用的代码包上限(当前为100MB)。

你当前工作流中api_location设为"/",会导致部署工具将整个根目录的内容(包括node_modules、仓库源码等)作为函数应用代码上传,总大小远超100MB,触发了这个错误,而非静态内容的250MB配额限制。

问题2:如何使用250MB配额并解决部署错误?

核心是修正工作流配置,避免上传无关内容作为函数代码,同时确保静态内容正确部署:

  1. 修正api_location配置
    如果你的应用没有后端API函数,直接将api_location设为空字符串:

    api_location: ""
    

    这样部署工具会跳过函数应用的上传,只处理静态内容,此时静态内容的大小限制就是标准计划的250MB。

  2. 调整构建路径配置
    确认app_location指向Retype的构建输出目录(当前设为"/wwwroot/"),如果wwwroot是源码目录,需将output_location指定为Retype构建后生成文件的子目录(比如"dist"或"build",根据npm run build-ui-prod的实际输出路径调整)。

  3. 清理冗余文件
    在构建命令后添加清理步骤,删除wwwroot中不需要部署的文件(如缓存、临时构建文件):
    修改app_build_command为:

    app_build_command: 'npm run build-ui-prod && rm -rf wwwroot/cache wwwroot/temp'
    

    根据实际存在的冗余目录调整删除路径。

  4. 合并重复工作流
    你当前有两个功能重复的工作流文件,建议保留一个即可,避免触发重复部署造成资源浪费。

内容的提问来源于stack exchange,提问作者PainfulTruth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 15:13:18