Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The content server has rejected the request with: BadRequest 147 Reason: The size of the function content was too large. The limit for this static site is 31457280 bytes. #214

Closed
myaesubi opened this issue Nov 18, 2020 · 33 comments
Labels
enhancement New feature or request Functions

Comments

@myaesubi
Copy link

myaesubi commented Nov 18, 2020

Hi @anthonychu/@annaji-msft,
I am developing the static website that I'm building is based on the Blazor framework.
I have NuGet library that is the bits around 30Mb should be part of the "Api" part. The CI/CD fails with the following error.

The content server has rejected the request with: BadRequest 147 Reason: The size of the function content was too large. The limit for this static site is 31457280 bytes.

Is there any way to fix this, increase the space. any urgency this be done much appreciated.

Thanks in advance,
Mohammad

@jrathgeber
Copy link

Hello. I have the exact same error. Only I am brand new at this and I am only trying to run the tutorial from the static web apps documentation. My app is supper small. It has no content is just 'hello world'. But I don't know what to do to resolve.

image

Attached an image of the error. Experience tells me if we both have the same error and it is very first in the list then maybe a new bug was just introduced. Or maybe we both need to set some configuration somewhere. I have looked around but I don't know what.

@anthonychu
Copy link
Member

@jrathgeber Your app does not have an API, however, the workflow is configured with an API location, which caused the GitHub action to treat your entire app as an Azure Function app and try to deploy it, and it is hitting the API app limit of 30MB. Please change that valve to an empty string and see if that solves the issue.

@jrathgeber
Copy link

It works now. Thank you very much.

@anthonychu
Copy link
Member

@myaesubi Can you let me know if you're still experiencing this problem and if you have more information that you can share about your app, especially the workflow file? Thanks.

@myaesubi
Copy link
Author

Hi @anthonychu
yes. I still have the issue.
Basically, I use a NuGet package to create pdf from html file and that's above 30Mb size. I use the standard work flow that is being picked up when I create Blazor static web app in Azure portal.

I think the quota for Blazor apps should be increased, since they are sitting on the .NET side with .dll files, comparing to Angular JS or other Javascript frameworks.

Thanks,
Mohammad

@anthonychu
Copy link
Member

Just to clarify, our limit for the frontend apps for the current free offering is 250MB. That should be plenty for your Blazor app. You are hitting the limit on the function app, which is currently at 30MB. We plan on increasing this.

If you believe your Blazor app is blocked by the 30MB limit, please share more information and we can help troubleshoot.

@myaesubi
Copy link
Author

Hi Anthony,
you are correct. my limit size is in the API side which is Function apps.
I use DinkToPdf NuGet package which is a wrapper for multiple native libraries for each OS.
The size of those libraries each is above 40Mb.

Here is the link:

What I had to do is workaround is to put the a message to a message queue to be picked up by my pay-as-you-go Function Apps (consumption plan) and generate Pdf with that app service in meantime.

I really wish to have the function app self sufficient for generating the PDF file and eliminate the queue and queue trigger in my app service function app.

Thanks,
Mohammad

@anthonychu
Copy link
Member

Yep. We will be increasing it soon. Thanks for your patience. /cc @annaji-msft

@anthonychu
Copy link
Member

@jrathgeber Do you mind sharing which tutorial you were following? We want to make some updates to make it more clear that the API location should be left empty. Thanks!

@anthonychu anthonychu added enhancement New feature or request Functions labels Nov 22, 2020
@jrathgeber
Copy link

Good morning. I had a look at my history and this what I found. It was 2 weeks ago now.
https://docs.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=react
I remember searching for static web apps on azure to find that. I also wanted to use Azure portal.
However if you click the link to the git hub repo on that page you will find it is a broken link.
Not give up I went the root of that git hub repo and fin https://github.com/staticwebdev/react-basic and was able to get going.
At the bottom of the Microsoft link there is a button for Next Step "Add API" .
I seem to remember at some stage clicking it or even on Azure portal there was an API setting and I might have enabled it.
That is it. I do plan to do the next step and enable the API!.

@anthonychu
Copy link
Member

Thanks @jrathgeber! Just tried it and you are correct that the link (https://github.com/staticwebdev/react-basic/generate) is broken if you are not logged into GitHub. We will update the instructions in the quickstarts and tutorials so it works well whether you are logged in or not. /cc @craigshoemaker @johnpapa

@myaesubi
Copy link
Author

myaesubi commented Dec 8, 2020

Hi @anthonychu,
would you be able to advise a tentative timeline

Yep. We will be increasing it soon. Thanks for your patience. /cc @annaji-msft

@anthonychu could you be able to advise a tentative timeline please. Thanks.

@haojianzong
Copy link

Setting api_location to empty string resolves the issue for me, thanks for the excellent answer.

@miwebst
Copy link
Contributor

miwebst commented May 18, 2021

Closing as bring your own functions serves as a workaround to this.

@miwebst miwebst closed this as completed May 18, 2021
@wbwvos
Copy link

wbwvos commented Jan 20, 2022

I'd like to reopen this thread. I am running into the same issue. I am running into the size limit whilst I only have one function in my api folder. It is a python function and I have about 100 lines of code and I import pandas and sklearn. Changing to the standard tier (instead of the free tier) does not change anything. When I upload my function separately, so not within the webapp, there is no issue. However, I cannot link the separate Function App to the WebApp in the free tier. So can you please advice? I really would like to deploy my webapp and api as a package.

When I zip the api folder myself it ends up being 18MB.

@anthonychu do you perhaps have a suggestion?

image

@hohenp
Copy link

hohenp commented Nov 14, 2022

Having the same issue deploying nextjs. Its a small "hello world"...

image

In the deployment job is set the api_location to an empty string.
api_location: ""

Are there any news on that?

@danielgary
Copy link

Also running into this with the new NextJS Hybrid deployment. I added Prisma to the project and it immediately started throwing this error.

@RaphaelSilv
Copy link

Me too facing the same issue on NextJs deployment, the task I'm using is as follows:

  - deployment: 'DeployStaticwebapp'
    dependsOn: ['Build']
    environment: $(DevopsEnvironment)
    strategy:
      runOnce:
        deploy:
          steps:
          - checkout: 'self'

          - task: AzureStaticWebApp@0
            inputs:
              app_location: '/'
              output_location: 'build'
              azure_static_web_apps_api_token: $(deployment_token)
              app_build_command: npm run build

Note there is no reference to api_location.

@lauhon
Copy link

lauhon commented Nov 18, 2022

Bump, having the same problem. Also without api_location

I did deviate from the tutorial in the docs in so far, that i did not include ‘next export‘.

That can currently not run when internationalized routing is enabled.

@miwebst Should we open a separate ticket for this since this one has already been closed?

@vivekjilla
Copy link

For NextJS Hybrid apps,

  1. To reduce the app size, see if removing the cache folder helps by changing the build script on package.json to something like
    "build": "next build && rm -rf ./.next/cache". More details: Max app size seems different than reported by Oryx #769 (comment)
  2. For the 100MB limit, this is for NextJS Hybrid apps, more details at https://learn.microsoft.com/en-us/azure/static-web-apps/nextjs#unsupported-features-in-preview
  3. We are also working to improve this experience wrt limitations and the messaging in the logs (empty api_location is expected for these apps).

@andrem0
Copy link

andrem0 commented Nov 29, 2022

Same problem with NextJS hybrid here as well. I have tried to follow your suggestions @vivekjilla, but it doesn't solve the issue. The devops task is building both app and api, even though the api_location is empty string. The documentation is obviously also not good enough. Please fix this as soon as possible. If not able to fix it, please consider increasing the max size.

Looking forward to your swift response.

@saicoder
Copy link

saicoder commented Dec 3, 2022

We are facing the same problem with NextJS. Our .next folder after the build is under 2.5MB.

@gzSupertramp
Copy link

gzSupertramp commented Dec 4, 2022

I am having exactly the same problem here while trying to create a hybrid Next.js website on Azure Static Web Apps.

image
image

It is a very lightweight landing page with one extremely light API page.

Did anyone find a workaround?

@vivekjilla
Copy link

@saicoder @gzSupertramp if .next is small, the node_modules folder could be taking up the space, it's needed for the hybrid support. Can you see if you can remove any dependencies that are not needed by your app from the package.json.

We're working on improving this experience, but unfortunately we're not aware of any workaround as of today. Apologies for the inconvenience.

@saicoder
Copy link

saicoder commented Dec 5, 2022

Thanks @vivekjilla. No, it's a plain Next.js app with only chakra-UI as a dependency. My node_modules is 230MB. Next.JS and TypeScript alone take over 187MB.

The only way currently is to export the Next.JS app as a static website without SSR.

@vivekjilla
Copy link

@saicoder Can you please try moving the TypeScript to devDependencies in the package.json and see if it helps.

@saicoder
Copy link

saicoder commented Dec 5, 2022

I've moved most of the dependencies to dev dependencies, and it did the trick. Thanks @vivekjilla

Just one side note, it would be useful that build log shows the final zip size.

@andrem0
Copy link

andrem0 commented Dec 5, 2022

We were finally able to solve this as well in the following way:

  • Set "output" in next.config.js to "standalone"
  • Run AzureStaticWebApp@0 in pipeline with following config:
- task: AzureStaticWebApp@0
    displayName: Deploy static web app (Next.js)
    inputs:
      app_location: '/'
      verbose: true
      azure_static_web_apps_api_token: XYZ
      app_build_command: 'yarn run build'
      api_build_command: 'rm -rf $SOURCE_DIR/node_modules/@next/swc-* && rm -rf $SOURCE_DIR/.next/cache'

This way, Oryx seems to find the standalone folder for the app on its own, being able to create the function app.

A permanent fix and better DevEx is definitely needed here anyways.

@plasticmik
Copy link

I have a static web app built with nextjs that doesn't use getStaticProps/getStaticPaths, neither SSR. It's a Redux RTK query base app that has some dynamic API calls in some pages that I use to populate form fields and submit them.
I'm deploying on an Azure static web app and I was having this error message:

The content server has rejected the request with: BadRequest Reason: The size of the function content was too large. The limit for this Static Web App is 104857600 bytes.

So, after an entire morning spent looking for a solution I was able to overcome the problem by:

  1. update the package.json with the 'next export' command right after 'next build':
"scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start",
    "lint": "next lint"
  },
  1. disabled the image optimization functionality in the next.config.js file:
images: {
  unoptimized: true,
}
  1. Add the output directory path ("out" generated by the build and export command) to the azure workflow file:
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "out" # Built app content directory - optional

Hope this helps someone 👋🏻

@dan-eversen
Copy link

dan-eversen commented Dec 15, 2022

Confirming that this is still an issue. Removing the cache is the only thing that works. I have no idea why Oryx even attempts to perform api bundling when I have no api folder listed in the yaml. I would say that's a certified bug, since it should be willing and able to ship anything under the 250mb/500mb limit specified by the hosting plan.

@fballan93
Copy link

Im having this issue too and i couldn't find a fix . my api route in empty too

@mmeir11
Copy link

mmeir11 commented Dec 27, 2022

Saved my day.
Thanks.

@Matt-CBI
Copy link

Having the same isse: #1034 (comment)

Why is this topic closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Functions
Projects
None yet
Development

No branches or pull requests