Azure Function: Publish fails with message “Web Deploy cannot modify the file on the Destination because it is locked by an external process.”

前端 未结 6 826
猫巷女王i
猫巷女王i 2021-02-01 13:25

I am developing an Azure Functions Project and when I publish first time, OK. Then I publish again, this Error appears:

Web Deploy cannot modify the file

相关标签:
6条回答
  • 2021-02-01 13:57

    Go to the Functions tab in Azure and press the Restart button. Then try to publish again in Visual Studio. Sometimes closing the browser and opening it again or a combination of these things are nessesary.

    That is all you need to do.

    0 讨论(0)
  • 2021-02-01 14:00

    My Azure Function is in V2, and got locked down with FILE_IN_USE.

    There is an open issue on this: https://github.com/Azure/azure-functions-host/issues/569

    According to Paul Batum's comment from 6 Sep:

    "In Functions V2 there is no shadowcopy behavior (because it does not exist in .NET core) and so running into locking issues is more likely. However we have implemented support for the "take app offline" feature that is provided through msdeploy. "

    So I checked take app offline and tried, and the file is not locked when I redleploy.

    0 讨论(0)
  • 2021-02-01 14:05

    Following this article, you could also try adding this directive in your Web Deploy pubxml to instruct taking the Function app offline while deploying:

    <EnableMsDeployAppOffline>True</EnableMsDeployAppOffline>

    0 讨论(0)
  • 2021-02-01 14:14

    As of time of this writing, if you are using Azure DevOps (VSTS) to deploy your application, you can select "Run From Package" in the "Azure App Service Deploy" task/step - this is available in version 4 of the task, under the "Additional Deployment Options" node.

    This deployment option eliminates file locking issues as it provides atomicity, in that the application is pointed to the new zip file rather than deploying a bunch of loose files under wwwroot, some of which may be locked.

    It provides you with a number of other benefits as documented here.

    HTH

    0 讨论(0)
  • 2021-02-01 14:15

    Updated Response: Here is some documentation on steps you can take when your files are locked (besides manually restarting your app). https://github.com/projectkudu/kudu/wiki/Dealing-with-locked-files-during-deployment

    0 讨论(0)
  • 2021-02-01 14:22

    Set

    MSDEPLOY_RENAME_LOCKED_FILES=1 
    

    in the Azure Function Application Settings usually resolved this

    This can also be done in Visual Studio on the Publish -> Application Settings:

    0 讨论(0)
提交回复
热议问题