Skip to content

Commit 22ca75f

Browse files
authored
Merge pull request #125566 from PeterDeThier-MSFT/patch-16
Update default-outbound-access.md
2 parents c1cbe44 + cc6fdab commit 22ca75f

File tree

1 file changed

+80
-8
lines changed

1 file changed

+80
-8
lines changed

articles/virtual-network/ip-services/default-outbound-access.md

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,88 @@ There are multiple ways to turn off default outbound access. The following secti
7777
> Certain services won't function on a virtual machine in a Private Subnet without an explicit method of egress (examples are Windows Activation and Windows Updates).
7878
7979
#### Add the Private subnet feature
80-
81-
* From the Azure portal, ensure the option to enable Private subnet is selected as part of the Virtual Network subnet create/modify experience as shown below:
82-
80+
81+
* From the Azure portal, select the subnet and select the checkbox to enable Private subnet as shown below:
82+
8383
:::image type="content" source="./media/default-outbound-access/private-subnet-portal.png" alt-text="Screenshot of Azure portal showing Private subnet option.":::
84-
85-
* Using PowerShell, when creating a subnet with [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig), use the `DefaultOutboundAccess` option and choose "$false". After creation, a subnet can be set using [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtualnetworksubnetconfig).
8684

87-
* Using CLI, when creating a subnet with [az network vnet subnet create](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-create), use the `--default-outbound` option and choose "false". After creation, a subnet can be set using [az network vnet subnet update](/cli/azure/network/vnet/subnet?view=azure-cli-latest#az-network-vnet-subnet-update).
88-
89-
* Using an Azure Resource Manager template, set the value of `defaultOutboundAccess` parameter to be "false".
85+
* Using Powershell, the following script takes the names of the Resource Group and Virtual Network and loops through each subnet to enable private subnet.
86+
87+
```
88+
$resourceGroupName = ""
89+
$vnetName = ""
90+
91+
$vnet = Get-AzVirtualNetwork -ResourceGroupName $resourceGroupName -Name $vnetName
92+
93+
foreach ($subnet in $vnet.Subnets) {
94+
if ($subnet.DefaultOutboundAccess -eq $null) {
95+
$subnet.DefaultOutboundAccess = $false
96+
Write-Output "Set 'defaultoutboundaccess' to \$false for subnet: $($subnet.Name)"
97+
}
98+
elseif ($subnet.DefaultOutboundAccess -eq $false) {
99+
# Output message if the value is already $false
100+
Write-Output "already private for subnet: $($subnet.Name)"
101+
}
102+
}
103+
Set-AzVirtualNetwork -VirtualNetwork $vnet
104+
```
105+
106+
* Using CLI, update the subnet with [az network vnet subnet update](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) and set `--default-outbound` to "false"
107+
108+
```
109+
az network vnet subnet update --resource-group rgname --name subnetname --vnet-name vnetname --default-outbound false
110+
```
111+
112+
* Using an Azure Resource Manager template, set the value of `defaultOutboundAccess` parameter to be "false"
113+
114+
```
115+
{
116+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
117+
"contentVersion": "1.0.0.0",
118+
"parameters": {
119+
"vnetName": {
120+
"type": "string",
121+
"defaultValue": "testvm-vnet"
122+
},
123+
"subnetName": {
124+
"type": "string",
125+
"defaultValue": "default"
126+
},
127+
"subnetPrefix": {
128+
"type": "string",
129+
"defaultValue": "10.1.0.0/24"
130+
},
131+
"vnetAddressPrefix": {
132+
"type": "string",
133+
"defaultValue": "10.1.0.0/16"
134+
}
135+
},
136+
"resources": [
137+
{
138+
"type": "Microsoft.Network/virtualNetworks",
139+
"apiVersion": "2023-11-01",
140+
"name": "[parameters('vnetName')]",
141+
"location": "westus2",
142+
"properties": {
143+
"addressSpace": {
144+
"addressPrefixes": [
145+
"[parameters('vnetAddressPrefix')]"
146+
]
147+
},
148+
"subnets": [
149+
{
150+
"name": "[parameters('subnetName')]",
151+
"properties": {
152+
"addressPrefix": "[parameters('subnetPrefix')]",
153+
"defaultoutboundaccess": false
154+
}
155+
}
156+
]
157+
}
158+
}
159+
]
160+
}
161+
```
90162

91163
#### Private subnet limitations
92164

0 commit comments

Comments
 (0)