Azure Function App - 发布失败

Azure Function App - Publish failed

我无法发布 (WebDeploy) 我的 Azure 函数应用程序(这是一个持久函数,我知道这无关紧要,但是,以防万一)。这从今天开始发生。

我在 Visual Studio.

的输出 window 中收到 "Publish Failed" 弹出窗口和以下错误消息

错误信息

<ProjectName> -> C:\search\source\<Solution Folder>\obj\Release\netstandard2.0\PubTmp\Out\
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Web deployment task failed. (Could not connect to the remote computer ("<functionappname>.scm.azurewebsites.net"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.) [<projectname>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : The requested resource does not exist, or the requested URL is incorrect. [<projectname>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Error details: [<projectname>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Could not connect to the remote computer ("<functionappname>.scm.azurewebsites.net"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE. [<projectname>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : The remote server returned an error: (404) Not Found. [<projectname>.csproj]
  Publish failed to deploy.

函数运行时 - 测试版

当我在浏览器中访问 Function App Url 时,我收到 "Your Function App 2.0 preview is up and running" 消息。而且,我在 Kudu 门户中也没有发现任何错误。

我删除了函数并用相同的名称重新创建了它,但没有成功。

非常感谢任何帮助。

更新:这是我遇到的另一个错误。

C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Web deployment task failed. ((7/25/2018 1:16:27 PM) An error occurred when the request was processed on the remote computer.) [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error :  [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : (7/25/2018 1:16:27 PM) An error occurred when the request was processed on the remote computer. [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : An error was encountered when processing operation 'Create Directory' on 'D:\home\site\wwwroot\bin'. [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : The error code was 0x800703E6. [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Invalid access to memory location. [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error :  [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error :    at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath) [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error :    at Microsoft.Web.Deployment.FileSystemInfoEx.set_Attributes(FileAttributes value) [<Project Name>.csproj]
C:\Program Files\dotnet\sdk.1.202\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error :    at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf) [<Project Name>.csproj]
  Publish failed to deploy.

谢谢, 普拉文

将 WebDeploy 与 SCM 结合使用时无法重现您的错误。当我将 WEBSITE_WEBDEPLOY_USE_SCM 设置为 false(在应用程序设置中)以避免使用 SCM 时,我看到 An error was encountered when processing operation 'Create Directory' on 'wwwroot' 就像您遇到的第二个错误。

可以尝试的几个选项:

  1. 在浏览器中访问https://functionappname.scm.azurewebsites.net检查您的网络环境是否良好,是否有防火墙限制。
  2. 检查发布时是否设置了类似Fiddler的代理
  3. 转到门户,Reset publish credentials,然后 Download publish profile。删除旧的发布配置文件并导入新的发布配置文件。
  4. 如果所有这些建议都失败了,请删除与该功能相关的所有旧资源。然后使用新的应用程序服务计划和存储创建一个全新的功能应用程序。尝试发布到这个新应用。

不知道这是否已关闭,但我在将新的 SDK 版本部署到旧的 azure 函数应用程序时遇到了同样的问题。这是我所做的: 没有从 Azure 门户下载部署配置文件,而是创建了一个具有 visual studio 自动部署的新配置文件。 这很重要 - 从 Visual studio 部署时,它应该要求您升级已部署应用程序的版本,单击是,您的应用程序将被部署。

我很容易错过...但是 Azure 上的功能阻止了我从 Visual Studio 2017 年发布。

需要的是在 Azure 上重新启动函数。

1) 转到 Azure 门户并单击您的函数应用程序。

2) 单击您的函数名称,然后在“概述”选项卡中 - 在第二行菜单中您应该会看到“重新启动”。 (您会在以下行中看到它:停止 - 交换 - 重新启动 - 获取发布配置文件...等)

3) 单击重新启动

4) 返回 Visual Studio 2017 年并重新发布。

我最初错过的错误消息:

C:\Program Files\dotnet\sdk.2.103\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): error : Web deployment task failed. (Web Deploy cannot modify the file 'MyApp.Functions.dll' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.) [C:\Github19AzureBlobLocalOnly\MyApp.Functions\MyApp.Functions.csproj]

与@Andrew Chung 类似的问题,Azure 中的文件被锁定,无法删除旧的函数 dll 文件。我试图升级到 .NET 核心并从不同的项目发布。不幸的是,直到为时已晚,我才看到他的回应,并按照@Jerry Liu 的建议(#4)删除了功能应用程序并添加了一个新功能应用程序。直到我用 不同的名称 重新创建应用程序之前,这似乎对我不起作用。我怀疑可能存在 DNS 冲突,其中 xxxx.scm.azurewebsites.net 仍指向您已停用的旧应用的 IP 地址。

这似乎发生在我身上,因为某些原因需要进行以下更改。

  1. 重建项目(确保你可以在本地运行)。
  2. 点击发布,但在此之前点击 "Manage Application Settings" 做 快速检查并单击确定。
  3. 尝试发布。
  4. 如果失败关闭 visual studio 和 Azure 门户(停止 运行ning 或禁用所有相关对象)并重复。

最坏的情况是创建一个新配置文件并部署到该配置文件。

转到 Azure 门户,停止函数应用程序,从 vs 发布,然后重新启动。

我通过在应用程序设置中将 WEBSITE_RUN_FROM_PACKAGE 设置为 0 解决了这个问题。我通过将 WebDeploy 包从 Azure DevOps 同步到 App Service 文件系统而不是从 .zip 包中 运行 来上传功能文件。

https://docs.microsoft.com/bs-cyrl-ba/azure/azure-functions/run-functions-from-deployment-package 上解释了部署包中的 运行 功能以及这样做的所有好处,但请记住:

  1. 只需将 .zip 部署包上传到 d:\home\data\sitepackages(不要使用 msdeploy 动词 "sync" 同步 wwwroot 的文件系统)
  2. 添加一个 packagename.txt 只包含文件夹中的包文件的名称,没有任何空格