Skip to content

Commit f0301dc

Browse files
committed
added cli and powershell tabs
1 parent fe4c54e commit f0301dc

File tree

1 file changed

+40
-45
lines changed

1 file changed

+40
-45
lines changed

articles/nat-gateway/tutorial-hub-spoke-nat-firewall.md

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Use [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtu
152152
# Create subnet for Azure Firewall
153153
$subnetParams = @{
154154
Name = 'AzureFirewallSubnet'
155-
AddressPrefix = '10.0.1.64/64'
155+
AddressPrefix = '10.0.1.64/26'
156156
VirtualNetwork = $hubVnet
157157
}
158158
Add-AzVirtualNetworkSubnetConfig @subnetParams
@@ -181,8 +181,9 @@ $publicIpBastionParams = @{
181181
ResourceGroupName = 'test-rg'
182182
Location = 'South Central US'
183183
Name = 'public-ip-bastion'
184-
AllocationMethod = 'Static'
185184
Sku = 'Standard'
185+
AllocationMethod = 'Static'
186+
Zone = 1, 2, 3
186187
}
187188
$publicIpBastion = New-AzPublicIpAddress @publicIpBastionParams
188189
```
@@ -192,11 +193,12 @@ Use [New-AzBastion](/powershell/module/az.network/new-azbastion) to create Azure
192193
```powershell
193194
# Create Azure Bastion
194195
$bastionParams = @{
195-
ResourceGroupName = 'test-rg'
196-
Location = 'South Central US'
197-
Name = 'bastion'
198-
PublicIpAddress = $publicIpBastion
199-
VirtualNetwork = $hubVnet
196+
ResourceGroupName = "test-rg"
197+
Name = "bastion"
198+
VirtualNetworkName = "vnet-hub"
199+
PublicIpAddressName = "public-ip-bastion"
200+
PublicIPAddressRgName = "test-rg"
201+
VirtualNetworkRgName = "test-rg"
200202
}
201203
New-AzBastion @bastionParams
202204
```
@@ -211,24 +213,11 @@ $publicIpFirewallParams = @{
211213
Name = 'public-ip-firewall'
212214
AllocationMethod = 'Static'
213215
Sku = 'Standard'
216+
Zone = 1, 2, 3
214217
}
215218
$publicIpFirewall = New-AzPublicIpAddress @publicIpFirewallParams
216219
```
217220

218-
Use [New-AzFirewall](/powershell/module/az.network/new-azfirewall) to create Azure Firewall.
219-
220-
```powershell
221-
# Create Azure Firewall
222-
$firewallParams = @{
223-
ResourceGroupName = 'test-rg'
224-
Location = 'South Central US'
225-
Name = 'firewall'
226-
VirtualNetwork = $hubVnet
227-
PublicIpAddress = $publicIpFirewall
228-
}
229-
$firewall = New-AzFirewall @firewallParams
230-
```
231-
232221
Use [New-AzFirewallPolicy](/powershell/module/az.network/new-azfirewallpolicy) to create a firewall policy.
233222

234223
```powershell
@@ -241,18 +230,22 @@ $firewallPolicyParams = @{
241230
$firewallPolicy = New-AzFirewallPolicy @firewallPolicyParams
242231
```
243232

244-
Use [Set-AzFirewall](/powershell/module/az.network/set-azfirewall) to associate the firewall policy with the firewall.
233+
Use [New-AzFirewall](/powershell/module/az.network/new-azfirewall) to create Azure Firewall.
245234

246235
```powershell
247-
# Associate firewall policy with firewall
248-
$firewallUpdateParams = @{
236+
# Create Azure Firewall
237+
$firewallParams = @{
249238
ResourceGroupName = 'test-rg'
239+
Location = 'South Central US'
250240
Name = 'firewall'
251-
FirewallPolicy = $firewallPolicy
241+
VirtualNetworkName = 'vnet-hub'
242+
PublicIpName = 'public-ip-firewall'
243+
FirewallPolicyId = $firewallPolicy.Id
252244
}
253-
Set-AzFirewall @firewallUpdateParams
245+
$firewall = New-AzFirewall @firewallParams
254246
```
255247

248+
256249
### [CLI](#tab/cli)
257250

258251
Use [az group create](/cli/azure/group#az_group_create) to create a resource group.
@@ -395,13 +388,13 @@ $publicIpNat = New-AzPublicIpAddress @publicIpNatParams
395388
Use [New-AzNatGateway](/powershell/module/az.network/new-aznatgateway) to create the NAT gateway.
396389

397390
```powershell
398-
# Create NAT gateway
399391
$natGatewayParams = @{
400392
ResourceGroupName = 'test-rg'
401-
Location = 'South Central US'
402393
Name = 'nat-gateway'
403394
PublicIpAddress = $publicIpNat
395+
Sku = 'Standard'
404396
IdleTimeoutInMinutes = 4
397+
Location = 'South Central US'
405398
}
406399
$natGateway = New-AzNatGateway @natGatewayParams
407400
```
@@ -413,6 +406,7 @@ Use [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtu
413406
$subnetParams = @{
414407
VirtualNetwork = $hubVnet
415408
Name = 'AzureFirewallSubnet'
409+
AddressPrefix = '10.0.1.64/26'
416410
NatGateway = $natGateway
417411
}
418412
Set-AzVirtualNetworkSubnetConfig @subnetParams
@@ -776,7 +770,7 @@ $routeConfigParams = @{
776770
Name = 'route-to-hub'
777771
AddressPrefix = '0.0.0.0/0'
778772
NextHopType = 'VirtualAppliance'
779-
NextHopIpAddress = '10.0.1.68'
773+
NextHopIpAddress = $firewall.IpConfigurations[0].PrivateIpAddress
780774
RouteTable = $routeTable
781775
}
782776
Add-AzRouteConfig @routeConfigParams
@@ -796,6 +790,7 @@ Use [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtu
796790
$subnetConfigParams = @{
797791
VirtualNetwork = $spokeVnet
798792
Name = 'subnet-private'
793+
AddressPrefix = '10.1.0.0/24'
799794
RouteTable = $routeTable
800795
}
801796
Set-AzVirtualNetworkSubnetConfig @subnetConfigParams
@@ -881,21 +876,9 @@ Traffic from the spoke through the hub must be allowed through and firewall poli
881876

882877
### [PowerShell](#tab/powershell)
883878

884-
Use [New-AzFirewallPolicyNetworkRuleCollection](/powershell/module/az.network/new-azfirewallpolicynetworkrulecollection) to create a network rule collection.
885879

886-
```powershell
887-
# Create network rule collection
888-
$networkRuleCollectionParams = @{
889-
Name = 'spoke-to-internet'
890-
Priority = 100
891-
RuleCollectionType = 'NetworkRuleCollection'
892-
ActionType = 'Allow'
893-
RuleCollectionGroup = 'DefaultNetworkRuleCollectionGroup'
894-
}
895-
$networkRuleCollection = New-AzFirewallPolicyNetworkRuleCollection @networkRuleCollectionParams
896-
```
897880

898-
Use [New-AzFirewallPolicyNetworkRule](/powershell/module/az.network/new-azfirewallpolicynetworkrule) to create a network rule.
881+
Use [New-AzFirewallNetworkRule](/powershell/module/az.network/new-azfirewallnetworkrule) to create a network rule.
899882

900883
```powershell
901884
# Create network rule
@@ -906,11 +889,23 @@ $networkRuleParams = @{
906889
DestinationPort = '80,443'
907890
Protocol = 'TCP'
908891
}
909-
$networkRule = New-AzFirewallPolicyNetworkRule @networkRuleParams
910-
# Add network rule to collection
911-
$networkRuleCollection.Rules.Add($networkRule)
892+
$networkRule = New-AzFirewallNetworkRule @networkRuleParams
912893
```
913894

895+
Use [New-AzFirewallNetworkRuleCollection](/powershell/module/az.network/new-azfirewallnetworkrulecollection) to create a network rule collection.
896+
897+
```powershell
898+
# Create network rule collection
899+
$networkRuleCollectionParams = @{
900+
Name = 'spoke-to-internet'
901+
Priority = 100
902+
Rule = $networkRule
903+
ActionType = 'Allow'
904+
}
905+
$networkRuleCollection = New-AzFirewallNetworkRuleCollection @networkRuleCollectionParams
906+
```
907+
908+
914909
Use [Set-AzFirewallPolicy](/powershell/module/az.network/set-azfirewallpolicy) to update the firewall policy.
915910

916911
```powershell

0 commit comments

Comments
 (0)