Skip to content

Commit 263fb63

Browse files
committed
fixes
1 parent f340e97 commit 263fb63

File tree

1 file changed

+65
-15
lines changed

1 file changed

+65
-15
lines changed

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

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,6 @@ $hubToSpokeParams = @{
18271827
VirtualNetwork = $hubVnet
18281828
RemoteVirtualNetworkId = $spokeVnet.Id
18291829
AllowForwardedTraffic = $true
1830-
AllowVirtualNetworkAccess = $true
18311830
}
18321831
Add-AzVirtualNetworkPeering @hubToSpokeParams
18331832
@@ -1837,7 +1836,6 @@ $spokeToHubParams = @{
18371836
VirtualNetwork = $spokeVnet
18381837
RemoteVirtualNetworkId = $hubVnet.Id
18391838
AllowForwardedTraffic = $true
1840-
AllowVirtualNetworkAccess = $true
18411839
}
18421840
Add-AzVirtualNetworkPeering @spokeToHubParams
18431841
```
@@ -1956,9 +1954,7 @@ $routeTableParams = @{
19561954
}
19571955
$routeTable = Get-AzRouteTable @routeTableParams
19581956
1959-
Add-AzRouteConfig -RouteTable $routeTable -Route $routeParams
1960-
1961-
Set-AzRouteTable -RouteTable $routeTable
1957+
$routeTable | Add-AzRouteConfig @routeParams | Set-AzRouteTable
19621958
```
19631959
19641960
Use [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtualnetworksubnetconfig) to associate the route table with the subnet.
@@ -2075,7 +2071,7 @@ Use [New-AzNetworkSecurityGroup](/powershell/module/az.network/new-aznetworksecu
20752071
$nsgParams = @{
20762072
ResourceGroupName = "test-rg"
20772073
Name = "nsg-spoke-2"
2078-
Location = "eastus2"
2074+
Location = "westus2"
20792075
}
20802076
New-AzNetworkSecurityGroup @nsgParams
20812077
```
@@ -2089,6 +2085,9 @@ $ruleParams = @{
20892085
Direction = "Inbound"
20902086
Access = "Allow"
20912087
Protocol = "Tcp"
2088+
SourceAddressPrefix = "*"
2089+
SourcePortRange = "*"
2090+
DestinationAddressPrefix = "*"
20922091
DestinationPortRange = "80"
20932092
}
20942093
$nsg = Get-AzNetworkSecurityGroup -ResourceGroupName "test-rg" -Name "nsg-spoke-2"
@@ -2106,21 +2105,72 @@ $nicParams = @{
21062105
Name = "nic-2"
21072106
SubnetId = (Get-AzVirtualNetwork -ResourceGroupName "test-rg" -Name "vnet-spoke-2").Subnets[0].Id
21082107
NetworkSecurityGroupId = (Get-AzNetworkSecurityGroup -ResourceGroupName "test-rg" -Name "nsg-spoke-2").Id
2108+
Location = "westus2"
21092109
}
21102110
New-AzNetworkInterface @nicParams
21112111
```
21122112
2113-
Use [New-AzVM](/powershell/module/az.compute/new-azvm) to create the Windows Server 2022 virtual machine.
2113+
Use [Get-Credential](/powershell/module/microsoft.powershell.security/get-credential) to set a user name and password for the VM and store them in the `$cred` variable.
21142114
2115-
```powershell
2115+
```azurepowershell
2116+
$cred = Get-Credential
2117+
```
2118+
2119+
Use [New-AzVMConfig](/powershell/module/az.compute/new-azvmconfig) to define a VM.
2120+
2121+
```azurepowershell
2122+
$vmConfigParams = @{
2123+
VMName = "vm-spoke-2"
2124+
VMSize = "Standard_DS4_v2"
2125+
}
2126+
$vmConfig = New-AzVMConfig @vmConfigParams
2127+
```
2128+
2129+
Use [Set-AzVMOperatingSystem](/powershell/module/az.compute/set-azvmoperatingsystem) and [Set-AzVMSourceImage](/powershell/module/az.compute/set-azvmsourceimage) to create the rest of the VM configuration. The following example creates an Ubuntu Server virtual machine:
2130+
2131+
```azurepowershell
2132+
$osParams = @{
2133+
VM = $vmConfig
2134+
ComputerName = "vm-spoke-2"
2135+
Credential = $cred
2136+
}
2137+
$vmConfig = Set-AzVMOperatingSystem @osParams -Windows
2138+
2139+
$imageParams = @{
2140+
VM = $vmConfig
2141+
PublisherName = "MicrosoftWindowsServer"
2142+
Offer = "WindowsServer"
2143+
Skus = "2022-Datacenter"
2144+
Version = "latest"
2145+
}
2146+
$vmConfig = Set-AzVMSourceImage @imageParams
2147+
```
2148+
2149+
Use [Add-AzVMNetworkInterface](/powershell/module/az.compute/add-azvmnetworkinterface) to attach the NIC that you previously created to the VM.
2150+
2151+
```azurepowershell
2152+
# Get the network interface object
2153+
$nicParams = @{
2154+
ResourceGroupName = "test-rg"
2155+
Name = "nic-2"
2156+
}
2157+
$nic = Get-AzNetworkInterface @nicParams
2158+
2159+
$vmConfigParams = @{
2160+
VM = $vmConfig
2161+
Id = $nic.Id
2162+
}
2163+
$vmConfig = Add-AzVMNetworkInterface @vmConfigParams
2164+
```
2165+
2166+
Use [New-AzVM](/powershell/module/az.compute/new-azvm) to create the VM. The command will generate SSH keys for the virtual machine for login. Make note of the location of the private key. The private key is needed in later steps for connecting to the virtual machine with Azure Bastion.
2167+
2168+
```azurepowershell
21162169
$vmParams = @{
2170+
VM = $vmConfig
21172171
ResourceGroupName = "test-rg"
2118-
Name = "vm-spoke-2"
2119-
Image = "Win2022Datacenter"
2120-
Size = "Standard_DS2_v2"
2121-
AdminUsername = "azureuser"
2122-
NetworkInterfaceIds = (Get-AzNetworkInterface -ResourceGroupName "test-rg" -Name "nic-2").Id
2123-
}
2172+
Location = "westus2"
2173+
}
21242174
New-AzVM @vmParams
21252175
```
21262176
@@ -2228,7 +2278,7 @@ $vmExtensionParams = @{
22282278
Type = "CustomScriptExtension"
22292279
TypeHandlerVersion = "1.10"
22302280
Settings = @{
2231-
"commandToExecute" = "powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path 'C:\inetpub\wwwroot\default.htm' -Value $($env:computername)"
2281+
"commandToExecute" = "powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path 'C:\inetpub\wwwroot\default.htm' -Value vm-spoke-2"
22322282
}
22332283
}
22342284
Set-AzVMExtension @vmExtensionParams

0 commit comments

Comments
 (0)