Skip to content

Commit 5ddc32a

Browse files
authored
Merge pull request #226031 from asudbring/privatelink-disable-policy
Updated page, added tabs, and fixed up code for Disable network policy for Private Link Service
2 parents 9791840 + d39e0ae commit 5ddc32a

File tree

1 file changed

+44
-24
lines changed

1 file changed

+44
-24
lines changed

articles/private-link/disable-private-link-service-network-policy.md

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
title: 'Disable network policies for Azure Private Link service source IP address '
33
description: Learn how to disable network policies for Azure private Link
44
services: private-link
5-
author: malopMSFT
5+
author: asudbring
66
ms.service: private-link
77
ms.topic: how-to
8-
ms.date: 09/16/2019
8+
ms.date: 02/02/2023
99
ms.author: allensu
1010
ms.custom: devx-track-azurepowershell, devx-track-azurecli
1111
ms.devlang: azurecli
@@ -15,52 +15,68 @@ ms.devlang: azurecli
1515

1616
In order to choose a source IP address for your Private Link service, an explicit disable setting `privateLinkServiceNetworkPolicies` is required on the subnet. This setting is only applicable for the specific private IP address you chose as the source IP of the Private Link service. For other resources in the subnet, access is controlled based on Network Security Groups (NSG) security rules definition.
1717

18-
When using the portal to create a Private Link service, this setting is automatically disabled as part of the create process. Deployments using any Azure client (PowerShell, CLI or templates), require an additional step to change this property. You can disable the policy using the cloud shell from the Azure portal, or local installations of Azure PowerShell, Azure CLI, or use Azure Resource Manager templates.
18+
When using the portal to create a Private Link service, this setting is automatically disabled as part of the create process. Deployments using any Azure client (PowerShell, CLI or templates), require an extra step to change this property.
1919

20-
Follow the steps below to disable private link service network policies for a virtual network named *myVirtualNetwork* with a *default* subnet hosted in a resource group named *myResourceGroup*.
20+
You can use the following to enable or disable the setting:
2121

22-
## Using Azure PowerShell
23-
This section describes how to disable subnet private endpoint policies using Azure PowerShell.
24-
In the code, replace "default" with the name of the virtual subnet.
22+
* Azure PowerShell
2523

26-
```azurepowershell
27-
$virtualSubnetName = "default"
28-
$virtualNetwork= Get-AzVirtualNetwork `
29-
-Name "myVirtualNetwork" `
30-
-ResourceGroupName "myResourceGroup"
31-
32-
($virtualNetwork | Select -ExpandProperty subnets | Where-Object {$_.Name -eq $virtualSubnetName} ).privateLinkServiceNetworkPolicies = "Disabled"
24+
* Azure CLI
25+
26+
* Azure Resource Manager templates
3327

34-
$virtualNetwork | Set-AzVirtualNetwork
28+
The following examples describe how to enable and disable `privateLinkServiceNetworkPolicies` for a virtual network named **myVNet** with a **default** subnet of **10.1.0.0/24** hosted in a resource group named **myResourceGroup**.
29+
30+
# [**PowerShell**](#tab/private-link-network-policy-powershell)
31+
32+
This section describes how to disable subnet private endpoint policies using Azure PowerShell. In the following code, replace "default" with the name of your virtual subnet.
33+
34+
```azurepowershell
35+
$subnet = 'default'
36+
37+
$net = @{
38+
Name = 'myVNet'
39+
ResourceGroupName = 'myResourceGroup'
40+
}
41+
$vnet = Get-AzVirtualNetwork @net
42+
43+
($vnet | Select -ExpandProperty subnets | Where-Object {$_.Name -eq $subnet}).privateLinkServiceNetworkPolicies = "Disabled"
44+
45+
$vnet | Set-AzVirtualNetwork
3546
```
36-
## Using Azure CLI
47+
48+
# [**CLI**](#tab/private-link-network-policy-cli)
49+
3750
This section describes how to disable subnet private endpoint policies using Azure CLI.
51+
3852
```azurecli
3953
az network vnet subnet update \
40-
--name default \
41-
--resource-group myResourceGroup \
42-
--vnet-name myVirtualNetwork \
43-
--disable-private-link-service-network-policies true
54+
--name default \
55+
--resource-group myResourceGroup \
56+
--vnet-name myVNet \
57+
--disable-private-link-service-network-policies true
4458
```
45-
## Using a template
59+
60+
# [**JSON**](#tab/private-link-network-policy-json)
61+
4662
This section describes how to disable subnet private endpoint policies using Azure Resource Manager Template.
4763
```json
4864
{
49-
"name": "myVirtualNetwork",
65+
"name": "myVNet",
5066
"type": "Microsoft.Network/virtualNetworks",
5167
"apiVersion": "2019-04-01",
5268
"location": "WestUS",
5369
"properties": {
5470
"addressSpace": {
5571
"addressPrefixes": [
56-
"10.0.0.0/16"
72+
"10.1.0.0/16"
5773
]
5874
},
5975
"subnets": [
6076
{
6177
"name": "default",
6278
"properties": {
63-
"addressPrefix": "10.0.0.0/24",
79+
"addressPrefix": "10.1.0.0/24",
6480
"privateLinkServiceNetworkPolicies": "Disabled"
6581
}
6682
}
@@ -69,6 +85,10 @@ This section describes how to disable subnet private endpoint policies using Azu
6985
}
7086

7187
```
88+
89+
---
90+
7291
## Next steps
92+
7393
- Learn more about [Azure Private Endpoint](private-endpoint-overview.md)
7494

0 commit comments

Comments
 (0)