Skip to content

Commit 31810b6

Browse files
committed
changed resource names
1 parent 6a5a524 commit 31810b6

File tree

1 file changed

+59
-58
lines changed

1 file changed

+59
-58
lines changed

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

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,27 @@ Service endpoints are enabled per service, per subnet.
8484

8585
## Create a virtual network
8686

87-
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). The following example creates a resource group named *myResourceGroup*:
87+
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). The following example creates a resource group named *test-rg*:
8888

8989
```azurepowershell-interactive
90-
New-AzResourceGroup -ResourceGroupName myResourceGroup -Location EastUS
90+
New-AzResourceGroup -ResourceGroupName test-rg -Location westus2
9191
```
9292

93-
Create a virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). The following example creates a virtual network named *myVirtualNetwork* with the address prefix *10.0.0.0/16*.
93+
Create a virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). The following example creates a virtual network named *vnet-1* with the address prefix *10.0.0.0/16*.
9494

9595
```azurepowershell-interactive
9696
$virtualNetwork = New-AzVirtualNetwork `
97-
-ResourceGroupName myResourceGroup `
98-
-Location EastUS `
99-
-Name myVirtualNetwork `
97+
-ResourceGroupName test-rg `
98+
-Location westus2 `
99+
-Name vnet-1 `
100100
-AddressPrefix 10.0.0.0/16
101101
```
102102

103-
Create a subnet configuration with [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig). The following example creates a subnet configuration for a subnet named *Public*:
103+
Create a subnet configuration with [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig). The following example creates a subnet configuration for a subnet named *subnet-public*:
104104

105105
```azurepowershell-interactive
106106
$subnetConfigPublic = Add-AzVirtualNetworkSubnetConfig `
107-
-Name Public `
107+
-Name subnet-public `
108108
-AddressPrefix 10.0.0.0/24 `
109109
-VirtualNetwork $virtualNetwork
110110
```
@@ -115,11 +115,11 @@ Create the subnet in the virtual network by writing the subnet configuration to
115115
$virtualNetwork | Set-AzVirtualNetwork
116116
```
117117

118-
Create an additional subnet in the virtual network. In this example, a subnet named *Private* is created with a service endpoint for *Microsoft.Storage*:
118+
Create an additional subnet in the virtual network. In this example, a subnet named *subnet-private* is created with a service endpoint for *Microsoft.Storage*:
119119

120120
```azurepowershell-interactive
121121
$subnetConfigPrivate = Add-AzVirtualNetworkSubnetConfig `
122-
-Name Private `
122+
-Name subnet-private `
123123
-AddressPrefix 10.0.1.0/24 `
124124
-VirtualNetwork $virtualNetwork `
125125
-ServiceEndpoint Microsoft.Storage
@@ -131,12 +131,12 @@ $virtualNetwork | Set-AzVirtualNetwork
131131

132132
## Create a virtual network
133133

134-
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [az group create](/cli/azure/group). The following example creates a resource group named *test-rg* in the *eastus* location.
134+
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [az group create](/cli/azure/group). The following example creates a resource group named *test-rg* in the *westus2* location.
135135

136136
```azurecli-interactive
137137
az group create \
138138
--name test-rg \
139-
--location eastus
139+
--location westus2
140140
```
141141

142142
Create a virtual network with one subnet with [az network vnet create](/cli/azure/network/vnet).
@@ -150,11 +150,11 @@ az network vnet create \
150150
--subnet-prefix 10.0.0.0/24
151151
```
152152

153-
You can enable service endpoints only for services that support service endpoints. View service endpoint-enabled services available in an Azure location with [az network vnet list-endpoint-services](/cli/azure/network/vnet). The following example returns a list of service-endpoint-enabled services available in the *eastus* region. The list of services returned will grow over time, as more Azure services become service endpoint enabled.
153+
You can enable service endpoints only for services that support service endpoints. View service endpoint-enabled services available in an Azure location with [az network vnet list-endpoint-services](/cli/azure/network/vnet). The following example returns a list of service-endpoint-enabled services available in the *westus2* region. The list of services returned will grow over time, as more Azure services become service endpoint enabled.
154154

155155
```azurecli-interactive
156156
az network vnet list-endpoint-services \
157-
--location eastus \
157+
--location westus2 \
158158
--out table
159159
```
160160

@@ -196,13 +196,13 @@ By default, all virtual machine instances in a subnet can communicate with any r
196196

197197
### [PowerShell](#tab/powershell)
198198

199-
Create a network security group with [New-AzNetworkSecurityGroup](/powershell/module/az.network/new-aznetworksecuritygroup). The following example creates a network security group named *myNsgPrivate*.
199+
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*.
200200

201201
```azurepowershell-interactive
202202
$nsg = New-AzNetworkSecurityGroup `
203-
-ResourceGroupName myResourceGroup `
204-
-Location EastUS `
205-
-Name myNsgPrivate `
203+
-ResourceGroupName test-rg `
204+
-Location westus2 `
205+
-Name nsg-private `
206206
-SecurityRules $rule1,$rule2,$rule3
207207
```
208208

@@ -331,12 +331,12 @@ $rule3 = New-AzNetworkSecurityRuleConfig `
331331
-SourcePortRange *
332332
```
333333

334-
Associate the network security group to the *Private* subnet with [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtualnetworksubnetconfig) and then write the subnet configuration to the virtual network. The following example associates the *myNsgPrivate* network security group to the *Private* subnet:
334+
Associate the network security group to the *subnet-private* subnet with [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtualnetworksubnetconfig) and then write the subnet configuration to the virtual network. The following example associates the *nsg-private* network security group to the *subnet-private* subnet:
335335

336336
```azurepowershell-interactive
337337
Set-AzVirtualNetworkSubnetConfig `
338338
-VirtualNetwork $VirtualNetwork `
339-
-Name Private `
339+
-Name subnet-private `
340340
-AddressPrefix 10.0.1.0/24 `
341341
-ServiceEndpoint Microsoft.Storage `
342342
-NetworkSecurityGroup $nsg
@@ -407,7 +407,6 @@ az network vnet subnet update \
407407
--network-security-group nsg-private
408408
```
409409

410-
411410
---
412411

413412
## Restrict network access to a resource
@@ -426,9 +425,9 @@ Create an Azure storage account with [New-AzStorageAccount](/powershell/module/a
426425
$storageAcctName = '<replace-with-your-unique-storage-account-name>'
427426
428427
New-AzStorageAccount `
429-
-Location EastUS `
428+
-Location westus2 `
430429
-Name $storageAcctName `
431-
-ResourceGroupName myResourceGroup `
430+
-ResourceGroupName test-rg `
432431
-SkuName Standard_LRS `
433432
-Kind StorageV2
434433
```
@@ -437,7 +436,7 @@ After the storage account is created, retrieve the key for the storage account i
437436

438437
```azurepowershell-interactive
439438
$storageAcctKey = (Get-AzStorageAccountKey `
440-
-ResourceGroupName myResourceGroup `
439+
-ResourceGroupName test-rg `
441440
-AccountName $storageAcctName).Value[0]
442441
```
443442

@@ -516,7 +515,9 @@ $storageContext = New-AzStorageContext $storageAcctName $storageAcctKey
516515

517516
Create a file share with [New-AzStorageShare](/powershell/module/az.storage/new-azstorageshare):
518517

519-
$share = New-AzStorageShare my-file-share -Context $storageContext
518+
```azurepowershell-interactive
519+
$share = New-AzStorageShare file-share -Context $storageContext
520+
```
520521

521522
### [CLI](#tab/cli)
522523

@@ -571,7 +572,7 @@ By default, storage accounts accept network connections from clients in any netw
571572

572573
```azurepowershell-interactive
573574
Update-AzStorageAccountNetworkRuleSet `
574-
-ResourceGroupName "myresourcegroup" `
575+
-ResourceGroupName "test-rg" `
575576
-Name $storageAcctName `
576577
-DefaultAction Deny
577578
```
@@ -580,17 +581,17 @@ Retrieve the created virtual network with [Get-AzVirtualNetwork](/powershell/mod
580581

581582
```azurepowershell-interactive
582583
$privateSubnet = Get-AzVirtualNetwork `
583-
-ResourceGroupName "myResourceGroup" `
584-
-Name "myVirtualNetwork" `
584+
-ResourceGroupName "test-rg" `
585+
-Name "vnet-1" `
585586
| Get-AzVirtualNetworkSubnetConfig `
586-
-Name "Private"
587+
-Name "subnet-private"
587588
```
588589

589-
Allow network access to the storage account from the *Private* subnet with [Add-AzStorageAccountNetworkRule](/powershell/module/az.network/add-aznetworksecurityruleconfig).
590+
Allow network access to the storage account from the *subnet-private* subnet with [Add-AzStorageAccountNetworkRule](/powershell/module/az.network/add-aznetworksecurityruleconfig).
590591

591592
```azurepowershell-interactive
592593
Add-AzStorageAccountNetworkRule `
593-
-ResourceGroupName "myresourcegroup" `
594+
-ResourceGroupName "test-rg" `
594595
-Name $storageAcctName `
595596
-VirtualNetworkResourceId $privateSubnet.Id
596597
```
@@ -644,15 +645,15 @@ To test network access to a storage account, deploy a virtual machine to each su
644645

645646
### Create the first virtual machine
646647

647-
Create a virtual machine in the *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.
648+
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.
648649

649650
```azurepowershell-interactive
650651
New-AzVm `
651-
-ResourceGroupName "myResourceGroup" `
652-
-Location "East US" `
653-
-VirtualNetworkName "myVirtualNetwork" `
654-
-SubnetName "Public" `
655-
-Name "myVmPublic" `
652+
-ResourceGroupName "test-rg" `
653+
-Location "WestUS2" `
654+
-VirtualNetworkName "vnet-1" `
655+
-SubnetName "subnet-public" `
656+
-Name "vm-public" `
656657
-AsJob
657658
```
658659

@@ -666,15 +667,15 @@ Id Name PSJobTypeName State HasMoreData Location
666667

667668
### Create the second virtual machine
668669

669-
Create a virtual machine in the *Private* subnet:
670+
Create a virtual machine in the *subnet-private* subnet:
670671

671672
```azurepowershell-interactive
672673
New-AzVm `
673-
-ResourceGroupName "myResourceGroup" `
674+
-ResourceGroupName "test-rg" `
674675
-Location "East US" `
675-
-VirtualNetworkName "myVirtualNetwork" `
676-
-SubnetName "Private" `
677-
-Name "myVmPrivate"
676+
-VirtualNetworkName "vnet-1" `
677+
-SubnetName "subnet-private" `
678+
-Name "vm-private" `
678679
```
679680

680681
It takes a few minutes for Azure to create the VM. Do not continue to the next step until Azure finishes creating the VM and returns output to PowerShell.
@@ -704,7 +705,7 @@ The VM takes a few minutes to create. After the VM is created, the Azure CLI sho
704705
{
705706
"fqdns": "",
706707
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm-public",
707-
"location": "eastus",
708+
"location": "westus2",
708709
"macAddress": "00-0D-3A-23-9A-49",
709710
"powerState": "VM running",
710711
"privateIpAddress": "10.0.0.4",
@@ -796,12 +797,12 @@ The virtual machine you created earlier that is assigned to the **subnet-private
796797

797798
### [PowerShell](#tab/powershell)
798799

799-
Use [Get-AzPublicIpAddress](/powershell/module/az.network/get-azpublicipaddress) to return the public IP address of a VM. The following example returns the public IP address of the *myVmPrivate* VM:
800+
Use [Get-AzPublicIpAddress](/powershell/module/az.network/get-azpublicipaddress) to return the public IP address of a VM. The following example returns the public IP address of the *vm-private" `* VM:
800801

801802
```azurepowershell-interactive
802803
Get-AzPublicIpAddress `
803-
-Name myVmPrivate `
804-
-ResourceGroupName myResourceGroup `
804+
-Name vm-private" ` `
805+
-ResourceGroupName test-rg `
805806
| Select IpAddress
806807
```
807808

@@ -813,7 +814,7 @@ mstsc /v:<publicIpAddress>
813814

814815
A Remote Desktop Protocol (.rdp) file is created and downloaded to your computer. Open the downloaded rdp file. If prompted, select **Connect**. Enter the user name and password you specified when creating the VM. You may need to select **More choices**, then **Use a different account**, to specify the credentials you entered when you created the VM. Select **OK**. You may receive a certificate warning during the sign-in process. If you receive the warning, select **Yes** or **Continue**, to proceed with the connection.
815816

816-
On the *myVmPrivate* VM, map the Azure file share to drive Z using PowerShell. Before running the commands that follow, replace `<storage-account-key>` and `<storage-account-name>` with values from you supplied or retrieved in [Create a storage account](#create-a-storage-account).
817+
On the *vm-private" `* VM, map the Azure file share to drive Z using PowerShell. Before running the commands that follow, replace `<storage-account-key>` and `<storage-account-name>` with values from you supplied or retrieved in [Create a storage account](#create-a-storage-account).
817818

818819
```powershell
819820
$acctKey = ConvertTo-SecureString -String "<storage-account-key>" -AsPlainText -Force
@@ -839,7 +840,7 @@ ping bing.com
839840

840841
You receive no replies, because the network security group associated to the *Private* subnet does not allow outbound access to public IP addresses other than the addresses assigned to the Azure Storage service.
841842

842-
Close the remote desktop session to the *myVmPrivate* VM.
843+
Close the remote desktop session to the *vm-private" `* VM.
843844

844845
### [CLI](#tab/cli)
845846

@@ -951,12 +952,12 @@ Exit the SSH session to the *vm-private* VM.
951952
952953
### [PowerShell](#tab/powershell)
953954
954-
Get the public IP address of the *myVmPublic* VM:
955+
Get the public IP address of the *vm-public* VM:
955956
956957
```azurepowershell-interactive
957958
Get-AzPublicIpAddress `
958-
-Name myVmPublic `
959-
-ResourceGroupName myResourceGroup `
959+
-Name vm-public `
960+
-ResourceGroupName test-rg `
960961
| Select IpAddress
961962
```
962963

@@ -966,27 +967,27 @@ Replace `<publicIpAddress>` in the following command, with the public IP address
966967
mstsc /v:<publicIpAddress>
967968
```
968969

969-
On the *myVmPublic* VM, attempt to map the Azure file share to drive Z. Before running the commands that follow, replace `<storage-account-key>` and `<storage-account-name>` with values from you supplied or retrieved in [Create a storage account](#create-a-storage-account).
970+
On the *vm-public* VM, attempt to map the Azure file share to drive Z. Before running the commands that follow, replace `<storage-account-key>` and `<storage-account-name>` with values from you supplied or retrieved in [Create a storage account](#create-a-storage-account).
970971

971972
```powershell
972973
$acctKey = ConvertTo-SecureString -String "<storage-account-key>" -AsPlainText -Force
973974
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "Azure\<storage-account-name>", $acctKey
974-
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\<storage-account-name>.file.core.windows.net\my-file-share" -Credential $credential
975+
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\<storage-account-name>.file.core.windows.net\file-share" -Credential $credential
975976
```
976977

977-
Access to the share is denied, and you receive a `New-PSDrive : Access is denied` error. Access is denied because the *myVmPublic* VM is deployed in the *Public* subnet. The *Public* subnet does not have a service endpoint enabled for Azure Storage, and the storage account only allows network access from the *Private* subnet, not the *Public* subnet.
978+
Access to the share is denied, and you receive a `New-PSDrive : Access is denied` error. Access is denied because the *vm-public* VM is deployed in the *subnet-public* subnet. The *subnet-public* subnet does not have a service endpoint enabled for Azure Storage, and the storage account only allows network access from the *subnet-private* subnet, not the *subnet-public* subnet.
978979

979-
Close the remote desktop session to the *myVmPublic* VM.
980+
Close the remote desktop session to the *vm-public* VM.
980981

981982
From your computer, attempt to view the file shares in the storage account with the following command:
982983

983984
```powershell-interactive
984985
Get-AzStorageFile `
985-
-ShareName my-file-share `
986+
-ShareName file-share `
986987
-Context $storageContext
987988
```
988989

989-
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 *Private* subnet of the *MyVirtualNetwork* virtual network.
990+
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.
990991

991992
### [CLI](#tab/cli)
992993

@@ -1039,7 +1040,7 @@ Access is denied and you receive a **This request isn't authorized to perform th
10391040
When no longer needed, you can use [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) to remove the resource group and all of the resources it contains:
10401041

10411042
```azurepowershell-interactive
1042-
Remove-AzResourceGroup -Name myResourceGroup -Force
1043+
Remove-AzResourceGroup -Name test-rg -Force
10431044
```
10441045

10451046
### [CLI](#tab/cli)

0 commit comments

Comments
 (0)