Website Redirect – Azure WebApp

During our Office365 migration, we had a need to setup a temporary website redirect for OWA from our old TMG box to our new 2016 Exchange Hybrid box.

This doesn’t get much easier in Azure simply, create a webapp and configure the website.config file with the redirect as below – simple right?

First of all make the necessary changes to Public DNS entries – for this example I created a subdomain a record:

I also have a wildcard cert for the *, which will also need to be uploaded to Azure.

Now in Azure goto:

Azure > App Services  > +Add

Create the name of the webapp – In this example I named it ‘owa-redirect’

2018-05-30 08_08_08-Clipboard

Once created configure the custom domains and also upload the wild card certificate:

2018-05-30 08_09_14-Clipboard

Now we are ready to obtain the web.config file and edit it with the redirect code.¬† If you click on ‘Overview’ in the webapp you will have the option to download the publish file – click on ‘Get publish profile’.¬† Once this has been downloaded open it with a text editor like Notepad++.

Note the ‘userName’ and ‘userPWD’ – this is required to connect via ftp – the ftp address can be found under the overview section:

2018-05-30 08_22_20-Clipboard

Connect via FTP by using your favour FTP client, I’m still a fan of FileZilla.

Browse to site\wwwroot and download web.config

Edit the redirect in web.config file and upload/replace file using the redirect code below:

<?xml version=”1.0″ encoding=”utf-8″?> <configuration> <system.webServer> <httpRedirect enabled=”true” destination=”; httpResponseStatus=”Permanent”/> </system.webServer> </configuration>