#Replace with your values!!!!
#https://azure.microsoft.com/en-us/documentation/articles/load-balancer-arm-powershell/
#login to Rm Account
Login-AzureRmAccount
$pipName = "dpcentoswebvm1-pip" #name of the new/existing public name
$lbBackendName = "LB-backend"
$lbName = "NRP-LB"
$lbbenic = "lb-nic1-be"
#select the subscription id
$subscriptionId =
(Get-AzureRmSubscription
|
Out-GridView
`
-Title "Select an Azure Subscription ..." `
-PassThru).SubscriptionId
Select-AzureRmSubscription `
-SubscriptionId
$subscriptionId
#select the resource group
$rgName =
(Get-AzureRmResourceGroup
|
Out-GridView
`
-Title "Select an Azure Resource Group ..." `
-PassThru).ResourceGroupName
#create a new pip
$publicIP = New-AzureRmPublicIpAddress `
-Name $pipName `
-ResourceGroupName
"$rgName" `
-Location "$location" `
-AllocationMethod
Static
#if already a pip exists
#$publicIP = Get-AzureRmPublicIpAddress | Where-Object
{$_.Name -eq "$pipName"}
#frontend lb ip
$frontendIP = New-AzureRmLoadBalancerFrontendIpConfig
-Name LB-Frontend
-PublicIpAddress $publicIP
#create an lb pool
$beaddresspool=
New-AzureRmLoadBalancerBackendAddressPoolConfig
-Name "$lbBackendName"
#create inbound rule
$inboundNATRule1=
New-AzureRmLoadBalancerInboundNatRuleConfig -Name "SSH"
-FrontendIpConfiguration $frontendIP `
-Protocol TCP -FrontendPort
22 -BackendPort
22
#health check
$healthProbe = New-AzureRmLoadBalancerProbeConfig
-Name "HealthProbe"
-RequestPath "hc.html"
`
-Protocol http -Port 80 -IntervalInSeconds
15 -ProbeCount
2
#lb rule
$lbrule = New-AzureRmLoadBalancerRuleConfig -Name "HTTP"
-FrontendIpConfiguration $frontendIP `
-BackendAddressPool
$beAddressPool -Probe
$healthProbe -Protocol
Tcp -FrontendPort
80 -BackendPort
80
#create lb
$NRPLB = New-AzureRmLoadBalancer -ResourceGroupName
"$rgName" -Name "$lbName" -Location "$location" `
-FrontendIpConfiguration
$frontendIP -InboundNatRule
$inboundNATRule1 `
-LoadBalancingRule
$lbrule -BackendAddressPool
$beAddressPool -Probe
$healthProbe
A. Add
existing VMs through UI
In
portal.azure.com -> All resources -> filter -> Select your ALB ->
Backend Pools -> Add a virtual machine -> Select Availability Set ->
Select VM
B. Add
existing VMs through resources.azure.com
Click on the “+” signs….
a.
Select :- subscriptions -> resourceGroups
-> <your resource group> -> Microsoft.Network -> loadBalancers
-> <your ALB>
b.
Enable “Read/Write”
c.
Click Edit
Under “backendAddressPools”:
after provisioningState add/ammend backendIPConfigurations
"provisioningState":
"Succeeded",
"backendIPConfigurations": [
{
"id":
"/subscriptions/637156b4-7704-44f1-a19f-6bf607d6f499/resourceGroups/BasicIaaS/providers/Microsoft.Network/networkInterfaces/centoswebvm1959/ipConfigurations/ipconfig1"
}
],
"loadBalancingRules": [
d.
Click Put
e.
Check in the portal (or through powershell)
Get-AzureRmLoadBalancer
|
Where-Object {$_.Name -like "*NRP*"}
|
ForEach-Object {$_.BackendAddressPools}
No comments:
Post a Comment