Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.45 KB

File metadata and controls

48 lines (35 loc) · 1.45 KB
title include file
description include file
services app-service
author msangapu-msft
ms.service azure-app-service
ms.topic include
ms.date 12/14/2021
ms.author msangapu
ms.custom include file

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

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>

For more information, see Map a custom domain to a web app.

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

$subscriptionId = "<subscription_ID>"
$resourceGroup = "<resource_group>"
$appName = "<app_name>"
$hostname = "<fully_qualified_domain_name>"
$apiVersion = "2024-04-01"
 
$restApiPath = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/sites/{2}/hostNameBindings/{3}?api-version={4}" `
    -f $subscriptionId, $resourceGroup, $appName, $hostname, $apiVersion
 
Invoke-AzRestMethod -Method PUT -Path $restApiPath

For more information, see Assign a custom domain to a web app.