Delen via


FQDN's bijwerken voor resourceproviders

 

Van toepassing op: Windows Azure Pack

Naast het bijwerken van de FQDN's (Fully Qualified Domain Names) voor de kernservices, moet u de eindpunten voor uw resourceproviders bijwerken als u deze hebt ingeschakeld voor hoge beschikbaarheid.

Een lijst met resourceproviders ophalen in uw implementatie

Eerst moet u een lijst met de resourceproviders in uw implementatie hebben. Voer de volgende Windows PowerShell cmdlet uit op een virtuele machine in de implementatie om een dergelijke lijst op te halen, zoals wordt weergegeven in de volgende code.

Get-MgmtSvcResourceProvider -IncludeSystemResourceProviders -AdminUri $adminApiUri -Token $token -DisableCertificateValidation | Format-List -Property "Name"

De FQDNS bijwerken

Voor elk van de resourceproviders die zijn ingesteld voor hoge beschikbaarheid, moet u de volgende scripts uitvoeren. Voor elke resourceprovider moet u de omgevingsvariabelen bijwerken.

# Windows PowerShell Script to update Windows Azure Pack resource provider settings.

Import-Module MgmtSvcAdmin

# Use UriBuilder to update host name in Uri to preserve other parts of the Uri.
function Update-UriHost([string]$message, [System.Uri]$uri, [string]$find, [string]$replace)
{
    Write-Verbose -Message "  Checking $($message): $uri" -Verbose
    $uriBuilder = New-Object System.UriBuilder($uri)
    if ($uriBuilder.Host -ieq $find -and $replace)
    {
        $uriBuilder.Host = $replace
        Write-Warning -Message "  Updated $($message):`r`n    before: $uri`r`n    after:  $($uriBuilder.Uri)"
    }
    return $uriBuilder.Uri
}

# Get local machine host name and fully qualified domain name.
$ipgp = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
$hostname = $ipgp.HostName
$fqdn = "$($ipgp.HostName).$($ipgp.DomainName)".Trim(".")

# Get credentials for performing actions.
$windowsAuthSite = "https://$($hostname):30072/"
if (!$credential -or !($credential.Password))
{
    $credential = Get-Credential -Message "WAP Administrator" -UserName "$($env:USERDOMAIN)\$($env:USERNAME)"
}
$token = Get-MgmtSvcToken -Type Windows -AuthenticationSite $windowsAuthSite -ClientRealm 'http://azureservices/AdminSite' -User $credential -DisableCertificateValidation

# IMPORTANT: Specify -DecryptPassword switch to read plain-text password
# so passwords are not mangled when the resource provider settings are written back to the database.
$adminUri = "https://$($hostname):30004/"
$rps = Get-MgmtSvcResourceProvider -IncludeSystemResourceProviders -AdminUri $adminUri -Token $token -DisableCertificateValidation
foreach ($rp in $rps)
{
    Write-Verbose -Message "Updating WAP resource provider '$($rp.Name)'." -Verbose
    $find = $hostname
    $replace = $fqdn

    if ($rp.AdminEndpoint.ForwardingAddress)
    {
        $rp.AdminEndpoint.ForwardingAddress = Update-UriHost -message 'AdminForwardingAddress' -uri $rp.AdminEndpoint.ForwardingAddress -find $find -replace $replace
    }

    if ($rp.TenantEndpoint.ForwardingAddress)
    {
        $rp.TenantEndpoint.ForwardingAddress = Update-UriHost -message 'TenantForwardingAddress' -uri $rp.TenantEndpoint.ForwardingAddress -find $find -replace $replace
    }

    if ($rp.UsageEndpoint.ForwardingAddress)
    {
        $rp.UsageEndpoint.ForwardingAddress = Update-UriHost -message 'UsageForwardingAddress' -uri $rp.UsageEndpoint.ForwardingAddress -find $find -replace $replace
    }

    if ($rp.HealthCheckEndpoint.ForwardingAddress)
    {
        $rp.HealthCheckEndpoint.ForwardingAddress = Update-UriHost -message 'HealthCheckForwardingAddress' -uri $rp.HealthCheckEndpoint.ForwardingAddress -find $find -replace $replace
    }

    if ($rp.NotificationEndpoint.ForwardingAddress)
    {
        $rp.NotificationEndpoint.ForwardingAddress = Update-UriHost -message 'NotificationForwardingAddress' -uri $rp.NotificationEndpoint.ForwardingAddress -find $find -replace $replace
    }

    # Add -Confirm:$false to silently update.
    $rpUpdated = Set-MgmtSvcResourceProvider -ResourceProvider $rp -AdminUri $adminUri -Token $token -DisableCertificateValidation -Force
}