PowerShell ile Azure External Load Balancer olusturulmasi

Asagidaki PowerShell komutu Azure izerinde yeni bir VNET, bu VNET icerisinde yeni bir subnet ve ardindan 443 uzerinden dagitim yapacak external bir Load Balancer olusturmaktadir.

Ayrica LB arkasindaki VM ler icin 3389 uzerinden erisim kurallari eklenmektedir.

createlb

New-AzureRMResourceGroup –Name AdatumRG –Location centralus
$vnet = New-AzureRMVirtualNetwork –ResourceGroupName AdatumRG –Name AdatumVnet
–AddressPrefix 192.168.0.0/16 –Location centralus
$backendSubnet=Add-AzureRmVirtualNetworkSubnetConfig -Name AdatumSubnet
-VirtualNetwork $vnet -AddressPrefix 192.168.1.0/24
Set-AzureRMVirtualNetwork –VirtualNetwork $vnet
$publicIP = New-AzureRmPublicIpAddress -Name PublicIp -ResourceGroupName AdatumRG
-Location centralus –AllocationMethod Static -DomainNameLabel loadbalancernrp
$frontendIP = New-AzureRmLoadBalancerFrontendIpConfig -Name LB-Frontend
-PublicIpAddress $publicIP
$beIPPool = New-AzureRmLoadBalancerBackendAddressPoolConfig -Name LB-backend
$inboundNATRule1= New-AzureRmLoadBalancerInboundNatRuleConfig -Name RDP1
-FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3441 -BackendPort
3389
$inboundNATRule2= New-AzureRmLoadBalancerInboundNatRuleConfig -Name RDP2
-FrontendIpConfiguration $frontendIP -Protocol TCP -FrontendPort 3442 -BackendPort
3389
$healthProbe = New-AzureRmLoadBalancerProbeConfig -Name HealthProbe -RequestPath
'HealthDemo.aspx' -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2
$lbrule = New-AzureRmLoadBalancerRuleConfig -Name HTTP -FrontendIpConfiguration
$frontendIP -BackendAddressPool $beIPPool -Probe $healthProbe -Protocol Tcp -
FrontendPort 443 -BackendPort 443
$LB = New-AzureRmLoadBalancer -ResourceGroupName AdatumRG -Name AdatumLB -Location
centralus -FrontendIpConfiguration $frontendIP -InboundNatRule
$inboundNATRule1,$inboundNATRule2 -LoadBalancingRule $lbrule -BackendAddressPool
$beIPPool -Probe $healthProbe

$backendnic1= New-AzureRmNetworkInterface -ResourceGroupName AdatumRG -Name lb-nic1
-Location centralus -PrivateIpAddress 192.168.1.6 -Subnet $backendSubnet
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[0] -
LoadBalancerInboundNatRule $LB.InboundNatRules[0]
$backendnic2= New-AzureRmNetworkInterface -ResourceGroupName NRP-RG -Name lb-nic2-be
-Location 'West US' -PrivateIpAddress 192.168.1.7 -Subnet $backendSubnet
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[0] -
LoadBalancerInboundNatRule $LB.InboundNatRules[1]

$backednic1.IpConfigurations[0].LoadBalancerBackendAddressPool=$beIPPool
$backednic2.IpConfigurations[0].LoadBalancerBackendAddressPool=$beIPPool
Set-AzureRmNetworkInterface –NetworkInterface $backednic1
Set-AzureRmNetworkInterface –NetworkInterface $backednic2

Leave a Reply

Your email address will not be published. Required fields are marked *

− 3 = 5