Search code examples
powershellazurepowershell-cmdlet

Azure Cmdlet - New-AzureWebsite, what is different between Name and HostName?


New-AzureWebsite Cmdlet -

New-AzureWebsite [[-Name] <String> ] [[-Location] <String> ] [[-Hostname] <String> ] [[-PublishingUsername] <String> ] [-Git] [-GitHub] [-GithubCredentials <PSCredential> ] [-GithubRepository <String> ] [-Slot <String> ] [ <CommonParameters>]

What is the difference between Name and HostName? In what situations we can use them?


Solution

  • Both parameters will determine the addresses of your website.

    The Name represents the website name, and it will determine the default website address allocated by Azure (it is a subdomain of azurewebsites.net).

    So having the next comand:

    New-AzureWebsite -Name MySite
    

    Will generate an azure website with the next address: MySite.azurewebsites.net.

    The Hostname represents additional domain name to be attached to your website. You can use it in case you have your own domain name.

    So modifying the previous command:

    New-AzureWebsite -Name MySite -Hostname MyWebsite.com
    

    It will generate an azure website with the next addresses: MySite.azurewebsites.net and MyWebsite.com.

    The Azure Portal equivalent operation for Hostname parameter is explained here - Web Sites Custom Domain Names