Disable kudu for the running web app.
Why? Kudu is consuming the CPU periodically and I want to stop that.
So far I have tried to Kill the process by clicking on Properties >> Kill button. but this process gets start again.
You can use below settings in Application settings.
When separation enabled (the default), the main site and scm site run in different sandboxes.
WEBSITE_DISABLE_SCM_SEPARATION=true
Then you can check Process Explorer.
Offical Doc:
Use the same process for the user site and the scm site
Related
I have a Wep API .NET core application running through IIS on Windows Server 2016.
The app is doing a lot more than just replying to its API as it is monitoring events, etc on other services.
I have 3 problems:
When I start / restart the app through IIS (or when publishing an update), it doesn't do anything until there is a request coming. Then the app gets started. Is there a way to force the app to run immediately?
The app does a lot of background processing and I find that sometimes it stops doing anything at all. It has tasks on a timer that do not get executed, etc. If I constantly output work to the logger, this doesn't happen
When the app starts, it sends quite a few things to the log and during that time, I can see it start twice! It starts to display a page worth of log and then it starts again. But here is what's odd: when the app starts, there is a random 'cute name' selected so we can differentiate instances and during the original and the second startup it is the same name, so it shows that it is the same instance, but the init gets called a second time.
Is there something specific about the way apps run in an IIS container that could explain these behaviors?
After doing more search, the recommended option is to run as a service, but it's not a possibility in my case, so I still need to make a .Net Core Kestrel app with IIS as a reverse proxy.
And despite the comment below, I still don't find any good solution short of pinging the site regularly to keep it alive.
On the application pool set "Start Mode" to "AlwaysRunning" and on the website, itself, set "Preload Enabled" to "true". With those two settings, the application starts immediately.
EDIT: You have to have "Application Initialization" module enabled on IIS
You must do those steps:
Turn on "Application Initialization"
Go to "Turn Windows features on or off"
Select "World Wide Web Services" > "Application Development Features" > "Application
Initialization"
Press "OK"
Under Connections in IIS click on "Application Pools"
Right-click on the website which was created
Change "Start Mode" to "AlwaysRunning"
Change ".NET CLR Version" to "v4.0"
Change "Idle Time-out (minutes)" to "0"
Press "OK"
Go to IIS hosted site "Advanced Settings" (it is positioned on the right side when clicked on site)
Change "Preload enabled" to "true"
Press "OK"
[I'm posting this to record what I actually found out after hours of painful trial-and-error.]
I have a website that I need to be "always running" (because in this case it has a Hangfire job that's responsible for kicking off a scheduled task every 5 minutes), and by default, websites are only started up when the first request is received.
So, how can I ensure that the website is started automatically? And, how can I configure this via the TFS release management tool?
[This answer isn't specific to Hangfire, but see the Hangfire documentation's discussion of this issue for details of how it affects Hangfire, but note that the recommended work-around is somewhat involved, and much more complex than the solution below. See also a separate and quite comprehensive discussion on the Hangfire support forum that gives several alternative solutions.]
In IIS, each website is associated with an Application Pool (App Pool). You can configure your App Pool to start automatically via IIS Manager by changing the "Start Mode" to AlwaysRunning in "Advanced Settings" for the App Pool:
However, starting the App Pool doesn't start the website (or websites) associated with it. The website does not get loaded until the first request is received.
In IIS8 (or IIS7.5 with an extension), a new setting was added that allows us to work around this. You can ensure that the website gets sent a request as soon as the App Pool starts by setting "Preload Enabled" to True in "Advanced Settings" for the website:
The combination of these settings ensure that the website will automatically start up when IIS starts, and immediately after the App Pool is recycled, etc.
But, how can you get those settings applied automatically as part of a TFS release pipeline, rather than having to remember to set them manually?
In your release definition, you presumably have an "IIS Web App Management" task, which sets up the App Pool and the website. In the configuration panel for this step, there should be an "Advanced" box with an "Additional AppCmd.exe Commands" entry field. You can use AppCmd to apply the settings described above.
AppCmd has the most confusing command-line syntax I've yet seen outside of code-golf competitions, but here's the incantation that worked for me:
set config /section:applicationPools -[name='myAppPoolName'].startMode:AlwaysRunning
set app "mySiteName/" /preloadEnabled:true
Note that if you have configuration variables defined for your App Pool name and website name, then you can use those rather than hard-coding the name, such as:
set config /section:applicationPools -[name='$(appPoolName)'].startMode:AlwaysRunning
I hope this helps somebody... Thanks for listening :-)
I noticed I have multiple functions running but never ending because they never get to the context.done() call. (This is a NodeJS function).
How can I stop these running functions without having to delete the entire function?
Disabling the function in the Manage tab prevents it from starting more, but doesn't end existing instances.
Kudu doesn't give me access to TASKKILL.
You have the ability to simply restart the Function App site, which will kill any functions (Function App Settings > Go To App Service Settings > Restart).
If you are running on a dynamic plan, please make sure you have upgraded to the latest version of the runtime, as a timeout feature is now in effect and will prevent functions from executing indefinitely.
For automation purposes, you can use the Azure CLI 2.0 (local azure shell) which makes this so much easier than clicking around in the portal blades.
This also works in the portal cloud shell if so desired.
Option #1: Restart Entire Function App (via Azure CLI)
az functionapp restart --name <functionappName> --resource-group <resourceGroup>
You can also restart the function app by killing the running w3wp.exe process - there is a watchdog that will automatically restart it.
Option #2: Restart IIS Worker Process (via Powershell)
#powershell kill -name w3wp
Kudu will allow you to do this manually via Debug Console and entering the command above or clicking thru Process Explorer->Properties->Kill.
Note: Killing the IIS worker process is all that is required as any spawned child processes will also be terminated (dotnet.exe, node, etc.)
This is the order of clicks starting from the portal home page to restart a function app in azure:
-> Function Apps (Found on the very left-hand sidebar, or on dashboard)
-> yourFunction (mine is called 'myFunction')
-> Platform Features (found near the top right of the screen)
-> All Settings (found under the General Settings section)
-> Restart (found near the top of the screen)
It seems the portal has been updated as I couldn't find the Restart button using the given instructions.
As of 17/7/2020 you can restart a Function app by navigating to the App Service page then clicking the Restart button which is found in the Toolbar:
I just stopped an Application Pool in IIS. When trying to start it, IIS complains that,
The service cannot accept control messages at this time. (Exception from HRESULT: 0x80080425).
What gives? Whence did this error come?
Looking at the Event Viewer > System shows these warnings:
A worker process '1456' serving application pool 'MyAppPool' failed to stop a listener channel for protocol 'http' in the allotted time. The data field contains the error number.
A process serving application pool 'MyAppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '10592'. The data field contains the error number.
A process serving application pool 'MyAppPool' exceeded time limits during shut down. The process id was '10516'.
This resolved itself after about 5-minutes, at which point we tried to restart the website, and received:
The World Wide Web Publish Service (W3SVC) is stopped. Web sites cannot be started unless the World Wide Web Publishing Service (W3SVC) is running.
So, we started the W3SVC service, and then we could start our website.
This helped me: just wait about a minute or two.
Wait a few minutes, then retry your operation.
Ref: https://msdn.microsoft.com/en-us/library/ms833805.aspx
The error message could result due to the following reason:
The service associated with Credential Manager does not start.
Some files associated with the application have gone corrupt.
Please follow the steps mentioned below to resolve the issue:
Method 1:
Click on the “Start”
In the text box that reads “Search Program and Files” type “Services”
Right click on “Services” and select “Run as Administrator”
In the Services Window, look for Credential Manager Service and “Stop” it.
Restart the computer and “Start” the Credential Manager Service and set it to “Automatic”.
Restart the computer and it should work fine.
Method 2:
1. Run System File Checker. Refer to the link mentioned below for additional information:
http://support.microsoft.com/kb/929833
In my case, the VS debugger was attached to the w3wp process. After detaching the debugger, I was able to restart the Application Pool
I stopped the IIS Worker Process (in task manager), and then started the IIS again.
It worked.
I killed related w3wp.exe (on a friends' advise) at task manager and it worked.
Note: Use at your own risk. Be careful picking which one to kill.
Restarting the machine worked for me but not every time.
If you are really stuck on this then follow below steps
Open Task Manager
A window will open. Click on Details tab.
Search for the process name you wanted to restart/stop.
Select process, right click on it, select End task option.
A confirmation dialog box will appear. Click on End process button.
Now try to restart your service from Services.msc window.
I forgot I had mine attached to Visual Studio debugger. Be sure to disconnect from there, and then wait a moment. Otherwise killing the process viewing the PID from the Worker Processes functionality of IIS manager will work too.
Restarting the IIS windows service (World Wide Web Publishing Service) and then starting the application pool has worked for me. However, as the top answer suggests it may have just been the waiting that caused it to subsequently work.
I had this issue recently,
Problem statement:
Mine was a windows service that I run locally by attaching VS debugger. When I stop debugging and try to restart/stop the service (under services.msc) I used to get the mentioned error.
Solution:
Open up Task manager.
Search for the service (based on the exe name and not service name, for those that are different).
Kill the service.
On doing the above the service is stopped.
Being impatient, I created a new App Pool with the same settings and used that.
I kept having this problem whenever I tried to start an app pool more than once. Rather than rebooting, I simply run the Application Information Service. (Note: This service is set to run manually on my system, which may be the reason for the problem.) From its description, it seems obvious that it is somehow involved:
Facilitates the running of interactive applications with additional administrative privileges. If this service is stopped, users will be unable to launch applications with the additional administrative privileges they may require to perform desired user tasks.
Presumably, IIS manager (as well as most other processes running as an administrator) does not maintain admin privileges throughout the life of the process, but instead request admin rights from the Application Information service on a case-by-case basis.
Source: social.technech.microsoft.com
I would like to write a script to start IIS server automatically if it is stopped.
You can use the IIS Admin Scripts to query the server, and then start it if you need.
The script is located in %systemroot%\system32.
To query you server, just run IIsWeb.vbs /query w3svc/1 from a command line.
If it's not running, then you can run IIsWeb.vbs /start w3svc/1 to start it.
Here is an article with more information on these scripts.
you can look for w3wp.exe in the process list (if it's IIS6)
you can always try "iisreset /start" - I believe, it works even if IIS is already started
take a look at the scripts provided by Microsoft in C:\Inetpub\AdminScripts (assuming default install location), there is startsrv.vbs, startweb.vbs - both do a good job
One simple thing you can do if you are worried about iis not restarting after it fails is to set the services responses. If you go into services and then look at the properties for iis, you will see a recovery tab. Change each of the failure options to restart the service. one thing you could also do is create a batch file that includes
iisreset
and set the option to run program and have that be the program you select.
Found some code here: https://social.msdn.microsoft.com/Forums/en-US/5a01d88b-2b7c-4d0b-bce0-9b90a236b64a/how-to-check-if-iis-is-running?forum=asmxandxml
Example:
Dim sc As New System.ServiceProcess.ServiceController("World Wide Web Publishing Service")
If sc.Status.Equals(System.ServiceProcess.ServiceControllerStatus.Stopped) Or sc.Status.Equals(System.ServiceProcess.ServiceControllerStatus.StopPending) Then
' Start the service if the current status is stopped.
sc.Start()
Else
' Stop the service if its status is not set to "Stopped".
sc.Stop()
End If