Wednesday, December 5, 2018

D365FO / Azure - Create website redirect in azure to handle supplemental environment url changes

Currently while dealing with D365FO supplemental environments within LCS that are all hosted on a single machine anytime we update them and there is an error microsoft's recommended fix is to stand up a new environment. Because of this the url will change and you need to notify your users. In order to handle this scenario so our users do not need to worry about a new url you can create a redirect website in azure that you can point to whatever url you want and if your users bookmark these urls instead of the direct ones then you don't need to worry about who has what book marked.

Azure portal 

Step 1. In the Azure portal you need to create a webapp. You do this by going to "Create a resource" and then choose a web app.




Step 2. In the newly created webapp go to Advanced tools (Kudu)


Step 3. In Kudu go to Debug console > cmd


Step 4. Browse to /site/wwwroot and click on the add ("+") button and choose to create a new file and name it web.config

Step 5. Click on the edit button for the web.config file and add in the following and hit save.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect test enviornment" stopProcessing="true">
                    <match url="^test" />
                    <action type="Redirect" url="https://testurl.cloudax.dynamics.com" redirectType="Permanent" />
                </rule>   
                <rule name="Redirect stage enviornment" stopProcessing="true">
                    <match url="^stage" />
                    <action type="Redirect" url="https://stageurl.cloudax.dynamics.com" redirectType="Permanent" />
                </rule>
                <rule name="Redirect dm enviornment" stopProcessing="true">
                    <match url="^dm" />
                    <action type="Redirect" url="https://datamigrationurl.cloudax.dynamics.com" redirectType="Permanent" />
                </rule>
                <rule name="Redirect qa enviornment" stopProcessing="true">
                    <match url="^qa" />
                    <action type="Redirect" url="https://qaurl.operations.dynamics.com/" redirectType="Permanent" />
                </rule>
                <rule name="Redirect header" stopProcessing="true">
                    <match url=".*" />
                <action type="Redirect" url="https://www.google.com" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>    


Step 6. After hitting save you should now be able to access your azure web app in the following manner

https://yourwebappurl.com/test
https://yourwebappurl.com/qa
https://yourwebappurl.com/stage
https://yourwebappurl.com/dm

and they should now forward to their respective website.

If you do not include a /* tag and just put https://yourwebappurl.com then it should forward you to google.com as well





No comments:

Post a Comment