Breyta

Deila með


Update the RDP port range values

This sample script changes the RDP port range values on the cluster node VMs after the cluster has been deployed. Azure PowerShell is used so that the underlying VMs do not cycle. The script gets the Microsoft.Network/loadBalancers resource in the cluster's resource group and updates the inboundNatPools.frontendPortRangeStart and inboundNatPools.frontendPortRangeEnd values. Customize the parameters as needed.

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. To get started, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

If needed, install the Azure PowerShell using the instruction found in the Azure PowerShell guide.

Sample script

Login-AzAccount
Get-AzSubscription
Set-AzContext -SubscriptionId 'yourSubscriptionId'

$groupname = "mysfclustergroup"
$start=3400
$end=4400

# Get the load balancer resource
$resource = Get-AzResource | Where {$_.ResourceGroupName –eq $groupname -and $_.ResourceType -eq "Microsoft.Network/loadBalancers"} 
$lb = Get-AzResource -ResourceGroupName $groupname -ResourceType Microsoft.Network/loadBalancers -ResourceName $resource.Name

# Update the front end port range
$lb.Properties.inboundNatPools.properties.frontendPortRangeStart = $start
$lb.Properties.inboundNatPools.properties.frontendPortRangeEnd = $end

# Write the inbound NAT pools properties
Write-Host ($lb.Properties.inboundNatPools | Format-List | Out-String)

# Update the load balancer
Set-AzResource -PropertyObject $lb.Properties -ResourceGroupName $groupname -ResourceType Microsoft.Network/loadBalancers -ResourceName $lb.name  -Force

Script explanation

This script uses the following commands. Each command in the table links to command specific documentation.

Command Notes
Get-AzResource Gets the Microsoft.Network/loadBalancers resource.
Set-AzResource Updates the Microsoft.Network/loadBalancers resource.

Next steps

For more information on the Azure PowerShell module, see Azure PowerShell documentation.

Additional Azure PowerShell samples for Azure Service Fabric can be found in the Azure PowerShell samples.