Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion artifacts.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"resourcesTemplate": ""
"resourcesTemplate": "https://matestoragevlp15.blob.core.windows.net/task-artifacts/task16/exported-template.json?sv=2025-07-05&se=2026-07-19T11%3A12%3A49Z&sr=b&sp=r&sig=5Xd%2F%2F1%2FHSRk7RSjHCln23zv2tTgLxShWCytrxAtzDIo%3D"
}
48 changes: 42 additions & 6 deletions task.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,52 @@ Write-Host "Creating a resource group $resourceGroupName ..."
New-AzResourceGroup -Name $resourceGroupName -Location $location

Write-Host "Creating web network security group..."
# Write your code for creation of Web NSG here ->
# Write your code for creation of Web NSG here ->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment still says "Write your code" – the implementation is present and correct for web NSG creation, but consider verifying whether you also need an explicit rule here to allow VNet (inter-subnet) traffic, instead of relying only on default NSG behavior, since the task explicitly mentions allowing traffic from other subnets.

$webHttpRule = New-AzNetworkSecurityRuleConfig `
-Name "AllowHttpHttpsInbound" `
-Description "Allow HTTP and HTTPS traffic from the Internet" `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 100 `
-SourceAddressPrefix Internet `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 80, 443
$webNsg = New-AzNetworkSecurityGroup `
-Name $webSubnetName `
-ResourceGroupName $resourceGroupName `
-Location $location `
-SecurityRules $webHttpRule

Write-Host "Creating mngSubnet network security group..."
# Write your code for creation of management NSG here ->
# Write your code for creation of management NSG here ->
$mngSshRule = New-AzNetworkSecurityRuleConfig `
-Name "AllowSshInbound" `
-Description "Allow SSH traffic from the Internet" `
-Access Allow `
-Protocol Tcp `
-Direction Inbound `
-Priority 100 `
-SourceAddressPrefix Internet `
-SourcePortRange * `
-DestinationAddressPrefix * `
-DestinationPortRange 22
$mngNsg = New-AzNetworkSecurityGroup `

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This NSG currently has only the SSH-from-Internet rule; double-check whether you must explicitly allow traffic from VirtualNetwork to satisfy the "all subnets should allow traffic from other subnets" requirement, rather than depending on default rules.

-Name $mngSubnetName `
-ResourceGroupName $resourceGroupName `
-Location $location `
-SecurityRules $mngSshRule

Write-Host "Creating dbSubnet network security group..."
# Write your code for creation of management NSG here ->
# Write your code for creation of management NSG here ->
$dbNsg = New-AzNetworkSecurityGroup `

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database NSG has no explicit inbound rules, which correctly blocks Internet traffic; however, if the tests require explicit intra-VNet allow rules, you may need to add a rule that allows traffic from VirtualNetwork while still not permitting Internet as a source.

-Name $dbSubnetName `
-ResourceGroupName $resourceGroupName `
-Location $location

Write-Host "Creating a virtual network ..."
$webSubnet = New-AzVirtualNetworkSubnetConfig -Name $webSubnetName -AddressPrefix $webSubnetIpRange
$dbSubnet = New-AzVirtualNetworkSubnetConfig -Name $dbSubnetName -AddressPrefix $dbSubnetIpRange
$mngSubnet = New-AzVirtualNetworkSubnetConfig -Name $mngSubnetName -AddressPrefix $mngSubnetIpRange
$webSubnet = New-AzVirtualNetworkSubnetConfig -Name $webSubnetName -AddressPrefix $webSubnetIpRange -NetworkSecurityGroup $webNsg
$dbSubnet = New-AzVirtualNetworkSubnetConfig -Name $dbSubnetName -AddressPrefix $dbSubnetIpRange -NetworkSecurityGroup $dbNsg
$mngSubnet = New-AzVirtualNetworkSubnetConfig -Name $mngSubnetName -AddressPrefix $mngSubnetIpRange -NetworkSecurityGroup $mngNsg
New-AzVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName -Location $location -AddressPrefix $vnetAddressPrefix -Subnet $webSubnet,$dbSubnet,$mngSubnet
Loading