Why does WAIISHost lock certain files - azure

I am deploying a web application to azure. The application is built using Nancy, and there is no RoleEntryPoint defined (please note this isn't a problem, the website itself is running just fine). When I deploy to azure, i have enabled the web deploy option.
When I attempt to run a webdeployment, am getting the following error:
Error 7 Web deployment task failed.((6/26/2012 12:28:45 PM) An error
occurred when the request was processed on the remote computer.)
(6/26/2012 12:28:45 PM) An error occurred when the request was
processed on the remote computer. An error was encountered when
processing operation 'Create File' on 'Castle.Windsor.dll'. The error
code was 0x80070020. The process cannot access
'E:\approot\bin\Castle.Windsor.dll' because it is being used by
another process.
I've RDP'd into the role instance and using process explorer I see that WAIISHost has a lock to a number of assemblies that my project references.
I haven't been able to determine what is causing those files to be locked.
thanks,
jason

Web Deploy is not for use in a production environment. (described here)
WaIisHost.exe is the role hose process for full IIS web role so when your web role starts, your role DLL is loaded in this process. During the life of your webrole the role dll is loaded in the host process and can not be changed. As Castle.Windsor.dll is in E:\approot\bin* where role specific DLL are located, the host process has this binary loaded in it.
If you want to update your web role you would need to, you the Windows Azure Upgrade option either from portal or from powershell.

Related

Azure Devops : How to enable the Rename locked files (RenameFilesFlag) with an "IIS web app deploy" task

I'm having a problem with a locked DLL file while I tried to deploy with a Release Pipeline in Azure Devops.
The screenshot of the error is:
Output as text:
2021-03-31T17:43:18.2626492Z ##[error]Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'Microsoft.Data.SqlClient.SNI.x64.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.
Error count: 1.
It seems the problem is caused by a wrongly disposed .NET resource. (ex: unmanaged SqlConnection)
Anyway, I can't change the source code.
Here is my Release Pipeline.
Here are my questions:
Q1) I'm trying to use the "-RenameFilesFlag" (MSDEPLOY_RENAME_LOCKED_FILES) as described here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops
web.config file locked during Azure App Service Deploy task
How do I have to specify this argument ?
Do I have to fill the "Additional arguments" textbox ? I tried different values and I always get an
"Unrecognized argument" error.
Q2) If the "-RenameFilesFlag" is not available for this task.
Can I use the "Take App Offline" to unlock a file ?
Q3) On another post on StackOverflow, I saw a checkbox option specific to "Rename locked files"
Getting ERROR_FILE_IN_USE while using Web Deploy in Azure App Service Task v3
I don`t have this option in my task. Is it possible that I am confusing two type of Deploy tasks ?
MSDEPLOY_RENAME_LOCKED_FILES
As far as I know, this method only supports Azure Web APP service. This option is used to set the Azure App settings(cloud). It does not apply to IIS deployment(on-prem).
##[error]Error Code: ERROR_FILE_IN_USE
To solve this issue, you could try the following methods:
1.You could set the Take App Offline option in IIS Web Deploy task.
Here is a doc about Taking an Application Offline before Publishing
2.You could Stop your website before deploying the app and restart it after deployment.
You could add IIS web app manage task to stop and start the IIS Website.
For example:
Update1:
As ssinfod's comment: stop the application pool could solve this issue.
We can also achieve this in IIS web app manage task

Azure WebApp: cannot modify file even though service is stopped

I am trying to deploy my app to an Azure WebApp slot but it seems that the file (Microsoft.Data.Edm.dll) it is trying to update is locked even though I have manually stopped the WebApp. I got the following error while deploying my app.
Web deployment task failed. (Web Deploy cannot modify the file 'Microsoft.Data.Edm.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.)
I tried on both VSTS web deploy task and manual deploy from Visual Studio, it returns me the same error message. I tried restarting the WebApp, setting the COR_ENABLE_PROFILING = 0 then 1 too but again, same error. The last resort that I didn't try is delete the WebApp and recreate again.. but i would like to know if there are other suggestions first before I do this desperate measure.
Thank you in advanced.
Restarting works better, stop just stops the http listener, restart restarts the running proces
Please try to use Resources explorer portal to full stop your web app. In this way, we can delete some locked files via FTP without anything running. For more details about how to full stop your web app, please refer to this article
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 that you can read about it if you search and read about the feature.
HTH

AZURE Worker Role Deploy with extra DLL's and app.Config

I'm trying to deploy an Azure Worker Role Cloud Service. When testing a "Hello World" scenario, it's very simple and works fine.
Once I add references to custom DLL's, and EntityFramework, the Worker Role will no longer deploy. My thought is the extra DLL's and the app.config file is not getting deployed.
Here is the error:
1:25:03 PM - Uploading Package...
1:25:57 PM - Updating...
1:29:04 PM - Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation.
Does anyone know why it's failing and if this is possible or how to deploy a more complex worker role?
Sounds like something is present locally that doesn't exist (or is not available) once deployed.
Easiest thing to do is remotely debug your worker role:
http://msdn.microsoft.com/en-us/library/azure/ff683670.aspx#BK_Debugging_Cloud_Azure
Both feedback items helped me resolve the error. Below are the steps:
1.) I made sure I had both a web site and worker role added to the solution.
2.) I verified they both ran and could be published to Azure.
3.) I then added my custom code, and ensured the config file for the worker role was correct and working in the compute emulator.
4.) I ensured the app.config and dll files had the property copy local to true, which ensured they were deployed.
5.) Deployed to Azure and it worked!
Thanks...

Publishing web application works in Visual Studio, but generated package cmd file fails with insufficient permissions

I'm trying to deploy a web application from the command line. Eventually I'll do this from my build server (running Jenkins), but for now I'm doing it from my desktop.
My web server runs Windows Server 2012. I'm using Visual Studio 2012 on the desktop. Within Visual Studio, publishing directly, using the Web Deploy method, works fine. If instead I use the Web Deploy Package method, then run the generated .cmd file, it fails with
Error: (3/14/2013 7:35:49 PM) An error occurred when the request was processed on the remote computer.
Error: An error occurred when reading the IIS Configuration File 'MACHINE/REDIRECTION'. The identity performing the operation was 'WEB\uoedeploy'.Error: Filename: \\?\C:\Windows\system32\inetsrv\config\redirection.config
Error: Cannot read configuration file due to insufficient permissions
Following instructions from Microsoft and elsewhere, I have created an account on the web server for publishing, and I use the same account credentials for both publishing methods. I added that user to the group MSDepSvcUsers on the web server. I checked the effective permissions for that account on redirection.config, and it shows read permission.
I hate MSDeploy.

WorkerRole.cs what is its purpose

Hi I have created a new azure project with a worker role and have noticed a class WorkerRole.cs. I tried researching on what it's purpose is however I couldn't find a straight answer.
The goal of the WorkerRole.cs is to give you an entry point to execute "something" when the Worker Role instance starts. This could be a command line application you're starting, or a WCF service, or MySQL, ... anything you want.
Note that you'll need to write code to keep the instance 'alive'. If you don't do this, it will restart when the Run method completes. Take a look at the following question for more information: Using Thread.Sleep or Timer in Azure worker role in .NET?
Here is something you can use to understand Windows Azure Worker Role:
Windows Azure is Platform as a Service and you will get to run your application in a dedicated virtual machine (except with extra-small instance)
The application architecture for Windows Azure application supports 3 different kind of applications called Web Role, Worker Role and VM Role,
2.1. A Web role is considered an application in which IIS is pre-configured and ready for your application. In most cases it is a web based application but it may not if you wish, but IIS will always be there. With IIS, you can run either an ASP.NET application or a node.js application it is your choice to decide what kind of application you would want.
2.2. A Worker role is considered to be an application which does not need IIS and it is up to you whatever you would want to run on Worker role, C#, Java, PHP, Python or anything else. It is mainly used for open source web application or an application which perform actions as back-end and does not need web front end.
2.3 VM Role is in BETA and used to run on a custom VHD deployed by user. We would consider it is in following explanation.
All of these roles are actually a libraries means they compiled as DLL and when they run on Windows Azure, they actually needs a host process to run. For Web Role, the host process is WaWebHost.exe or WaWebIIS.exe, for WorkerRole the host process is WaWorkerHost.exe.
When these host process starts in Windows Azure they look for a file call E:__entrypoint.txt which provided the Role DLL name and location so host process and find and load it.
These Web and Worker role class are derived from RoleEntryPoint base class which extend all of required function for a web and worker role to run in Windows Azure Environment
When you create a web or worker role using, Azure SDK template you will get these base code file where Web and Worker Role class can implement required functions. For Worker Role the call WorkerRole defined in WorkerRole.cs and for Web Role it is WebRole.cs.
If you decided to add code specific to Windows Azure Runtime i.e. configuration or some setting you are going to add here because when role will start via host process, the code you have added in WebRole.cs or WorkerRole.cs will execute in Windows Azure runtime context.

Resources