I created a ARM template that creates App Service (web application) and Application Insights resource that is similar to this template (https://github.com/tomasr/webapp-appinsights). The App insights is connected to web app and everything works fine, the only problem is that app insights automatically generates requests to root of my web app as part of availability test that always return error because I don't have anything in the root path (even if I had, it is calling http instead of https url). There is nothing in the template that sets up this request, and if I go to availability properties, nothing is there. Is there a way to turn this feature off or configure it to call a valid URL?
In case it's Always On, the feature of App Service that keeps your app from going idle by pinging it with an HTTP GET to the root every once in a while, there is a way with Rewrite.
You can make a rewrite rule that has a condition that detects it's an Always On request, and if it is, make it hit another URL you specify instead.
Here is an example:
<?xml version="1.0" encoding="UTF-8" standalone="no">
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite AlwaysOn" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="^AlwaysOn$" />
</conditions>
<action type="Rewrite" url="/api/Online/Ping" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Original article I found this from: https://blogs.msdn.microsoft.com/benjaminperkins/2018/08/10/how-to-optimize-azure-app-service-alwayson-cold-start-warm-up-request/
If you have a rewrite rule that redirects HTTP to HTTPS, you should add this rule before that.
Related
I have an Azure website at site1.azurewebsites.net and a domain on GoDaddy for somesite.com
So I want to use my somesite.com domain to handle site1.azurewebsites.net I have followed Azure's instructions and set up
How would I change the URL it uses In Asp.net MVC Site ?
This is a DNS issue and fix.
Your AzureWebsite URL should be put down as the source for your CNAME record for your existing domain.
I.E # record points to site1.azurewebsites.com
When a user goes to your URL, they are delivered the content from the Azure URL, but still stay on the same URL.
Do not do the redirect answer with web.config, unless you want to change the URL of your site, to be the azure URL. A redirect is not the correct fix. Configuration of DNS records is
You could set the URL rewrite in your web.config file to redirect your Azure Web Site to custom domain name.
Here is an example code that helps you redirect to your custom domain.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://www.yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
For more details, refer to this blog post.
This has probably been asked many times, but I have a purchased domain (through 1&1 if that matters) foobar.com. I have setup custom domains in Azure and domain to forward to an azure app service I built, and that is working fine when someone goes to foobar.com. What I am seeing is if someone goes to www.foobar.com. they get an ugly web app not found (an Azure screen). What do I need to setup to make this redirect work. Do I need to update the domain/azure in someway? I have the following rule in my Web.config
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.foobar.com$" />
</conditions>
<action type="Redirect" url="http://foobar.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
I always solve this with CNAME not through web.config. Take a look if you followed the steps described in here:
https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-custom-domain-name-portal
I created web app named XYZ in MS Azure. It automatically created domain XYZ.azurewebsites.net. Then I bought and added a custom domain. The problem now is the XYZ.azurewebsites.net still shows what has been deployed to my domain MYDOMAIN.COM. How can I remove the default domain?
You can't remove Azure's DNS record - that is how everything for your web app is controlled/managed in Azure. You can add no-index and no-follow options for search engines and add a permanent redirect in your app from the Azure DNS to yours.
Alright, so after some googling, I found out this is a common problem with using Azure (shame MS doesnt makes life easier here).
I solved it by using permanent redirect in web.config from this thread
Getting mapped custom domain url in Azure
Thank you for taking interest
Petr
I was using the Web Application Gateway with my Azure App service and I found the below option of 'Access Restrictions' after that it stopped all the traffic on my default DNS link of https://SAMPLE.azurewebsites.net
Here is the way to look for 'Access Restrictions'
I added two rules to my web.config file. The first was a rule to perform a permanent redirect from the default domain to the custom domain. You can also throw a forbidden error message with HTTP status code 403. The second rule was an outbound rule to block search engine requests to the default domain.
<system.webserver>
<rewrite>
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^old-domain.azurewebsites.net$" />
</conditions>
<action type="Redirect" url="https://new-domain.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Noindex Domains">
<match serverVariable="RESPONSE_X_Robots_Tag" pattern=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^old-domain.azurewebsites.net$" />
</conditions>
<action type="Rewrite" value="NOINDEX, NOFOLLOW"/>
</rule>
</outboundRules>
</rewrite>
</system.webServer>
If your site is verified with Google under its Search Console, you can also temporarily remove a URL from search results; it lasts 6 months. Go to Removals, click the "New Request" button and then use a URL prefix as the option for blocking indexing; it will block all requests beginning with the URL instead of the root URL only. This request can take a little while to process. You can also submit a Change of Address request to let Google know you have changed site URLs by going to Settings > Change of address, where you can specify the old domain and new/moved domain.
My azure web application (myapp.azurewebsites.net) is mapped to a custom domain (client1.mycompany.com).
I will be mapping it to some more custom domains (client2.mycompany.com, client3.mycompany.com etc.) one per each client.
In web application I am using
HttpContext.Current.Request.Url.Host
to get custom domain address which is accessing the application. But it is sometimes returning myapp.azurewebsites.net instead of custom domain.
Any idea how I can custom domain url in Azure in reliable way?
As Admir said in his answer the default *.azurewebsites.net binding cannot be removed, but it is very easy to prevent users from using this domain name for your site.
<rewrite>
<rules>
<rule name="Canonical Host Name" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="client1.mycompany.com" negate="true" />
</conditions>
<action type="Redirect" url="http://client1.mycompany.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
*.azurewebsites.net is not removable which means it is out of your control if someone will access your website through that DNS binding, which explains why you get that when you attempt to inspect HttpContext.Current.Request.Url.Host.
Only thing you can do is to choose to ignore requests coming directly to that binding, by redirecting user to:
Custom page (i.e. 404)
Some default custom domain
I have a Wordpress-based web site hosted in Azure websites with a custom domain (www.mydomain.com) that is working great.
Now I want to let another domain (www.anotherdomain.com) respond to the same Azure website. But www.anotherdomain.com is an old website where its pages are no longer available either in new or old places.
This means I need to redirect any URL from www.anotherdomain.com to the root (home page) of www.mydomain.com without any http error messages.
Example: www.anotherdomain.com/products/blablabla.aspx to www.mydomain.com
I suppose I have to add some rewrite rules on web.config, but I have no idea on how to make them.
In addition, what would be the changes (if any):
1 - At my DNS zones for both domains
2 - Azure website domain configuration.
Thank you,
Igor
I think you will need to assign hostname www.anotherexample.com to the same wordpress site that hosts www.example.com by following instructions here.
After that you will need to add a redirect rule to your site that will redirect requests www.anotherexample.com to www.example.com:
<rewrite>
<rules>
<rule name="Redirect host name" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="www.anotherexample.com" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
If your new site is WordPress based so it will very easy for you. just go to DNS management zone and add entry of domain forwarding and off Path Forwarding.No need to do any change in Azure site settings.
if you will turn On Path Forwarding even then WordPress will handle and it will not give any http error.
for example my site is http://subhashsingh.com and from http://study-desk.org you can get the same site even you will hit a wrong url like http://study-desk.org/12/new .