SC-100 • Practice Test 32
Free SC-100 practice test — 15 questions with explanations. Set 32. No signup required.
Refer to the exhibit. You are reviewing a PowerShell script that configures network security. What is the effect of the NSG rule created in this script?
Refer to the exhibit.
$rg = 'rg-network'
$vnet = 'vnet-prod'
$subnet = 'snet-app'
$nic = 'nic-app1'
$nsg = 'nsg-app'
# Create NSG
$nsgParams = @{
ResourceGroupName = $rg
Name = $nsg
Location = 'eastus'
}
$nsgObj = New-AzNetworkSecurityGroup @nsgParams
# Add rule to deny inbound from internet
$ruleParams = @{
Name = 'DenyInternetInbound'
Access = 'Deny'
Priority = 100
Direction = 'Inbound'
Protocol = '*'
SourceAddressPrefix = 'Internet'
SourcePortRange = '*'
DestinationAddressPrefix = '*'
DestinationPortRange = '*'
NetworkSecurityGroup = $nsgObj
}
Add-AzNetworkSecurityRuleConfig @ruleParams | Set-AzNetworkSecurityGroup
# Associate NSG with subnet
$vnetObj = Get-AzVirtualNetwork -ResourceGroupName $rg -Name $vnet
$subnetObj = $vnetObj.Subnets | Where-Object {$_.Name -eq $subnet}
$subnetObj.NetworkSecurityGroup = $nsgObj
Set-AzVirtualNetwork -VirtualNetwork $vnetObj