SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $vnetName = "Replace with your virtual network name"
  2. $resourceGroupName = "Replace with the resource group the virtual network is in"
  3. $subnetName = "Replace with the name of the subnet that you plan to use for HDInsight"
  4. # Get the Virtual Network object
  5. $vnet = Get-AzureRmVirtualNetwork `
  6.     -Name $vnetName `
  7.     -ResourceGroupName $resourceGroupName
  8. # Get the region the Virtual network is in.
  9. $location = $vnet.Location
  10. # Get the subnet object
  11. $subnet = $vnet.Subnets | Where-Object Name -eq $subnetName
  12. # Create a Network Security Group.
  13. # And add exemptions for the HDInsight health and management services.
  14. $nsg = New-AzureRmNetworkSecurityGroup `
  15.     -Name "hdisecure" `
  16.     -ResourceGroupName $resourceGroupName `
  17.     -Location $location `
  18.     | Add-AzureRmNetworkSecurityRuleConfig `
  19.         -name "hdirule1" `
  20.         -Description "HDI health and management address 52.164.210.96" `
  21.         -Protocol "*" `
  22.         -SourcePortRange "*" `
  23.         -DestinationPortRange "443" `
  24.         -SourceAddressPrefix "52.164.210.96" `
  25.         -DestinationAddressPrefix "VirtualNetwork" `
  26.         -Access Allow `
  27.         -Priority 300 `
  28.         -Direction Inbound `
  29.     | Add-AzureRmNetworkSecurityRuleConfig `
  30.         -Name "hdirule2" `
  31.         -Description "HDI health and management 13.74.153.132" `
  32.         -Protocol "*" `
  33.         -SourcePortRange "*" `
  34.         -DestinationPortRange "443" `
  35.         -SourceAddressPrefix "13.74.153.132" `
  36.         -DestinationAddressPrefix "VirtualNetwork" `
  37.         -Access Allow `
  38.         -Priority 301 `
  39.         -Direction Inbound `
  40.     | Add-AzureRmNetworkSecurityRuleConfig `
  41.         -Name "hdirule3" `
  42.         -Description "HDI health and management 168.61.49.99" `
  43.         -Protocol "*" `
  44.         -SourcePortRange "*" `
  45.         -DestinationPortRange "443" `
  46.         -SourceAddressPrefix "168.61.49.99" `
  47.         -DestinationAddressPrefix "VirtualNetwork" `
  48.         -Access Allow `
  49.         -Priority 302 `
  50.         -Direction Inbound `
  51.     | Add-AzureRmNetworkSecurityRuleConfig `
  52.         -Name "hdirule4" `
  53.         -Description "HDI health and management 23.99.5.239" `
  54.         -Protocol "*" `
  55.         -SourcePortRange "*" `
  56.         -DestinationPortRange "443" `
  57.         -SourceAddressPrefix "23.99.5.239" `
  58.         -DestinationAddressPrefix "VirtualNetwork" `
  59.         -Access Allow `
  60.         -Priority 303 `
  61.         -Direction Inbound `
  62.     | Add-AzureRmNetworkSecurityRuleConfig `
  63.         -Name "hdirule5" `
  64.         -Description "HDI health and management 168.61.48.131" `
  65.         -Protocol "*" `
  66.         -SourcePortRange "*" `
  67.         -DestinationPortRange "443" `
  68.         -SourceAddressPrefix "168.61.48.131" `
  69.         -DestinationAddressPrefix "VirtualNetwork" `
  70.         -Access Allow `
  71.         -Priority 304 `
  72.         -Direction Inbound `
  73.     | Add-AzureRmNetworkSecurityRuleConfig `
  74.         -Name "hdirule6" `
  75.         -Description "HDI health and management 138.91.141.162" `
  76.         -Protocol "*" `
  77.         -SourcePortRange "*" `
  78.         -DestinationPortRange "443" `
  79.         -SourceAddressPrefix "138.91.141.162" `
  80.         -DestinationAddressPrefix "VirtualNetwork" `
  81.         -Access Allow `
  82.         -Priority 305 `
  83.         -Direction Inbound `
  84. # Set the changes to the security group
  85. Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $nsg
  86. # Apply the NSG to the subnet
  87. Set-AzureRmVirtualNetworkSubnetConfig `
  88.     -VirtualNetwork $vnet `
  89.     -Name $subnetName `
  90.     -AddressPrefix $subnet.AddressPrefix `
  91.     -NetworkSecurityGroup $nsg
  92. $vnet | Set-AzureRmVirtualNetwork
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top