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

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'

I hade the same problem today with net core 2.2 and the solution was to remove setting "WEBSITE_RUN_FROM_PACKAGE" in azure appsettings

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.

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.

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.

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.
Login to portal
Goto your app
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. i.e. bin\Release\ProjectName.xml or similar

Related

Web Deploy to Azure Stopped Working even with downloaded publish profile

My Web Deploy Publish from Visual Studio 2017 to my Azure web app was being finicky yesterday, and today just stopped working completely.
Yesterday the error in Event Viewer was
Error Code: 6 Exception Message: Could not connect to the remote computer ("MYDOMAIN.scm.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC. Exception Stack Trace: The remote server returned an error: (403) Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
--- End of inner exception stack trace ---
Could not connect to the remote computer ("MYDOMAIN.scm.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC.
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request)
at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request)
at Microsoft.Web.Deployment.AgentClientProvider.PerformHeadRequestHelper(Boolean getVersionInfo, Version& maximumSupportedVersion, Version& minimumSupportedVersion)
at Microsoft.Web.Deployment.AgentClientProvider..ctor(DeploymentProviderContext providerContext, DeploymentBaseContext baseContext, String serverVersion)
at Microsoft.Web.Deployment.DeploymentManager.CreateObjectPrivate(DeploymentProviderContext providerContext, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
at Microsoft.Web.Deployment.DeploymentManager.CreateDestinationObject(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
Today the error is :
Error Code: 103 Exception Message: Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CONNECTION_TERMINATED. Exception Stack Trace: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at Microsoft.Web.Deployment.TraceEventSerializer.Deserialize(Stream responseStream, DeploymentBaseContext baseContext, DeploymentSyncContext syncContext)
--- End of inner exception stack trace ---
Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CONNECTION_TERMINATED.
at Microsoft.Web.Deployment.TraceEventSerializer.Deserialize(Stream responseStream, DeploymentBaseContext baseContext, DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.AgentClientProvider.RemoteDestSync(DeploymentObject sourceObject, DeploymentSyncContext syncContext, Nullable`1 syncPass, String syncSessionId)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
After looking at many inconclusive posts on the matter, (and since this error ERROR_CONNECTION_TERMINATED is not listed on the official troubleshoot website they provide in the error), I did the following:
(1) Restart my computer
(2) Restart Visual Studio
(3) Open Visual Studio as Admin
(4) Redownload the Publish profile from Azure
None of this worked.
In the publish profile window, when I click "Validate" for my credentials, they pass. Only when I preview or run the publish does it error out.
What finally worked was
(5) Set Application setting to false in Azure WEBSITE_WEBDEPLOY_USE_SCM
I looked it up and am not sure what it did, and why I needed to do it, and why it worked fine before without this setting. It feels like a hack fix and I don't like it. Should I keep this application setting?
UPDATE:
Not sure if the SCM setting helped. I was able to publish once, and no can't again.
First, Close the firewall and the local proxy-based software.
Second, Make sure you have install the web deploy handler and all of the options has be installed.
(Add the option not be selected.)
Thrid, Make sure you dont have IP restrictions for Management Service.
Other possible reasons you can find in this Offcial doc:
https://learn.microsoft.com/en-us/iis/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio

Azure Web deployment task failed - There is an unclosed literal string

I created a basic web MVC app in vs 2017 and tried to publish it on Azure.
Tried to use existing app service and created a new as well, but both failed.
Received this error -
Severity Code Description Project File Line Suppression State
Error Web deployment task failed. ((20-Jun-19 12:40:32 PM) An error occurred when the request was processed on the remote computer.)
(20-Jun-19 12:40:32 PM) An error occurred when the request was processed on the remote computer.
There is an unclosed literal string. Line 1, position 70.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space)
at System.Xml.XPath.XPathDocument..ctor(TextReader textReader)
at Microsoft.Web.Deployment.PackageDeserializer..ctor(Stream stream, DeploymentBaseContext baseContext)
at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId, String user, String siteName) WebApplicationForAzure 0
To start with, kindly check to see if the app works fine locally.
A deployment issue is an issue that causes the wrong set of files to get deployed to your site folder (typically site\wwwroot), or that causes some files not to get deployed at all.
A runtime issue happens when the files in your wwwroot folder are exactly what they should be, but for some reason the site doesn't run correctly.
Make sure site correctly deploys locally for isolating the issue. Are you deploying to staging slots?
Set WEBSITE_WEBDEPLOY_USE_SCM=false in the Application settings from the Azure Portal, re-download the publish profile and then re-try to see if that helps.
Navigate to your problematic app in the Azure Portal.
Go to Configuration settings blade.
Under Application Settings, set WEBSITE_WEBDEPLOY_USE_SCM = false
Ensure that the ‘false’ key is in the value field.
Reset and re-download the publish settings again in VS.
Also, isolate to see if it is due to network proxy or port on your system.

What is "AppOffline" which prevents my bot application from getting published to the IIS web server?

Just created an application with the Bot Framework, from the template downloaded here: http://aka.ms/bf-bc-vstemplate.
It works well in the testing Emulator. But when publishing to the IIS server, I got this error:
Error Web deployment task failed. ((5/6/2016 3:03:54 PM) An error occurred when the request was processed on the remote computer.)
(5/6/2016 3:03:54 PM) An error occurred when the request was processed on the remote computer.
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at Microsoft.Web.Deployment.Base64EncodingHelper.DeserializeHelper(BinaryFormatter formatter, Byte[] buffer)
at Microsoft.Web.Deployment.Base64EncodingHelper.Deserialize(String str, Exception& handledException)
at Microsoft.Web.Deployment.SerializationHelper.Deserialize(String str)
at Microsoft.Web.Deployment.DeploymentAgentWorkerRequest.GetTraceMessage(String[] additionalMessage)
at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentWorkerRequest workerRequest)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.BeginProcessRequest(DeploymentAgentWorkerRequest workerRequest, AsyncCallback callback, Object extraData)
Unrecognized rule 'AppOffline'. ParkingBot 0
What is the AppOffline error?
I worked around it by doing the following:
locate the .pubxml file for your deployment
toggle EnableMSDeployAppOffline True to
False.
You may need this feature, so it might not be an option. However my application doesn't have this requirement.
Make sure you have the latest version of IIS Web Deploy installed on your server. I was getting this error.
I needed to install Web Deploy 3.6 on our server fixed it.
Check to see if you have a file named app_offline.htm in your deployment folder. That file is for when you're deploying and want to prevent logins on the site until you're done. That file might not have been deleted after deployment.
To add on to jbtule's answer (https://stackoverflow.com/a/49635669/7733418), you might also need to DOWNGRADE to version 3.6. I had Web Deploy 4 installed and was getting the "Unrecognized rule 'AppOffline'" error, but after uninstalling version 4 and installing version 3.6, deployment with <EnableMSDeployAppOffline>True</EnableMSDeployAppOffline>
worked immediately.

Kudu on Azure Webapp causes an "Invalid URI: The hostname could not be parsed." exception

Since yesterday (2016-02-11 18:32 EST), we get this mysterious error in our Azure Webapps' "New Relic" monitoring logs. It seems to happens every 5 minutes We have five applications, all were deployed yesterday around that exact time, but the deployment process it the same as before...
The applications are all functional. I do not know where this error comes from, but the Stack trace mentions Kudu.Services.Web.Tracing.TraceModule.OnBeginRequest
Error message
System.UriFormatException: Invalid URI: The hostname could not be parsed.
Stack trace
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Web.Util.UriUtil.BuildUriImpl(String scheme, String serverName, String port, String path, String queryString, Boolean useLegacyRequestUrlGeneration)
at System.Web.Util.UriUtil.BuildUri(String scheme, String serverName, String port, String path, String queryString)
at System.Web.HttpRequest.BuildUrl(Func`1 pathAccessor)
at System.Web.HttpRequest.get_Url()
at Kudu.Services.Web.Tracing.TraceModule.TryConvertSpecialHeadersToEnvironmentVariable(HttpRequestWrapper request)
at Kudu.Services.Web.Tracing.TraceModule.OnBeginRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Any ideas what is causing this? Is it a Kudu / Azure issue? Can I do anything about it?
There was indeed a new build of Kudu yesterday that caused this regression (build 51.50211.2078). When it was found, and additional build was deployed (build 51.50212.2079) to address it. However, it doesn't take effect until the site is restarted.
Please try restarting your site and confirm that the issue is gone. If you go to the Kudu home page, you can confirm the version before and after the restart.

Exception when running Azure Cloud Project

I have created an azure cloud project in visual studio.
1) Used the "Convert to Azure" feature.
2) Added a Https endpoint and certificate.
Attempting to run the project with the azure emulator locally "without debug" the emulator hangs. If I run the project with debugging it seems to start but i get the following exception:
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll
Additional information: Invalid name.
Parameter name: name
After the exception sites fails to continue.
I was wondering if anyone has experienced this issue and how they resolved it?
Additional Information:
.net 4.5.1 framework.
IIS: version 7.5
Azure SDK 2.6
So looking into the WaIISHost.Log I have found the following exception which keeps being thrown:
WaIISHost Information: 0 : [00014196:00000001, 2015/07/15 07:45:38.428,ERROR] Exception:System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDeta il]: Invalid name.
Parameter name: name (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: Invalid name.
Parameter name: name
at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
at System.Security.AccessControl.FileSystemSecurity..ctor(Boolean isContainer, String name, AccessControlSections includeSections, Boolean isDirectory)
at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
at System.IO.DirectoryInfo.GetAccessControl(AccessControlSections includeSections)
at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurator.FileManager.AddAllowAceIte rative(DirectoryInfo dir, FileSystemRights rights, IdentityReference[] accounts)
at Microsoft.WindowsAzure.ServiceRuntime.IISConfigurato...).
I found a solution to my issue in the end.
I'll be completely honest, i'm not entirely sure if its due to long path names as suggested by #spender or if its something else. I had a folder on my C drive called Dev:
C:\Dev\AzureSolutionExample\Source
I basically moved it directly onto the C drive and everything started working.
C:\AzureSolutionExample\Source

Resources