Skip to content

Commit 9ae54dd

Browse files
committed
fixes in code
1 parent e672a20 commit 9ae54dd

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

articles/virtual-network/tutorial-restrict-network-access-to-resources.md

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Azure Bastion uses your browser to connect to VMs in your virtual network over S
193193
VirtualNetworkName = 'vnet-1'
194194
Sku = 'Basic'
195195
}
196-
New-AzBastion @bastion
196+
New-AzBastion @bastion -AsJob
197197
```
198198
199199
It takes about 10 minutes to deploy the Bastion resources. You can create VMs in the next section while Bastion deploys to your virtual network.
@@ -269,14 +269,14 @@ By default, all virtual machine instances in a subnet can communicate with any r
269269
270270
1. Create a network security group with [New-AzNetworkSecurityGroup](/powershell/module/az.network/new-aznetworksecuritygroup). The following example creates a network security group named *nsg-private*.
271271
272-
```azurepowershell-interactive
273-
$nsgpriv = @{
274-
ResourceGroupName = 'test-rg'
275-
Location = 'westus2'
276-
Name = 'nsg-private'
277-
}
278-
$nsg = New-AzNetworkSecurityGroup @nsgpriv
279-
```
272+
```azurepowershell-interactive
273+
$nsgpriv = @{
274+
ResourceGroupName = 'test-rg'
275+
Location = 'westus2'
276+
Name = 'nsg-private'
277+
}
278+
$nsg = New-AzNetworkSecurityGroup @nsgpriv
279+
```
280280
281281
### [CLI](#tab/cli)
282282
@@ -406,7 +406,6 @@ az network nsg create \
406406
# Add the new rules to the security group
407407
$nsg.SecurityRules += $rule1
408408
$nsg.SecurityRules += $rule2
409-
$nsg.SecurityRules += $rule3
410409
411410
# Update the network security group with the new rules
412411
Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg
@@ -418,7 +417,7 @@ az network nsg create \
418417
$subnet = @{
419418
VirtualNetwork = $VirtualNetwork
420419
Name = "subnet-private"
421-
AddressPrefix = "10.0.1.0/24"
420+
AddressPrefix = "10.0.2.0/24"
422421
ServiceEndpoint = "Microsoft.Storage"
423422
NetworkSecurityGroup = $nsg
424423
}
@@ -597,13 +596,21 @@ The steps necessary to restrict network access to resources created through Azur
597596
1. Create a context for your storage account and key with [New-AzStorageContext](/powershell/module/az.storage/new-AzStoragecontext). The context encapsulates the storage account name and account key:
598597
599598
```azurepowershell-interactive
600-
$storageContext = New-AzStorageContext $storageAcctName $storageAcctKey
599+
$storagecontext = @{
600+
StorageAccountName = $storageAcctName
601+
StorageAccountKey = $storageAcctKey
602+
}
603+
$storageContext = New-AzStorageContext @storagecontext
601604
```
602605
603606
1. Create a file share with [New-AzStorageShare](/powershell/module/az.storage/new-azstorageshare):
604607
605608
```azurepowershell-interactive
606-
$share = New-AzStorageShare file-share -Context $storageContext
609+
$fs = @{
610+
Name = "file-share"
611+
Context = $storageContext
612+
}
613+
$share = New-AzStorageShare @fs
607614
```
608615
609616
### [CLI](#tab/cli)
@@ -671,8 +678,7 @@ To restrict network access to a subnet:
671678
```azurepowershell-interactive
672679
$subnetpriv = @{
673680
ResourceGroupName = "test-rg"
674-
VirtualNetworkName = "vnet-1"
675-
Name = "subnet-private"
681+
Name = "vnet-1"
676682
}
677683
$privateSubnet = Get-AzVirtualNetwork @subnetpriv | Get-AzVirtualNetworkSubnetConfig -Name "subnet-private"
678684
```
@@ -737,7 +743,7 @@ To test network access to a storage account, deploy a virtual machine to each su
737743
738744
### Create the first virtual machine
739745
740-
Create a virtual machine in the *subnet-public* subnet with [New-AzVM](/powershell/module/az.compute/new-azvm). When running the command that follows, you are prompted for credentials. The values that you enter are configured as the user name and password for the VM. The `-AsJob` option creates the VM in the background, so that you can continue to the next step.
746+
Create a virtual machine in the *subnet-public* subnet with [New-AzVM](/powershell/module/az.compute/new-azvm). When running the command that follows, you are prompted for credentials. The values that you enter are configured as the user name and password for the VM.
741747
742748
```azurepowershell-interactive
743749
$vm1 = @{
@@ -748,15 +754,7 @@ $vm1 = @{
748754
Name = "vm-public"
749755
PublicIpAddressName = $null
750756
}
751-
New-AzVm @vm1 -AsJob
752-
```
753-
754-
Output similar to the following example output is returned:
755-
756-
```output
757-
Id Name PSJobTypeName State HasMoreData Location Command
758-
-- ---- ------------- ----- ----------- -------- -------
759-
1 Long Running... AzureLongRun... Running True localhost New-AzVM
757+
New-AzVm @vm1
760758
```
761759

762760
### Create the second virtual machine
@@ -914,7 +912,7 @@ The virtual machine you created earlier that is assigned to the **subnet-private
914912

915913
1. Select **vm-private**.
916914

917-
1. Select **Bastion** in **Operations**.
915+
1. Select **Connect** then **Connect via Bastion** in **Overview**.
918916

919917
1. Enter the username and password you specified when creating the virtual machine. Select **Connect**.
920918

@@ -1125,7 +1123,6 @@ SSH into the *vm-private* VM.
11251123
Context = $storageContext
11261124
}
11271125
Get-AzStorageFile @storage
1128-
11291126
```
11301127
11311128
Access is denied, and you receive a *Get-AzStorageFile : The remote server returned an error: (403) Forbidden. HTTP Status Code: 403 - HTTP Error Message: This request is not authorized to perform this operation* error, because your computer is not in the *subnet-private* subnet of the *vnet-1* virtual network.

0 commit comments

Comments
 (0)