Redirect to a custom directory

By default, App Service directs web requests to the root directory of your app code. However, certain web frameworks don’t start in the root directory.

For example, Laravel starts in the public subdirectory. To continue the abouconde.com DNS example, such an app would be accessible at https://abouconde.com/public, but you would really want to direct http://abouconde.com to the public directory instead. This step doesn’t involve DNS resolution, but customizing the virtual directory.

To do this, select Application settings in the left-hand navigation of your web app page.

At the bottom of the page, the root virtual directory / points to site\wwwroot by default, which is the root directory of your app code. Change it to point to the site\wwwroot\public instead, for example, and save your changes.

Once the operation completes, your app should return the right page at the root path (for example, http://abouconde.com).

 

Automate with scripts

 

You can automate management of custom domains with scripts, using the Azure CLI or Azure PowerShell.

Azure CLI

 

The following command adds a configured custom DNS name to an App Service app.

az webapp config hostname add \

–webapp-name <app_name> \

–resource-group <resource_group_name> \

–hostname <fully_qualified_domain_name>

Azure PowerShell

 

The following command adds a configured custom DNS name to an App Service app.

Set-AzureRmWebApp `

-Name <app_name> `

-ResourceGroupName <resource_group_name> `

-HostNames @(“<fully_qualified_domain_name>”,”<app_name>.azurewebsites.net”)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s