Skip to content

Commit 9791840

Browse files
Merge pull request #226035 from asudbring/privatelink-posh
Added disable network policy to fix errors
2 parents 9ff0256 + 8f2170f commit 9791840

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

articles/private-link/create-private-link-service-powershell.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: private-link
55
author: asudbring
66
ms.service: private-link
77
ms.topic: quickstart
8-
ms.date: 01/24/2021
8+
ms.date: 02/02/2023
99
ms.author: allensu
1010
ms.custom: devx-track-azurepowershell, mode-api
1111
#Customer intent: As someone with a basic network background, but is new to Azure, I want to create an Azure private link service
@@ -130,6 +130,30 @@ New-AzLoadBalancer @loadbalancer
130130
131131
```
132132

133+
## Disable network policy
134+
135+
Before a private link service can be created in the virtual network, the setting `privateLinkServiceNetworkPolicies` must be disabled.
136+
137+
* Disable the network policy with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-AzVirtualNetwork).
138+
139+
```azurepowershell-interactive
140+
## Place the subnet name into a variable. ##
141+
$subnet = 'mySubnet'
142+
143+
## Place the virtual network configuration into a variable. ##
144+
$net = @{
145+
Name = 'myVNet'
146+
ResourceGroupName = 'CreatePrivLinkService-rg'
147+
}
148+
$vnet = Get-AzVirtualNetwork @net
149+
150+
## Set the policy as disabled on the virtual network. ##
151+
($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq $subnet}).privateLinkServiceNetworkPolicies = "Disabled"
152+
153+
## Save the configuration changes to the virtual network. ##
154+
$vnet | Set-AzVirtualNetwork
155+
```
156+
133157
## Create a private link service
134158

135159
In this section, create a private link service that uses the Standard Azure Load Balancer created in the previous step.
@@ -138,7 +162,7 @@ In this section, create a private link service that uses the Standard Azure Load
138162

139163
* Create the private link service with [New-AzPrivateLinkService](/powershell/module/az.network/new-azprivatelinkservice).
140164

141-
```azurepowershell
165+
```azurepowershell-interactive
142166
## Place the virtual network into a variable. ##
143167
$vnet = Get-AzVirtualNetwork -Name 'myVNet' -ResourceGroupName 'CreatePrivLinkService-rg'
144168
@@ -207,8 +231,6 @@ $vnetpe = New-AzVirtualNetwork @net
207231

208232
* Use [New-AzPrivateEndpoint](/powershell/module/az.network/new-azprivateendpoint) to create the endpoint.
209233

210-
211-
212234
```azurepowershell-interactive
213235
## Place the private link service configuration into variable. ##
214236
$par1 = @{

0 commit comments

Comments
 (0)