We are hosting an ASP.NET Core application on an Azure App Service (Web Apps).
Our individual instances take some time to "preload" the required data needed to process requests. But when scaling out, requests will be routed to the instances still being prepared.
How does the App Service load balancer decide when an instance is ready and requests can be routed to it? Is there a way to prevent routing to some specific instance until we deem it ready?
Try using the applicationInitialization node in your web.config. This instructs IIS to to issue warm-up requests to URLs that you designate before the application receives its first request.
I have used this on slow swaps before. But from reading the docs on IIS here, it looks like it'll also work for new instances. I haven't tried this when scaling out though - let me know if this works for you.
Here's example code of using it within the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<applicationInitialization>
<add initializationPage="/pagetowarmup1.php" />
<add initializationPage="/pagetowarmup2.php" />
<add initializationPage="/pagetowarmup3.php" />
</applicationInitialization>
</system.webServer>
</configuration>
Related
We host our Asp.Net app as Azure App Service and using scaling-out capabilities. The issue is that when we add new instances these new instances start to server requests almost immediately - before warming up process is done. I am using application initialization module with the following configuration:
<applicationInitialization remapManagedRequestsTo="/warmup.html">
<add initializationPage="/start.ashx" />
</applicationInitialization>
And once we scale-out the plan e.g. from 3 instances to 4 and requesting the site, approximately 1 of 4 times I see my warmup.html - therefore I assume that newly created instance considered by the balancer before it is actually warmed up.
Please note: our site does not require HTTPS, so this should not be an issue.
The question: how can we prevent warming up instances from being requested until the are ready to serve requests?
You may add add a section to your web.config that tells IIS to ping this route (initializationPage) for status, this should help in making the instance available until the warm-up is completed.
<system.webServer>
<applicationInitialization remapManagedRequestsTo="/warmup.html">
<add initializationPage="/wait-for-init.php" hostName="appinit-site.azurewebsites.net"/>
</applicationInitialization>
<system.webServer>
Check this blog link: https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/
See: https://www.iis.net/downloads/microsoft/application-initialization
Also, you may use a external cache provider like Azure Cache for Redis, your new instance can just point to this external cache without having to reload the data.
Also check this blog might be helpful.
I am deploying ASP.NET Core Web API for the first time.
I am facing issues and confused on few things.
1) I followed this link Host ASP.NET Core Web API and have no issues until step 5. My Core Web API has Swagger UI and UI not showing up.
2) I followed this link Deploy ASP.NET Core to IIS and in step 3 I am not sure how he gets Add Application. My IIS always show Add website.
I followed this link too Host ASP.NET Core on Windows. I tried from 2 days haven't get working on IIS.
I deployed using Web Deploy and Folder too. None of them worked
This is my Web Config file
After Diagnostics, I am here. Runtime doesnot match. I tried to install from that link and still not working.
<?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=".\SampleCoreApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
The first link is talking about hosting the ASP.NET Web API and not ASP.NET Core Web API.
When you are hosting ASP.NET Core app/api, you need to set the .NET CLR version of the application pool to No Managed Code
This is also mentioned in the Step 3 of the second link. It's creating an application under the Default Web Site, that's where you see the Add Application option. It's not necessary to create an application under the Default Web Site.
You can either create the Application Pool first and set it to No Managed Code. Then, when adding a new website, you can select this application pool
Or, add a new website first. That will create an application pool automatically with the same name as the web site. Then, you edit the application pool and set it to No Managed Code
I hope that helps.
I have two different applications which I want to deploy on the same Azure WebApp like this:
webapp.azurewebsites.net/api/ <-- run the Java REST API here
webapp.azurewebsites.net/site/ <- put the Angular2 app here
Problem
Both apps are deployed on the server but currently I'm only able to get the REST API running with a web.config like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false"/>
<conditions>
<add input="{HTTPS}" pattern="off"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-jar D:\home\site\wwwroot\webapps\rest-api.war">
</httpPlatform>
</system.webServer>
</configuration>
but I'm not able to reach the Angular2 app on the server and I can't find documentation how I would configure the Java application and the Angular2 app at the same time.
I also tried to achieve this with the Virtual applications and directories settings from the Azure dashboard under Application settings - but it didn't work and I can't find a decent documentation of how I would achieve this, or if this is even possible with setting the Virtual applications and directories.
I tried to move the Angular2 site around but was not able to configure the server so that the Angular2 app is accessible while the Java application is running.
Question
Can someone point me to a good documentation on how to achieve this, or describe the deployment process in detail (with regard to the configs, e.g. the Application settings from the Azure Dashboard and the web.config file)?
Per my experience, I think the best way for deploying multiple Apps on Azure WebApps is to set the Virtual applications and directories of Application Settings for your Azure Webapp, please see the figure below.
As reference, please refer to the answer of the SO thread Add virtual directory to existing website on Azure.
Virtual Directories are supported for Azure Websites. See Configuring Azure Websites for what you can do through the Azure Management Portal. From the Azure Portal, click on the Website and go to Configure, then scroll down to virtual applications and directories (the last config section). Just enter your virtual directory and the physical path relative to the site root and click Save.
Regarding the second part of your answer, when investigating the subject I found this blog post to be the best explanation of how the Application Settings from the dashboard interact with the Web.config file:
https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
In particular -
If the application setting(s) happen to already exist in your web.config file, Windows Azure Web Sites will automatically override them at runtime using the values associated with your website.
So the Application Settings tab in the Azure portal will take precedence over your web.config values.
I'm trying to serve some static content (Jekyll if that's relevant) out of an Azure web app. Said web app can also be served out of an Azure CDN. Both urls (CDN and app) work fine.
A chrome audit complains that the assets of my page are missing cache expiration dates. Fair enough.
But uhhh...how do I set cache expiration for an Azure web app or an Azure CDN endpoint?
Can they be set somewhere in the HTML? Can they be set somewhere in the wilds of the Azure console?
Most google answers (including SO) explain how to set the expiration via a web.config file, but I don't have one of those, because my application is not a .NET app.
The answer to my question turns out to be dead simple. I just needed to add a web.config file to the root of my jekyll app. Like so:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMaxAge="365.00:00:00" cacheControlMode="UseMaxAge"/>
</staticContent>
</system.webServer>
</configuration>
Coming from a Linux background, I assumed the web.config was a .NET thing, but nope. It sets the IIS (that is, Azure) configuration.
I have a web app running a old ASMX service that I want to limit access to for only other apps and services within my azure environment.
Is there any easy and cheap way to do this?
App Service Environments seems like it does this, but they seem rather expensive for this small purpose. I would be cheaper with a VM that I can configure the firewall on.
If you know the IP-Ranges you can use web.config file in root of your app:
<security>
<ipSecurity allowUnlisted="false"> <!-- this line blocks everybody, except those listed below -->
<clear/> <!-- removes all upstream restrictions -->
<add ipAddress="127.0.0.1" allowed="true"/> <!-- allow requests from the local machine -->
<add ipAddress="81.116.19.53" allowed="true"/> <!-- allow the specific IP of 81.116.19.53 -->
</ipSecurity>
</security>