Azure Web apps provide a rapid and easy way to deploy web applications and publish them on Internet or attach them to your Azure virtual network, so they can be accessed by users.

In this post i will detail how to create an Azure Web app which the purpose is to make URL Rewrites.

Example :

  • We have an URL which i want to distribute among users so they can access it
  • The URL is too long, and users will have difficulties memorizing this URL. The aim is to use a simplest URL ( which will be communicated to users. And we want that some mechanism redirect this URL to the desired target URL.
  • Using DNS CNAME is not possible since we cannot create a CNAME for a composed URL

The solution is to use an URL rewrite solution, which will redirect the simple URL to the composed URL. We can achieve this using an Azure Web app.

The following are the steps which will be conducted during this walk-through:

  1. Create an Azure Web app
  2. Configure the Azure Web app
  3. Create the URL Rewrite Configuration file
  4. Upload the configuration file to the Azure Web app
  5. Create a Public CNAME DNS record which redirect the Simple URL to the Azure Web App URL

Create an Azure Web app

Connect to the Azure portal and sign in using a subscription Admin account

NB : I’m using the Azure preview portal but the classic portal can be used too.

Go to New + –> Web + Mobile –> Web App


The Web app creation wizard will show

 Type the following information :



Example value

Web app

A suffix for the Web App public URL.

This will compose be the Public URL Name for this web app. It will be appended to ‘’, so choose a significant suffix. This suffix is public, that means, you may enter a suffix which is already used by another customer. I recommend including your enterprise name within the suffix since it’s hard that someone else used it.

The CNAME  that will be configured later will resolve to  this Public URL

Suffix : MyAzureURLrewrite

Public URL :


Choose the Subscription where to place this Web app


Resource Group

Choose and Existent Resource Group or Create a new Resource Group for this Web app


Now, click on App Service Plan



We can create a new Service Plan or use an existent Service Plan

To simplify the description, a Service Plan defines the properties of the underlying compute resources that hold your Web App. Consider the service plans  as different machines with different performances level. A service plan can host one or more Web apps (just like a machine can hold one or more IIS websites)

If we decide to create a new Service Plan, click Create New

Type the Flowing Information



Example value

App Service plan

Choose a name for your service plan



Choose a location where to place this Service Plan (This where the Web App will be hosted too)

North Europe

Pricing Tier

This allow you to choose between the different tiers. You can look here (Azure Service Plans tiers Pricing) for more information about the Service Plan tiers

NB: You can upgrade from one tier to another when needed

B1 Basic

Now, we can click on Create. You web app will start deploying.


First Configuration steps for the Web App

Go to Browse ALL –> Web Apps and select the Created Web App


2.1- Verify that the Web App is published

Click on the Web App URL. You will be redirected to the Web App. A page with the ‘This web app has been successfully created‘ should appear.


2.2- Add custom domain and SSL Certificate

Because we will not use the in the real life, and use instead, a custom URL containing your domain prefix (, we should declare which domains will be targeted on this Web app and which SSL Certificate will be used.

Go to All settings –> Custom domains and SSL



2.2.1- Add an External domain

Click on Bring External Domains


Add  domains prefixes. Example :

NB : As mentioned on the wizard, Azure must verify that you are the owner of this domain name. So you should create a CNAME in a public DNS provider that match your domain to the the Web app public URL ( –> or –>

2.2.2- Add the SSL certificate for the domain

Now that we successfully added our domains to the Web app configuration, we should bind a certificate which will secure your website when it’s accessed via URLs which contains our domain name.


In our case, we want to redirect to this Web App ( So the user accessing this web app will tape in the browser. The certificate have to match the the requested URL, that means

Click on Upload Certificate and upload a Certificate that match your requested URL. The certificate must be of the PFX format (with the Private Key)


NB : If we use this Web app as a redirect service for many URLs, this web App will receive requests on many names (, ,…), so to avoid uploading many certificates, you can use a wildcard certificate * (*

2.3- Setup the FTP parameters

Now, we need to configure the FTP user credentials in order to be able to connect (using FTP or GIT) to the Web App content.

Go to All settings –> Deployment Credentials




Example value

FTP/deployment user name

Type the User Name you would use. The user name can contain only letters numbers, hyphens and underscores, and must start with a letter.



Type a complex password


Confirm password

Retype the password


Configure the URL rewrite

After completing the previous steps, we can configure the URL rewrite service. The following steps will be conducted:

  1. Prepare the redirection configuration file
  2. Upload it to the Web application

3.1- Prepare the redirection configuration file

Download the following file (Web.config)

  • Open it with a text editor (Notepad or Notepad++)


  • Change the following information :



Example value


Type an identification name for this URL to be redirected



Type the URL of the application to which you want make redirect (the composed URL)


Type the URL on which the Web app will receive the request, the simple URL (You must respect the format, a ‘.’ is replaced by ‘\.’)


  • Save the file and keep the same name (web.config)

NB: If you have more than one URL to redirect, just add a new rule to the same file, by copying/pasting the Rule ‘section’


3.2- Upload the configuration file to the Web App

We will use FTP to connect and upload files to the Web app.

You can use the Windows Explorer or a FTP client like Filezilla (Download Filezilla)

In my Example i will use the Windows Explorer.

  • On the Web App blade, locate the FTP hostname and copy the URL (You can use the copy shortcut)


  • Open a Windows Explorer window and paste the copied URL. We will be prompted for the FTP credentials. Enter the credentials we already configured on the previous steps.


  • Go to site/wwwroot/ and paste the web.config file


  • You successfully created an URL rewrite Web app on Azure

NB: We may have to restart the Web App

Create the Public DNS CNAME record

This is the final step, you should now create a public DNS record which will redirect the desired URL ( to the Azure Web app URL (


The following is the content of the web config file.

                <rule name=”SimpleURL” patternSyntax=”ECMAScript” stopProcessing=”true”>
                    <match url=”(.*)” />
                    <action type=”Redirect” url=” appendQueryString=”false” redirectType=”Permanent” />
                        <add input=”{HTTP_HOST}” pattern=”SimpleURL\.samirfarhat\.com” />