Problem #1: I have a classic cloud service running a single web site role. I would like to differentiate between the way it is debugged locally versus how it is deployed to the cloud. Specifically I would like the local site to run on HTTP and the cloud service to run on HTTPS. The main reason for this is that we don't want to have to install the same cert on all the developers' machines. However, the endpoints are defined in the common "ServiceDefinition.csdef", NOT in the two "ServiceConfiguration.cscfg" files ("local" and "cloud"). So, how do I set up different endpoints for local versus cloud?
Problem #2: I would like, especially in the cloud, to have a site running on HTTP that simply redirects the user to the HTTPS site. How would I set that up?
I realize these questions may not have sufficient detail, but I didn't want to write a book. Please feel free to ask for clarification.
Thanks a lot in advance!
Partial answer to your questions:
Problem #2: I would like, especially in the cloud, to have a site
running on HTTP that simply redirects the user to the HTTPS site. How
would I set that up?
For this, you can simply rely on web.config transforms. In your web.release.config you can set a redirection rule which will redirect http requests to https. Something like the following:
<rewrite>
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Similar thing would just not be present in your web.debug.config (or web.config).
Specifically I would like the local site to run on HTTP and the cloud
service to run on HTTPS.
For this, the way I have handled it in the past when I worked on Cloud Services is basically I created separate cloud projects for each environment (WebApp.Azure.Dev, WebApp.Azure.Prod etc.). This way I would get separate csdef file for each environment.
Related
We have a Web App hosted in Azure. We have a staging deployment slot that the web app is on and the URL provided is a .internal link that is not accessible. How do we create an accessible URL for the deployment slot. Thank you!
The staging site deployed would have a separate URL on the slot's resource page. The deployment slot has its own host name and is also a live app. Which is publicly accessible by default, however, we have ways to limit public access to the deployment slot, for this checkout 'Azure App Service IP restrictions' – For it to work, IPv4 address ranges that start with 10. and 100. are internal to your deployment. You should allow them to connect to your app.
You have stated that the staging site is inaccessible, please do share more details on the error you may be receiving and how exactly are you accessing the site.
Some common issues and ways to mitigate:
During custom warm-up, the HTTP requests are made internally (without going through the external URL). They can fail with certain URL rewrite rules in Web.config. For example, rules for redirecting domain names or enforcing HTTPS can prevent warm-up requests from reaching the app code. To work around this issue, modify your rewrite rules by adding the following two conditions:
<conditions>
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
<add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
...
</conditions>
Without a custom warm-up, the URL rewrite rules can still block HTTP requests. To work around this issue, modify your rewrite rules by adding the following condition:
<conditions>
<add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
...
</conditions>
Checkout the doc setting up App Service staging environment for more details on this topic.
I am new to Azure and currently host my node.js backend at another cloud provider, and I want to understand the steps I need to make in order to host it at Azure, without using Visual Studio Code.
It is a very easy question, yet it seems impossible to find an answer to.
I've seen the 5mins quick starts here;
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs
But in the guide, the site is directly deployed to the web URL;
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs#browse-to-the-app
But none of them explains the fundamentals on how Azure runs the process.
How does Azure start my backend app? Where do I configure that, what is needed?
That's not mentioned in the guide at all.
Is there a guide for what exactly what files are required and how to configure them in order to start my backend?
Microsoft Azure feels like a black box right now, any documentation is much appreciated!
As I know, you need to configure web.config if you want to run nodejs app on the Azure.
I followed this sample node.js app: nodejs-docs-hello-world and deploy it to Azure. It works fine,you could refer to web.config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="scripts.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="scripts.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I suggest you navigating to the KUDU url: https://<your app name>.scm.azurewebsites.net/DebugConsole and go to site\wwwroot to upload your files so that the files are contained within a directory.
Or discard zip deploy temporarily, just drag the local files directly to the d:home\site\wwwroot directory.
I am trying to deploy an Azure App Service from Visual Studio 15.2. Specifically I am trying to deploy this following service: https://github.com/Microsoft/Azure-SQL-DB-auditing-OMS-integration to ingest audit logs from SQL Data Warehouse to OMS. However, due to security concerns, we would like to do so without creating a public endpoint, a url. We have tried configuring it in a VNet but it does not allow you to do so unless the VNet has a public gateway.
Configure Azure App Service without public URL
As far as I know, we couldn't configure Azure App Service without public URL. If you created a web app, it will auto provide public endpoint for user to access.
Here are two work around.
I found the github application just use the web app's webjobs.
One way:
If you don't need any web site, just use the backgourd process to run the webjobs, you could choose azure function which uses WebJobs SDK itself but doesn't require an App Service to be configured for it.
Second way:
Normally we run WebJobs in a Azure App Service web app, and that Azure App Service web app can be accessed/browsed via URL. If you want to prevent users from browsing to that Azure App Service web app, you can add a rewrite rule to site’s web.config to block web access.
The web.config is like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
<match url=".*" />
<conditions>
<!-- Enter your staging site host name here as the pattern-->
<add input="{HTTP_HOST}" pattern=".*" />
<!-- Enter your white listed IP addresses -->
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>
<!-- Add the white listed IP addresses with a new condition as seen below -->
<!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"
statusDescription="Site is not accessible" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
More details about how to add the web.config to your web app, you could follow this steps:
1.Open kudu tool in web portal.
2.Open cmd console and locate the \site\wwwroot folder.
3.Create web.config and copy the settings in it.
4.When we accessed the web site, you could find this:
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 have an Ember application that is using CORS to access APIs on different subdomains.
Since IE8 and IE9 don't have full CORS support I need to create a proxy to access the APIs.
The Ember application is deployed on an Azure Website and the API's are Web Roles. I have tried to create a proxy using URL rewrite but I only get a 404 Not Found.
I would like the following behavior
https://www.cloudstorez.com/rewrite/cms/public/designs
Rewrites to
https://cms-public.cloudstorez.com/designs
The URL rewrite looks like this
<rule name="Rewrite to APIs" stopProcessing="true">
<match url="^rewrite/([^/]*)/([^/]*)/(.*)" />
<action type="Rewrite" url="https://{R:1}-{R:2}.cloudstorez.com/{R:3}" />
</rule>
If I instead do a corresponding redirect it works fine.
<rule name="Redirect to APIs" stopProcessing="true">
<match url="^redirect/([^/]*)/([^/]*)/(.*)" />
<action type="Redirect" url="https://{R:1}-{R:2}.cloudstorez.com/{R:3}" />
</rule>
Is there something wrong in my rewrite or are there restrictions on Azure Websites regarding URL rewrites or accessing other servers?
Rewriting to External URLs is called Reverse Proxy. This functionality is achieved in a combination of ARR + Url Rewrite. These are two separate modules of IIS.
Reverse Proxy is not enabled by default on Azure Web Sites. But there is a trick to enabled it. Ruslan Y. from IIS Team (or former IIS team) has written a blog post on how to enable reverse proxy on Azure Web Sites here.
Note - I haven't personally tested the trick, so cannot say if it still works (Azure Web Sites has much evolved since Ruslan's blog and this feature might have been disabled), but still worth giving it a try.