■ 가상 머신 확장 집합에서 어플리케이션 트래픽 허용하기

------------------------------------------------------------------------------------------------------------------------

 

##################################################

# 가상 머신 확장 집합을 구한다.

##################################################

 

$vmss = Get-AzVmss -ResourceGroupName TestResourceGroup -VMScaleSetName TestScaleSet

 

##################################################

# 80번 포트를 허용하는 규칙을 생성한다.

##################################################

 

$testNSRuleConfig = New-AzNetworkSecurityRuleConfig `

  -Name TestNSRuleConfig `

  -Protocol Tcp `

  -Direction Inbound `

  -Priority 200 `

  -SourceAddressPrefix * `

  -SourcePortRange * `

  -DestinationAddressPrefix * `

  -DestinationPortRange 80 `

  -Access Allow

 

##################################################

# 네트워크 보안 그룹을 생성한다.

##################################################

 

$testNSG = New-AzNetworkSecurityGroup `

  -ResourceGroupName TestResourceGroup `

  -Location EastUS `

  -Name TestNSG `

  -SecurityRules $testNSRuleConfig

 

##################################################

# 가상 네트워크를 구한다.

##################################################

 

$vnet = Get-AzVirtualNetwork -ResourceGroupName TestResourceGroup -Name TestVNet

 

##################################################

# 서브넷을 구한다.

##################################################

 

$testSubnet = $vnet.Subnets[0]

 

##################################################

# 가상 네트워크의 서브넷을 설정한다.

##################################################

 

$testSubnetConfig = Set-AzVirtualNetworkSubnetConfig `

  -VirtualNetwork $vnet `

  -Name TestSubnet `

  -AddressPrefix $testSubnet.AddressPrefix `

  -NetworkSecurityGroup $testNSG

 

##################################################

# 가상 네트워크를 설정한다.

##################################################

 

Set-AzVirtualNetwork -VirtualNetwork $vnet

 

##################################################

# 가상 머신 확장 집합을 업데이트 한다.

##################################################

 

Update-AzVmss `

  -ResourceGroupName TestResourceGroup `

  -Name TestScaleSet `

  -VirtualMachineScaleSet $vmss

 

 

TestResourceGroup : 리소스 그룹명

   TestScaleSet      : 가상 머신 확장 집합명

   TestNSRuleConfig  : 네트워크 보안 규칙 구성명

   EastUS            : 지역명

   TestNSG           : 네트워크 보안 그룹명

   TestVNet          : 가상 네트워크명

   TestSubnet        : 서브넷명

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요