2

When I try to publish my Azure Function I get a Publish Failed message. I have had this message before and it has gone away after a period of time.

[Update] I understand that Azure Functions have a cold start and expire after 5 minutes. I find if I wait 5 minutes after getting the error then I can publish without the error. So it makes sense that the error occurs because the function app is still "live"

I have been running the function from within the Azure Portal

Am I right in this thinking ? If so a better message would be nice.

Next time it happens I will try stopping the function from within the Portal.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
Kirsten
  • 15,730
  • 41
  • 179
  • 318

2 Answers2

3

Publish Failed of Azure Function MSDeploy in VS can be caused by many points, we could see more details in VS output which usually has some link directs us to Web Deploy Error Codes.

cold start is an increase in latency for functions which haven’t been called recently created on Consumption plan, deployment should have nothing to do with it.

According to your description, I guess you may meet ERROR_FILE_IN_USE .

Web Deploy cannot modify the file 'xxx' on the destination because it is locked by an external process.

AppOffline has been achieved in Azure function, just add setting below to publish profile(funcappname - Web Deploy.pubxml) and Azure will unlock files in use to allow deployment to work. In this way, we don't need to manually stop and start function app.

<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>

There could be other errors failing function deployment.

For ERROR_COULD_NOT_CONNECT_TO_REMOTESVC and ERROR_DESTINATION_NOT_REACHABLE, make sure network is fine and has no firewall/proxy restriction.

For ERROR_CONNECTION_TERMINATED, check whether Fiddler is open.

After we eliminate possible causes on our machine, have a try at methods below.

  1. Have seen several related problems solved with no action taken, i.e wait for a while or retry after several days. So retry later could be a solution if we are not in a hurry.
  2. On portal Overview, Reset publish credentials then Download publish profile. Delete old publish profiles and import the new one to publish again.
  3. In VS publish steps, check Run from package file(recommended) to avoid using MSDeploy.
  4. 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.
  5. On portal Help + support service, New support request to get official help.
Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
0

In my case, I had upgraded .NET versions from 6 to 7.

I was ignoring a minor error, see here: Publish error: Found multiple publish output files with the same relative path

This error was not in the webdeploy log which had a System.AggregationException but no other details. In hindsight, it seems clear that the aggregation was the library conflicts in the project and that while webdeploy was falling over; it was something prior to that likely causing issues (depsite my code building and running fine).

Make sure to check for other errors in both the Output pane in Visual studio (I was using VS2022) and in the log for webdeploy itself as well.

If all goes wrong; I think I would recommend trying a clean project and seeing if that works then comparing the projects.

Dessus
  • 2,147
  • 1
  • 14
  • 24