简体   繁体   中英

What is going wrong with web deployment from Visual Studio and App service?

Suddenly Web Deployment started failing.

Could not find file 'D:\home\site\wwwroot\App_Offline.htm'.

I stopped the service, but deployment still fails.

When I tried to delete any file from wwwroot in Kudu PowerShell UI I get error "404 file not find", but that file is still displayed after refresh. When I tried to delete file directly in powershell I get error

Cannot remove item D:\home\site\wwwroot\Azure.Storage.dll: Invalid access to memory location.
At line:1 char:1
+ del .\Azure.Storage.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (D:\home\site\wwwroot\Azure.Storage. 
   dll:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell 
   .Commands.RemoveItemCommand

I deleted the service, recreated it and the first deployment from Visual Studio was Ok. But next day deployment failed again. The only thing between that deployments was deployment from VSTS. But I was able to deploy from VSTS and from Visual Studio in any order before without any problem.

I'm the Owner of that App Service.

Deployment log.

(2018-08-06 13:05:03) An error occurred when the request was processed on the remote computer.
Could not find file 'D:\home\site\wwwroot\App_Offline.htm'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
   at System.Xml.XmlWriterSettings.CreateWriter(String outputFileName)
   at System.Xml.XmlWriter.Create(String outputFileName, XmlWriterSettings settings)
   at Microsoft.Web.Deployment.AppOfflineRuleHandler.AddAppOfflineFilesToEachApp(DeploymentBaseContext baseContext, Boolean whatIf)
   at Microsoft.Web.Deployment.AppOfflineRuleHandler.AddChild(DeploymentSyncContext syncContext, DeploymentObject destinationParentObject, DeploymentObject& sourceObject, Boolean& proceed)
   at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAddChild(DeploymentObject destParent, DeploymentObject sourceObject, Int32 position)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncDirPathChildren(DeploymentObject destRoot, DeploymentObject sourceRoot)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenNoOrder(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenNoOrder(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
   at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId)
   at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId, String user, String siteName)
Publish failed to deploy.

All of a sudden VSTS default deployment mode became Run-From-Zip.

The solution is setting Select deployment method checkbox in VSTS deploy and be sure Web Deploy is selected.

To "unlock" the service you need to delete setting WEBSITE_RUN_FROM_PACKAGE from Application settings page in the Azure Portal - it is under 'Configuration'

在此处输入图片说明

我今天在 net core 2.2 上遇到了同样的问题,解决方案是在 azure appsettings 中删除设置“WEBSITE_RUN_FROM_PACKAGE”

We got hit by this same issue - the file system becomes readonly when WEBSITE_RUN_FROM_PACKAGE=1 . Azure App Service seems to be adding this app setting automatically during recent platform upgrades.

I do suggest using Run-From-Package over web deploy - but you can easily revert their forced updates by setting WEBSITE_RUN_FROM_PACKAGE=0 . If you are on Azure DevOps - the latest version of App Service Deploy v4 supports Run-From-Package .

The reason for this is because the AzureWebApp task in Azure DevOps (VSTS) Pipeline, updates the 'WEBSITE_RUN_FROM_PACKAGE' to '1'. This is primarily used by Azure Functions, where we need to deploy the entire package (and there by making the wwwroot as read-only). While its very useful in Functions, you will see weird things in normal Web App (such as App_Offline not found, the wwwroot/lib folder not found, you will see older files in the FTP folder but latest ones in the Kudu console etc).

The simplest fix is to update the setting 'deploymentMethod' to 'zipDeploy' in your YAML file.

Go to Configurations -> Application settings in your azure portal change the value of ' WEBSITE_RUN_FROM_PACKAGE ' from '1' to '0'. And then publish again.

This resolved my problem.

Delete the appp settings WEBSITE_RUN_FROM_ZIP then retry deploy from VS. This worked for me

If you choose the deployment method by yourself in the release step this should not appear:

在此处输入图片说明

For those who cannot find setting in azure portal, please refer below steps.

  1. Login to portal
  2. Goto your app
  3. search configuration

在此处输入图片说明

Name 'WEBSITE_RUN_FROM_PACKAGE' will be there is list.

My deployment was failing with the same message and stack trace, but was caused by a policy assignment that disallowed the location for my resource.

(The resource had been created in US West, and then a policy was applied at the tenant root level that only allowed US West 2.)

After the policy was updated, the deployment succeeded.

I got a similar error but for me it was:

Access to the path 'C:\home\site\wwwroot\App_Offline.htm' is denied

Got this when trying to publish a .NET 5 application. Fixed by setting correct .NET version in General settings for my App Service:

在此处输入图片说明

This error can occur when VS has issues finding your swagger xml file. Right-click your project > Properties > Build will take you to the correct page.

Check the "XML Documentation File:" box. This resolved the issue for me but you may need to ensure that the release or debug folder are included in the path. ie bin\\Release\\ProjectName.xml or similar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM