正在使用的 Azure App Service Deploy 文件

Azure App Service Deploy file in use

在我的项目中,我们使用 Azure App Service Deploy 任务来部署我们的 webdeploy 包。

我注意到有时我在部署时会遇到文件正在使用错误,即使选项 'Take app offline' 已设置为开。

解决此问题的最佳方法是什么?

这是错误:

2016-12-07T15:26:44.8411101Z ##[error]Failed to deploy website.

2016-12-07T15:26:44.8411101Z ##[error]Error Code: ERROR_FILE_IN_USE

2016-12-07T15:26:44.8421096Z More Information: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.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.

我有本页推荐的临时修复方法 here

我在部署前使用此命令创建了一个 Azure CLI 任务:

azure webapp stop --resource-group XX --name YY

(其中 XX 是资源组名称,YY 是网络应用服务)

然后使用 Azure Web 部署任务执行部署

然后在部署后执行此 Azure CLI 任务:

azure webapp start --resource-group XX --name YY

那行得通。

您现在可以使用 'Azure App Service Manage 任务来停止和启动应用程序服务以防止文件被使用。