Azure Function App - Publish failed
Asked Answered
G

8

18

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

Gabriello answered 25/7, 2018 at 12:30 Comment(4)
Any progress? If you are still trapped, I recommend you to send a support request on Azure.Diffident
We automated the deployments from VSTS. After looking at your above comment, I tried to publish it again. It's working now. Not sure how it's working now. I didn't make any changes to the Function app.Gabriello
this helped me in: #48330474Thundering
I managed to fix it by install WebDeploy: iis.net/downloads/microsoft/web-deployUnreflecting
S
14

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://learn.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
Supreme answered 29/10, 2019 at 15:8 Comment(1)
Worked for me, but after setting WEBSITE_RUN_FROM_PACKAGE I had to delete the publish profile from Visual Studio and add it againPeppers
H
10

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

Hanford answered 12/4, 2019 at 1:12 Comment(2)
This is not the ideal way we should follow. Especially when the site is production .Reichstag
This doesn't work from command line with "func .... "Naive
H
9

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.

Hydranth answered 31/10, 2018 at 8:43 Comment(0)
D
1

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.
Diffident answered 26/7, 2018 at 6:17 Comment(3)
Repeatly after a few publishs a ran into the same problem and only #4 works. Azure Functions v2 seems not be to ready.Unsuspecting
@johnstaveley Have a look at another related problem.Diffident
I deployed without zipping and set WEBSITE_WEBDEPLOY_USE_SCM to be an empty string (in Application settings). This worked.Curare
O
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.

Orrery answered 3/4, 2019 at 19:7 Comment(0)
F
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]
Fernandofernas answered 21/2, 2019 at 19:34 Comment(0)
G
0

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.

Goose answered 28/3, 2019 at 1:35 Comment(0)
W
0

If your function app is under a subnet (it was the case for me), then you might see the same error. I was banging my head as the publish from visual studio as well as the DevOps pipeline was not able to deploy my function app code. When I saw the exception closely in Visual Studio, it was:-

Could not connect to the remote computer "xxxx.scm.azurewebsites.net". Make sure that the remote computer name is correct and that you are able to connect to that computer.

I was not able to browse to the Kudu website but the function app was working fine.

Solution: Navigate to your Function app -> Networking -> Private Endpoint

Open the Private Endpoint node by navigating via above steps. Goto DNS configuration under settings and note down the IP address.

Now, on your computer - Navigate to C:\Windows\System32\drivers\etc\hosts Edit the hosts file and enter:-

xx.xxx.xxx.xxx yourwebsite.scm.azurewebsites.net

Here, xx is the private endpoint IP address noted above.

Warlord answered 30/5, 2023 at 17:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.