Thursday, 10 August 2023

How to configure a custom URL to access Azure WebApp

By default, all users access Azure web applications via their HTML5 compactible browser using Microsoft URL which is the same for all customers (https://rdweb.wvd.microsoft.com/webclient/index.html).

Being that this URL is a bit long, and it is not quite easy to memorise, it would be helpful to set a Custom URL using the corporate domain name. Something like https://desktop.essex.ac.uk or any preferred subdomain name.

In this article, Azure Functions will be leveraged to allow you to execute your code in a serverless compute platform using the consumption plan pricing includes a monthly free grant of 1 million requests, this would save you from the hassle of creating, configuring, and securing an IIS virtual machine and well as the cost of compute.

Below are topics covered in this article:

Create an Azure Function App

Create a Function App HTTPTrigger

Enable Azure Function App Proxy

Create Azure Function App Proxy

Create Custom domain

Update DNS service with custom CNAME records

1.    Go to www.portal.azure.com and sign in with your credentials.

2.  In the App search bar, type Function App and select the Function App service.

 

3.  Click “+ Create” to create a Function App in the Azure Portal

    

                              
4.   In the Basics Tab, fill the required information as desired.

            
            ·       Select the subscription

·       Choose or create a new Resource Group

·       Assign a name to the Function App

·       In the “Do you want to deploy code or container image?” section, select “Code”

·       For the Runtime stack, choose .NET and select version 6 (LTS)

·       Select the desire region to deploy the Function App

·       For the Operating System, choose Windows

·       On the Hosting plan, choose Consumption (Serverless)

·       Click “Next: Storage >” create or select a storage account

 

 5.  In the Storage Tab, select an existing storage account for the Function App or create a new one. Click “Next: Networking >”

6.  In the Networking Tab, select On in the “Enable public access” feature to ensure internet-based traffic can access the Function App and click “Next : Monitoring”

7.  In the Monitoring Tab, select “Yes” to enable Application Insights. Select an existing Application Insights workspace or create a new workspace. Click on “Next : Deployment >”

8.  In the Deployment Tab, select either “Enable” if you want to push the code from a Git repository. If not choose Disable and click “Next: Tags >” to proceed.

 9.   In the Tag tab, assign tags to the resources and click “Next : Review + Create >” to review and create the Azure Function App

10.   Review the configuration and click “Create” to create the Function App

 


Create a Function App HTTP Trigger

11. Go to the newly created Function App and click the “Create in Azure Portal” button to select the environment to use in configuring the Function App.

•         Choose the option to develop in the Portal

•         Choose the HTTP trigger as the desired template to use

•         Assign a name to the new trigger function

•         In the Authorization level, select “Function”

•         Click “Create” to create the Function App Trigger

12. In the Function App page, go to the Overview page and click on the newly created Trigger to open it


13. At the left pane of the Trigger page, click on the “Code + Test” Tab and paste the .NET code into the run.csx directory and click “Save” to save the pasted code.


The .NET script can be downloaded from here:

Remember to edit the underlined URLs with your custom URL and the target URL of the web application.

14. Click “Get Function URL” and copy the function URL

 


Enable Azure Function App Proxy

15. In left hand pane of the Function App page, click on “Configuration”

·        Under the “Application settings” tab, click “+ New application setting”


 

16. In the “Add/Edit application setting” page, in the “Name” field, type “AzureWebJobsFeatureFlags”, and in the “Value” field type “EnableProxies” to enable the proxy feature. (This is disabled by default in version 4.x of Azure Function App). Click OK and Save the new configuration setting.


 
·       Click on the FUNCTIONS_EXTENSION_VERSION flag and change the version of the Function App to version 3 (this activates the Proxies Feature of the function app)


17. In the left pane of the Function App, click on “Proxies”

·        Click “+ Add” to add a new proxy parameters

·       Assign a name to the proxy parameter

·       In the route template field type “/” to route all traffic from the custom URL to the backend URL (the target URL configured in the Function App HttpTrigger using .NET script).

·       In the “Allowed HTTP methods” field, choose “All methods”

·       In the “Backend URL” paste the Function app URL copied in step 14 of this guidance

·       Click Create to add the newly create proxy.


  Add the custom domain

18. At the left-hand side of the Function App page, click on “Custom domain”

•     Click “+ Add Custom domain”

•     In the “Domain Provider” option, choose “All other domain services” to type the custom domain name as desired

•     In the “TLS/SSL certificate” option, choose App Service Managed Certificate to use Azure managed certificate or select “Add certificate later to upload custom certificate later

•     In TLS/SSL type, choose the SNI SSL option to ensure the web app URL is accessible by all modern browsers

•     In the “Domain” field, type in the custom domain name that users will use to access the web app

 


19. In the Domain validation section, copy the CNAME & TXT record and create corresponding records in the DNS service of the domain

20. Click “Validate” to validate the records are created correctly and click “Add” to add the record to Azure custom domain


21. Click on “Add binding” on the custom domain page to bind an SSL certificate to the domain.

·     Choose “Create App Service Managed Certificate” to use Azure Managed certificate or select “Upload certificate (.pfx)” to upload custom certificate

·       Click Validate to validate the certificate

·       Click Add to bind the certificate to the subdomain name


At this point, you would have successfully validated that you own the domain and the hostname is available. So go ahead and test the connection to the Azure web app using the custom URL that you used in this guide.

 Open https://webavd.grantinointegrated.com

I hope you find this article helpful and I would like to read from you so drop your comment.