Changing Azure Stack’s DNS and AD Domain to something other than AzureStack.local

16 Jul

This is another installer modification for Azure Stack TP1 PoC, that unfortunately will require editing more than one file.  I find the fact this edit is necessary, puzzling; once again we will start by mounting MicrosoftAzureStackPOC.vhdx.

We will start within PocDeployment\Test-AzureStackDeploymentParameters.ps1 at line 68:

$ADDomainName = "AzureStack.local"

Why is this not a parameter? We will also ignore the fact we are editing signed scripts and go ahead and make it one, first deleting that line and subsequently modifying the parameter block (leaving the default as azurestack.local).

[CmdletBinding()]
Param
(
    [string]
    [Parameter(Mandatory = $true)]
    $PackagePath,

    [SecureString]
    [Parameter(Mandatory = $false)]
    $AdminPassword,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $AADCredential,

    [string]
    [Parameter(Mandatory = $false)]
    $AADTenant,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $TIPServiceAdminCredential,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $TIPTenantAdminCredential,

    [Parameter(Mandatory = $false)]
    [Nullable[bool]]
    $UseAADChina,

    [String]
    [Parameter(Mandatory = $false)]
    $NATVMStaticIP,

    [String]
    [Parameter(Mandatory = $false)]
    $NATVMStaticGateway,

    [String]
    [Parameter(Mandatory = $false)]
    $PublicVLan = $null,

    [Parameter(Mandatory = $false)]
    [string]
    $ProxyServer,
    
    [Parameter(Mandatory = $false)]
    [string]
    $ADDomainName = "AzureStack.local",

    [Switch]
    $Force
)

We will also update yet another hard coded value this time in PocDeployment\Invoke-DeploymentLogCollection.ps1.
Look to line 106 and you will find a line like this:

('PublicIPAddresses','GatewayPools','GateWays','loadBalancers','loadBalancerMuxes','loadBalancerManager/config','networkInterfaces','virtualServers','Servers','credentials','macPools','logicalnetworks','accessControlLists') | % { JSONGet -NetworkControllerRestIP "NCVM.azurestack.local" -path "/$_" -Credential $credential | ConvertTo-Json -Depth 20 > "$destination\NC\$($_ -replace '/','').txt" }

Replace the hard coded azurestack.local value with the existing!!! parameter:

('PublicIPAddresses','GatewayPools','GateWays','loadBalancers','loadBalancerMuxes','loadBalancerManager/config','networkInterfaces','virtualServers','Servers','credentials','macPools','logicalnetworks','accessControlLists') | % { JSONGet -NetworkControllerRestIP "NCVM.$($parameters.ADDomainName)" -path "/$_" -Credential $credential | ConvertTo-Json -Depth 20 > "$destination\NC\$($_ -replace '/','').txt" }

Finally we need to modify the main installer script (in duplicate).  DeployAzureStack.ps1 is located both in the root of the Azure Stack TP1 zip file you downloaded and the Installer directory within MicrosoftAzureStackPOC.vhdx.  You can modify the file once and copy it to the other location in whatever order you choose.
We are going to start by adding a parameter, $ADDomainName, for the Active Directory DNS name (again leaving the default as azurestack.local):

[CmdletBinding()]
param
(
    [SecureString]
    [Parameter(Mandatory = $false)]
    $AdminPassword,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $AADCredential,

    [string]
    [Parameter(Mandatory = $false)]
    $AADTenant,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $TIPServiceAdminCredential,

    [PSCredential]
    [Parameter(Mandatory = $false)]
    $TIPTenantAdminCredential,

    [Parameter(Mandatory = $false)]
    [Nullable[bool]]
    $UseAADChina,

    [String]
    [Parameter(Mandatory = $false)]
    $NATVMStaticIP = $null, #eg: 10.10.10.10/24

    [String]
    [Parameter(Mandatory = $false)]
    $NATVMStaticGateway = $null,  #eg: 10.10.10.1

    [String]
    [Parameter(Mandatory = $false)]
    $PublicVLan = $null,  #eg: 305

    [String]
    [Parameter(Mandatory = $false)]
    $ProxyServer,
    
    [String]
    [Parameter(Mandatory=$false)]
    $ADDomainName="azurestack.local",

    [Switch]
    $Force,

    [Switch]
    $NoAutoReboot
)

Modify line 102 to accomodate the parameter we’ve created in this and Test-AzureStackDeploymentParameters.ps1.
The original line will look like this:

$Parameters = & "$DeploymentScriptPath\Test-AzureStackDeploymentParameters.ps1" -PackagePath $PSScriptRoot -AdminPassword $AdminPassword -AADCredential $AADCredential -AADTenant $AADTenant -TIPServiceAdminCredential $TIPServiceAdminCredential -TIPTenantAdminCredential $TIPTenantAdminCredential -UseAADChina $UseAADChina -NATVMStaticIP $NATVMStaticIP -NATVMStaticGateway $NATVMStaticGateway -PublicVLan $PublicVLan -ProxyServer $ProxyServer -Force:$Force

Add the ADDomainName parameter:

 $Parameters = & "$DeploymentScriptPath\Test-AzureStackDeploymentParameters.ps1" -PackagePath $PSScriptRoot -AdminPassword $AdminPassword -AADCredential $AADCredential -AADTenant $AADTenant -TIPServiceAdminCredential $TIPServiceAdminCredential -TIPTenantAdminCredential $TIPTenantAdminCredential -UseAADChina $UseAADChina -NATVMStaticIP $NATVMStaticIP -NATVMStaticGateway $NATVMStaticGateway -ADDomainName $ADDomainName -PublicVLan $PublicVLan -ProxyServer $ProxyServer -Force:$Force

Unmount the VHD and install to a new domain if you so desire.

Note: The process called out in this post contains content or procedures that are not endorsed or supported by Microsoft. This is specifically offered "As is". If your server blows up, we warned you.

-

Chris Speers

Systems Engineer Par Excellence within Avanade’s Azure Cloud Enablement Group.

LinkedIn