简体   繁体   English

当 zip 使用 Azure CLI 或 PowerShell 部署 function 应用程序时,功能会被删除

[英]Functions get Remove when zip deploy function app using Azure CLI or PowerShell

I'm facing an issue while deploying the azure function using Azure CLI or Azure PowerShell.我在使用 Azure CLI 或 Azure PowerShell 部署 azure function 时遇到问题。

I have already created needed resources like resource group, function app and blob storage.我已经创建了所需的资源,如资源组、function 应用程序和 blob 存储。

My function app platform type is Linux with consumption plan and runtime.net6.0.我的function app平台类型是Linux ,有消费计划,runtime.net6.0。 I have created Service Bus trigger function and deployed using Visual Studio Publish profile and it is working as expected.我已经创建了服务总线触发器 function 并使用 Visual Studio 发布配置文件进行了部署,它按预期工作。

But when I executed the command to deploy the Azure function using CLI.但是当我使用 CLI 执行部署 Azure function 的命令时。 Command is executing successfully but when I open the function app from azure portal and go to functions blade the deployed functions do not appear there.命令执行成功,但是当我从 azure 门户和 go 打开 function 应用程序到功能刀片时,部署的功能不会出现在那里。

I also checked the folder structure of the build output as mentioned in the link我还检查了链接中提到的构建 output 的文件夹结构

https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push

any help would be appreciated.任何帮助,将不胜感激。

Thanks谢谢

Reproduced the same issue from our end using Az-CLI使用 Az-CLI 从我们这边重现了同样的问题

az functionapp deployment source config-zip -g <Resource Group> -n <Function App Name> --src <Function Project with Zip>

在此处输入图像描述

在此处输入图像描述


Workaround to fix the issue解决问题的解决方法

After setting SCM_DO_BUILD_DURING_DEPLOYMENT to true in Configuration > Application Settings of the Azure Function App in Portal and deployed again using AZ CLI commands and shown the functions in Portal and in Kudu site of wwwroot folder.在 Portal 中 Azure Function App 的 Configuration > Application Settings 中将SCM_DO_BUILD_DURING_DEPLOYMENT设置为true并使用AZ CLI命令再次部署后,在 Portal 和 Kudu 站点的wwwroot文件夹中显示了这些功能。

在此处输入图像描述

AZ CLI Command: AZ CLI 命令:

az functionapp deployment source config-zip -g HariTestRG -n KrishNet6FuncApp --src "C:/Users/Hari/source/repos/DotNet6/TimerTrigger1205.zip"

在此处输入图像描述

According to this MS DOC , we came to know that some deployment customization has to be done before deploying the Function App as a Zip Push, ie, by default the app setting SCM_DO_BUILD_DURING_DEPLOYMENT is false which enables the continuous integration deployment.根据这个MS DOC ,我们了解到在将 886982359588 App 部署为 Zip Push 之前,必须进行一些部署定制,即默认情况下,应用程序设置SCM_DO_BUILD_DURING_DEPLOYMENT为 false,这会启用持续集成部署。

For the PowerShell Workaround, refer GitHub Page .对于 PowerShell 解决方法,请参阅GitHub 页面

Function App running on Linux OS in consumption plan has limited deployment options but supports only remote build. Function 消费计划中运行在 Linux 操作系统上的应用程序部署选项有限,但仅支持远程构建。

To enable remote build on Linux, the following application settings must be set:要在 Linux 上启用远程构建,必须设置以下应用程序设置:

ENABLE_ORYX_BUILD=true
SCM_DO_BUILD_DURING_DEPLOYMENT=true

If your project needs to use remote build, don't use the WEBSITE_RUN_FROM_PACKAGE app setting.如果您的项目需要使用远程构建,请不要使用WEBSITE_RUN_FROM_PACKAGE应用程序设置。

Functions Core Tools is the only solution work for me. Functions Core Tools 是我唯一的解决方案 By default, Azure Functions Core Tool perform remote builds when deploying to Linux. Because of this, it automatically create these settings for you in Azure.默认情况下,Azure Functions Core Tool 在部署到 Linux 时执行远程构建。因此,它会在 Azure 中自动为您创建这些设置。

func azure functionapp publish <FunctionAppName>

my custom script file我的自定义脚本文件

param(
[Parameter(Mandatory=$True)]
$AppName,
[Parameter(Mandatory=$True)]
$LocalProjectPath
)

cd "$($LocalProjectPath)"

func azure functionapp publish $AppName

cd ..

if you need more help with Linux hosting use this link Zip Deploy.net to get detailed information related to Azure Functions Deployments .如果您需要有关Linux 托管的更多帮助,请使用此链接Zip Deploy.net获取与Azure 功能部署相关的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Zip 部署 Azure function 成功但 Azure 中的函数为空 - Zip deploy of Azure function was a success but Functions in Azure is empty 如何使用无服务器 cli 部署多个功能? - How to deploy multiple functions using serverless cli? 如何将python app部署到Azure Function - How to deploy python app to Azure Function 使用 Azure CLI 获取 Azure 应用程序网关的“principalId”值 - Using Azure CLI Get the 'principalId' value of an Azure Application Gateway Azure Function 使用基于身份的身份验证的 App Blob 触发器返回 powershell 错误 - Azure Function App Blob Triggers using identity-based authentication returns a powershell error 尝试部署时出现 errorType:OK function - Get errorType:OK when trying to deploy function 从 aws cli 部署到 lambda edge function - Deploy to lambda edge function from aws cli 使用 Azure PowerShell 查找 App Insights 的 LA 工作区 - Find LA workspace for an App Insights using Azure PowerShell 无法使用 Azure 发布管道通过 Azure CLI 命令更新逻辑应用程序 JSON 文件 - Logic App JSON file could not be update through Azure CLI Command using Azure Release Pipeline Firebase CLI 部署错误:读取函数/包时出错。json - Firebase CLI deploy Error: There was an error reading functions/package.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM