英文:
Azure function: confusion about remote build and run from package
问题
阅读Azure函数文档时:
我有一些需要澄清的疑问:
在远程构建中,它说:
当在Linux上远程构建应用时,它们会从部署包中运行。
要启用函数从包中运行:
要启用您的函数应用从包中运行,请将WEBSITE_RUN_FROM_PACKAGE设置添加到您的函数应用设置中。WEBSITE_RUN_FROM_PACKAGE设置可以具有以下值之一:
并且对于高级计划,建议使用
1
。
而在一般考虑中,最后一个项目中说:
如果您的项目需要使用远程构建,请不要使用WEBSITE_RUN_FROM_PACKAGE应用设置。而是添加SCM_DO_BUILD_DURING_DEPLOYMENT=true部署自定义应用设置。对于Linux,还要添加ENABLE_ORYX_BUILD=true设置。
难道这里有矛盾吗?
-
在Linux上,远程构建时,它们从部署包中运行。
-
要启用从包中运行,我们需要
WEBSITE_RUN_FROM_PACKAGE=1
。 -
但是,如果您的项目需要使用远程构建,请不要使用WEBSITE_RUN_FROM_PACKAGE应用设置。
我一定是弄错了概念。有人可以提供一些澄清吗?
为了搞清楚事情,我想澄清一些问题:
- 当Azure执行远程构建时,构建过程的结果文件是什么?文件的格式是什么?这个文件具体存储在哪里?
英文:
Reading through the documents of Azure function:
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?
-
In Linux, when remote build, they run from deployment package.
-
To enable to run from package, we need
WEBSITE_RUN_FROM_PACKAGE=1
-
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:
- 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?
答案1
得分: 1
"Remote build"在执行"zip部署"时是指在远程构建服务器上构建函数应用程序的代码。
这是用于情况,如果您的函数应用程序中有任何需要编译或在部署之前需要额外构建步骤的依赖项。
带有SCM_DO_BUILD_DURING_DEPLOYMENT=true
和ENABLE_ORYX_BUILD=true
的远程构建:
-
当您将函数部署到Azure时,它会使用远程构建服务器来构建您的函数应用程序,该服务器配备了所需的构建工具、运行时环境和依赖项,以正确编译和打包您的代码。
-
远程构建服务器通过安装所需的依赖项和软件包将代码编译成部署包,并将该包部署到Azure函数应用程序运行时环境。
-
当调用您的函数应用程序时,它将直接从在远程服务器上构建的部署包中运行,其中包含了所有依赖项和已编译的代码,以正确执行该函数。
由于应用程序是远程构建并作为一个包部署的,所以不需要手动添加WEBSITE_RUN_FROM_PACKAGE
设置。
WEBSITE_RUN_FROM_PACKAGE
(无远程构建):
"从包中运行"是指函数应用程序在运行时在两种情况下使用部署包的内容。然而,远程构建和zip部署方案之间在创建和管理部署包的方式上有所不同。
在使用zip部署部署函数时,函数应用程序的源代码、依赖项和所有所需的文件将被打包成一个zip文件。然后,将zip文件上传到Azure中函数的目标环境。然后,Azure将内容部署到函数应用程序的运行时环境中。
通常情况下,Azure Functions会尝试直接从源代码位置(site/wwwroot)运行。
在函数应用程序=>设置=>配置中设置WEBSITE_RUN_FROM_PACKAGE=1
允许Azure从通过zip部署上传的部署包中运行应用程序,而不是从源代码运行。
- 当Azure执行远程构建时,构建过程的结果文件是什么?文件的格式是什么?这个文件究竟存储在哪里?
要检查远程构建后函数应用程序的文件:
- 转到函数应用程序的KUDU站点,Debug Console=>Bash
- 转到如下路径:
data\SitePackages
- 函数相关的zip文件将与packagename.txt一起可用。
要检查函数应用程序的文件(没有远程构建/zip部署):
希望这对您有所帮助。
英文:
Remote build while doing the zip deployment refers to building the function app's code on a remote build server.
This is used in case if you any dependencies in your function app which needs to be compiled or requires additional build steps before getting deployed.
Remote build with SCM_DO_BUILD_DURING_DEPLOYMENT=true
and ENABLE_ORYX_BUILD=true
:
-
When you deploy your function to Azure, it uses a remote build server to build your function app which is equipped with the required build tools, runtime environments, and dependencies to compile and package your code correctly.
-
The remote build server compiles the code by installing required dependencies and packages into a deployment package and deploy the package to your Azure Function App runtime environment.
-
When your function app is invoked, it runs directly from the deployment package that was built on the remote server with all the dependencies and compiled code to execute the function properly.
As the app is built remotely and deployed as a package, it already runs from the deployment package. So, adding the setting WEBSITE_RUN_FROM_PACKAGE
manually isn't required.
WEBSITE_RUN_FROM_PACKAGE
(without remote build):
Running from a package refers to the function app's use of the deployment package's contents during runtime in both cases. However, the way the deployment package is created and managed differs between remote build and zip deployment scenarios.
-
While deploying the function using zip deployment, the function app's source code, dependencies, and al the required files will be packaged into a zip file. Then, the zip file is uploaded to the Function's target environment in Azure. After that, Azure deploys the contents to your function app's runtime environment.
-
Generally, Azure Functions tries to run directly from the source code location(site/wwwroot).
-
The setting
WEBSITE_RUN_FROM_PACKAGE=1
in function app=>settings=>configuration lets Azure to run the app from the uploaded deployment package which was uploaded through zip deployment instead of source code.
>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?
To check the files of your function app after remote build:
- Go to KUDU site of your function app, Debug Console=>Bash
- Navigate to the path
data\SitePackages
as shown below: - The function related zip files will be available along with the packagename.txt.
To check the files of your function app(without remote build/ Zip deployment):
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论