I created a webapp with blazor serverside with a scheduler in my app using Hangfire. It's hosted in a IIS 8.5 on windows server 2012.
I already did all the settings to make sure my blazor app dont stop and dont recycle (idle=0,startmode,Regular Time Interval...) so the sheduler is always running. And all work good.
But if there is any server reboot, i need to restart my Hangfire server to restart the sheduler inside the app (just with single ping of the url in a browser)...
Like we can see on the screen, the hangfire server dont start until i ping my blazor's URL in a browser...
So you implemented all steps outlined in the hangfire documentation including preload and applicationInitialization?
Step 5 is persisted in the web.config of your application. To make sure it is not overwritten on deployment, one can put a web.config with the respective configuration under source control.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
<!-- Add this node to web.config -->
<applicationInitialization doAppInitAfterRestart="true">
<!-- Only needed when website contains multiple child apps -->
<add initializationPage='/hangfire',hostname='' />
<applicationInitialization />
</system.webServer>
</configuration>
Finally, if you use the app_offline.htm during deployment either directly or indirectly through the Azure DevOps Pipelines deploy task, then after the app_offline.htm is removed, only the next request restarts the app. In that case you need to fire a warm-up request manually. You can use a more elaborate warm-up script or this one-liner in your deployment pipeline.
curl https://my-page.com/
I think this is primarily an IIS thing, and what you want is to set the Application Pool in IIS to AlwaysRunning, so instead of starting up the worker process on the first web request it starts the worker process as soon as IIS starts.
See this SF answer
Related
I developed a web api in asp.net core version 1.0.1 using visual studio 2015, when I published the web api in IIS 10 of the same pc where it was developed, everything works correctly. The problem arises when I copy and paste the publication folder of the web api to a different pc, the browser shows the error 500.19 Internal Server Error, error code 0x8007000d, "The requested page can not be accessed because the related configuration data for the page is invalid ", which leads to some problem in the web.config.
I do not think the version of IIS is the problem because moving from IIS 10 to IIS 8 or from IIS8 to IIS 10 gives the same error, and the same happens between two pcs with IIS 10.
I have already reviewed several related issues, like, The element 'system.webServer' has invalid child element 'aspNetCore', and others related to web.config file where it seems the error is found. The web.config file in the development environment is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
After publish the web api, the web.config file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\buildingSecureWebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>
This web.config file has the same content no matter what computer was publish.
Some idea of what the solution to my problem may be, I need to mount the web api in any version of windows and until now it only works correctly on the pc that was developed.
To get a more detailed error message:
Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site.
Verify that the application pool has write access to the logs directory and
Verify that `stdoutLogEnabled="true".
If you have verified all 3 of these items, then you should get log entries that will contain a more detailed description of the error
What could cause a "500.19 Internal Server Error, error code 0x8007000d" error?
.NET Core hosting bundle is not installed on the webserver where the site is deployed. To remedy this, obtain this download .NET Core Windows Server Hosting bundle
You may also want to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
Control Panel > System > Advanced System Settings > Environment Variables. highlight "Path", click 'Edit' and verify that the path to the dotnet folder is present. If it isn't, add it. Do the same for both the User variables and System variables. Restart your machine and try again.
I configured IIS ApplicationInitialization as recommended in the documentation
add initializationPage='/warm-up'.
I implemented a /warm-up endpoint on my app deploy it to both staging and production slots.
When the app starts/restarts/swap the endpoint is NOT called because I can't see it in the logs.
When I hit the endpoint manually, it works fine!
What I'm trying to achieve is:
When I start/restart/swap my app
I want a page (/warm-up) to be called in order to preload the app
So the first call from a real client doesn't have to suffer from the app loading time
Currently, I implemented a service that runs when the app starts (IStartupfilter)
But the app, hence the filter, is not running before a first request hits the server!
So I want to hit the server instance as soon as possible with appInit
We have more than 5 instances at some time of the day
initializationPage is an IIS thing, it will not help you start up the ASP.NET Core application before the first request hits.
Instead, what you will need to do is configure the Application Initialization Module for ASP.NET Core. According to this documentation, you will need to enable the IIS Application Initialization module (which you probably already did if you could configure the initializationPage) and then modify the generated web.config to include the applicationInitialization node to the webServer section:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
<applicationInitialization doAppInitAfterRestart="true" />
</system.webServer>
</location>
</configuration>
This should start the ASP.NET Core application as soon as the IIS website starts, so there should be no delay. You will not need an initialization page then and can just initialize the ASP.NET Core application as the host starts.
I have a web hosting which supports ASP.NET Core 2.2. I tried to publish my own asp.net core 2.2 project in it and it worked with just design. And then I added Identity in the project and I added the same database in the host (exported and imported db which created with migrations). I changed the database connection as well, but when I'm trying to publish the same project it gives me this error :
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
Here is my connection string :
"ConnectionStrings": {
"IdentityConnection": "Data Source=.\MSSQLSERVER2016;Database=ChatIdentity;Integrated Security=False;User ID=halitkal;Password=*;Connect Timeout=15;Encrypt=False;Packet Size=4096"
},
Here is my webconfig file :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\ChatSite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 028aa0e3-c5ef-4f5c-87ac-e8de39c5ca44-->
Turn on the stdout logs by changing the next line in the web.config
aspNetCore processPath="dotnet" arguments=".\ChatSite.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
Don't forget create a folder named logs in the same directory that you have your dll files.
Then reboot the application (Application pool if you´re hosting in IIS) then make an http request and then check for generated log, that should give to you the detail about the error.
If that not works, make sure you have the right runtime installed.
I have a web.config that looks like so, and is added as a link to a number of applications in my solution:
<configuration>
<!-- For more info to customize the asp.net core module see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<!-- As connection proxy request contains double escape sequence, we need to enable it. background Azure ARM Apis are enabled it. -->
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout"/>
</system.webServer>
</configuration>
One of the services has potential for long running single requests, and so I want to increase the IIS request timeout for that service, which can be achieved by adding to the aspNetCore configuration like so:
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" requestTimeout="00:10:00"/>
However, given this web.config is otherwise shared and I don't want to alter the behaviour of my other apps, I'd like configure this via an application setting from my arm templates.
When I attempt something like the following, I get an error that %REQUEST_TIMEOUT% is not a valid time, and deploying fails to startup the webapp.
How can I enable app settings to insert into the request timeout field?
Azure App Service doesn't allow increase requestTimeout, the limit is 230 seconds - see Why does my request time out after 230 seconds?.
I would recommend looking at the Polling (link2) - it is the standard REST-pattern to process long running op.
Other resources:
How can increase Azure App Service 230 sec request time out
Increase azure web app request timeout
If you are using Azure DevOps, some options during deployment:
"XML variable substitution" can be enabled during deployment if you are using Azure App Service deploy task.
Add powershell task to change the request timeout with the value from a pipeline variable.
Note: If the requestTimeout is set to say 10 mins in web.config, the request will continue to run to completion even after 230 seconds. But the client will be terminated by the app service at 230 seconds and will receive an error.
I've read many similar issues but none of the resolutions solved my problem. So, here is my case.
I have a NET Core 2.1.1 app that runs beautifully within VS2017 and when published to my desktop running Win10 Pro and IIS10, i.e. running it outside of VS2017. But, when I deploy the app to a remote server Win2012 R2 with IIS8.5, I get the following issues with it.
I have followed different pages on deploying net core apps like this one.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.1
When attempting to reach the site I get error 500 Internal Server Error.
IIS manager complains about the generated web.config when clicking on any of the site's settings e.g. Net authorization, Net Error pages etc...
Even when setting the stdoutLogEnabled to true, I don't get any log files. I even tried adding custom details flags in the web.config yet still nothing changed.
This is the generated web.config, and I hope someone points me in the right direction.
Thanks.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\eSignWebMVC.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 72897161-bbbb-4f20-a12c-7f33922ea6bc-->
So I finally got this to work and I HAD to install the latest bundle v2.2.2 even though my app is targetting Net Core 2.1.1, but Microsoft's horrible technology still didn't make the app to run with the 2.1.1. bundle. Total waste of time and effort on such a stupid thing!!
What's the meaning of still providing the prior bundles if none of them does anything?