Azure Function App - Publish failed

14

I'm unable to publish (WebDeploy) my Azure Function App (It's a Durable Function, I know it deosn't matter, but, just in case if matters). This started happening today.

I'm getting a "Publish Failed" popup and the below error message in the output window of my Visual Studio.

Error Message

<ProjectName> -> C:\search\source\<Solution Folder>\obj\Release\netstandard2.0\PubTmp\Out\
C:\Program Files\dotnet\sdk\2.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\2.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\2.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\2.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\2.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 Runtime - beta

When I access the Function App Url in a browser I get "Your Function App 2.0 preview is up and running" message". And, I don't see anything wrong in the Kudu portal as well.

I have deleted the Function and re-created it with the same name with no luck.

Any help is much appreciated.

Update : Here is another error that I'm getting as well.

C:\Program Files\dotnet\sdk\2.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\2.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\2.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\2.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\2.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\2.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\2.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\2.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\2.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\2.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.

Thanks, Praveen

azure
azure-functions
webdeploy
asked on Stack Overflow Jul 25, 2018 by Prawin • edited Jul 26, 2018 by Jerry Liu

7 Answers

10

I fixed this issue by setting WEBSITE_RUN_FROM_PACKAGE to 0 on the application settings. I was uploading the function files by syncing a WebDeploy package from Azure DevOps to the App Service file system and not running it from the .zip package.

On https://docs.microsoft.com/bs-cyrl-ba/azure/azure-functions/run-functions-from-deployment-package explains about running Functions from a deployment package and all the benefits of doing it this way, but then remember to:

  1. Just upload the .zip deployment package to d:\home\data\sitepackages (don't use the msdeploy verb "sync" to sync the file system at wwwroot)
  2. Add a packagename.txt containing only the name of the package file in folder, without any whitespace
answered on Stack Overflow Oct 29, 2019 by David Rodriguez • edited Oct 29, 2019 by David Rodriguez
7

Go to azure portal, stop the function app, publish from vs, then start again.

answered on Stack Overflow Apr 12, 2019 by aldo
6

Don't know if this is closed but I had same issue while deploying new SDK version to an older azure function app. Here is what I did: Instead of downloading deployment profile from Azure portal, created a new one with visual studio automated deployment. This is important- While deploying from Visual studio it should ask you to upgrade version of deployed app, click yes and your app will get deployed.

answered on Stack Overflow Oct 31, 2018 by Harish
2

Can't reproduce your error when using WebDeploy with SCM. When I set WEBSITE_WEBDEPLOY_USE_SCM to false(in Application settings) to avoid using SCM, I saw An error was encountered when processing operation 'Create Directory' on 'wwwroot' like the second error you have met.

Several options to try:

  1. Visit https://functionappname.scm.azurewebsites.net in browser to check whether your network environment is fine and has no firewall restriction.
  2. Check whether you have proxy set like Fiddler when publishing.
  3. Go to portal, Reset publish credentials then Download publish profile. Delete old publish profiles and import the new one to publish again.
  4. If all of those suggestions fail, delete all old resources relate to the function. Then create a brand new function app with new app service plan and storage. Try to publish to this new app.
answered on Stack Overflow Jul 26, 2018 by Jerry Liu
1

This seems to happen to me when I have made changes that for some reason necessitate the following.

  1. Rebuild the project (make sure you can run it locally).
  2. Click to publish, but prior to that click on "Manage Application Settings" do a quick check and click OK.
  3. Attempt to publish.
  4. If that fails close visual studio and azure portal (stop running or disable all relevant objects) and repeat.

Worst case create a new profile and deploy to that.

answered on Stack Overflow Apr 3, 2019 by John Drinane
0

It was easy to miss for me...but the Function on Azure was blocking my publish from Visual Studio 2017.

What was needed was a restart of the Function on Azure.

1) Go to Azure Portal and click into your Function app.

2) Click on the name of your Function, and then in the Overview tab - in the second-row menu you should see Restart. (You'll see it in the row with: Stop - Swap - Restart - Get publish profile...etc.)

3) Click Restart

4) Go back to Visual Studio 2017 and Republish.

My error message which I initially missed:

C:\Program Files\dotnet\sdk\2.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:\Github\2019AzureBlobLocalOnly\MyApp.Functions\MyApp.Functions.csproj]
answered on Stack Overflow Feb 21, 2019 by Andrew Chung
-1

A similar issue to @Andrew Chung where there were locks on the files in Azure and it couldn't delete old function dll files. I was trying to upgrade to .NET core and publish from a different project. Unfortunately, i didn't see his response until it was too late, and had followed @Jerry Liu's advice (#4) to remove the function app and add in a new one. This didn't seem to work for me as until I recreated the app with a different name. I suspect there may be a DNS conflict where xxxx.scm.azurewebsites.net is still pointing to the IP address of your old decommissioned app.

answered on Stack Overflow Mar 28, 2019 by Peter Henry

User contributions licensed under CC BY-SA 3.0