MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.13k stars 21.2k forks source link

Azure function: confusion about remote build and run from package #113356

Open DaCao opened 11 months ago

DaCao commented 11 months ago

Reading through the documents of Azure function:

Deployment options Run from package file

I have some confusions that need to be clarified:

In Remote build, it says:

When apps are built remotely on Linux, they run from the deployment package.

To Enable functions to run from a package:

To enable your function app to run from a package, add a WEBSITE_RUN_FROM_PACKAGE setting to your function app settings. The WEBSITE_RUN_FROM_PACKAGE setting can have one of the following values:

and 1 is recommended for premium plan

And in general considerations, it says in the last bullet point:

If your project needs to use remote build, don't use the WEBSITE_RUN_FROM_PACKAGE app setting. Instead add the SCM_DO_BUILD_DURING_DEPLOYMENT=true deployment customization app setting. For Linux, also add the ENABLE_ORYX_BUILD=true setting.

Isn't there a contradiction?

  1. In Linux, when remote build, they run from deployment package.

  2. To enable to run from package, we need WEBSITE_RUN_FROM_PACKAGE=1

  3. But, If your project needs to use remote build, don't use the WEBSITE_RUN_FROM_PACKAGE app setting.

I must have got my concepts wrong. Could someone offer some clarification?

To sort things out, I want to clarify a few questions:

  1. When Azure performs remote build, what is the resultant file of the build process? What is the format of the file? Where exactly is this file stored?

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

YashikaTyagii commented 11 months ago

@DaCao Thanks for your feedback! We will investigate and update as appropriate.

ggailey777 commented 11 months ago

Thanks @DaCao there does seem to be some conflicting guidance here. @FinVamp1 do you have any suggestions on how to clarify this article?

ggailey777 commented 3 months ago

@im-samz can you suggest how we might fix these apparent contradictions? It would probably help to clarify the remote build section.

im-samz commented 3 months ago

Hello @DaCao, I think addressing your second assertion will clarify things: "To enable to run from package, we need WEBSITE_RUN_FROM_PACKAGE=1"

When you set SCM_DO_BUILD_DURING_DEPLOYMENT=true and ENABLE_ORYX_BUILD=true, you are specifying a deployment path that behaves similarly to what happens when you set WEBSITE_RUN_FROM_PACKAGE=1, with the key difference that the package is built remotely first.

"Run from package" is a deployment method in which your ready-to-run package is located in d:\home\site\wwwroot for Windows or /home/site/wwwroot for Linux. There are different ways that you can get your package to this location - i.e., to enable your app to run from package. Setting WEBSITE_RUN_FROM_PACKAGE=1 is one such method.

Setting SCM_DO_BUILD_DURING_DEPLOYMENT=true and ENABLE_ORYX_BUILD=true is another method. By doing so, you are specifying a deployment route in which your deployment package will be first built by the platform (i.e., kudu) to become ready-to-run. You don't need to specify WEBSITE_RUN_FROM_PACKAGE=1 in this case because that logic is already baked in.

To specifically answer your question, after Azure performs the remote build, the resultant file is a .zip package stored in the d:\home\data\SitePackages (Windows) or /home/data/SitePackages (Linux) folder. After a restart, the package is mounted to wwwroot as a read-only filesystem.

Let me know if this was helpful :)