About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
powershell_heavy
⚠️
windows_first
Summary:
The documentation provides comprehensive examples for Azure Portal, Azure PowerShell, Azure CLI, and Bicep. However, there is a notable emphasis on Azure PowerShell, which is most commonly used on Windows, and PowerShell examples are often presented before Azure CLI. The PowerShell sections are more verbose and detailed, and prerequisites for PowerShell include specific instructions for Windows environments. While Azure CLI is cross-platform and suitable for Linux, it is consistently listed after PowerShell, and there are no explicit Linux shell (bash) or scripting examples. There is no mention of Linux-specific tools, nor is there guidance for Linux users beyond Azure CLI.
Recommendations:
- Present Azure CLI examples before PowerShell, as CLI is cross-platform and preferred by many Linux users.
- Explicitly mention that Azure CLI commands work on Linux, macOS, and Windows, and provide sample shell environments (e.g., bash) where appropriate.
- Add a short section or note for Linux users, clarifying that Azure CLI is the recommended tool for Linux and macOS, and that PowerShell is optional.
- Where PowerShell is referenced, clarify that it is available cross-platform, but that Azure CLI may be more familiar to Linux users.
- Consider including bash script snippets or references to Linux shell usage, especially in the prerequisites and setup sections.
- Ensure parity in detail and explanation between PowerShell and CLI sections, so Linux users are not disadvantaged.
Create pull request
Flagged Code Snippets
## Place NAT gateway into a variable. ##
$ng = @{
Name = 'nat-gateway'
ResourceGroupName = 'test-rg'
}
$nat = Get-AzNatGateway @ng
## Place the existing public IP prefix associated with the NAT gateway into a variable. ##
$ip = @{
Name = 'public-ip-prefix-nat'
ResourceGroupName = 'test-rg'
}
$prefixIP1 = Get-AzPublicIPPrefix @ip
## Place the secondary public IP prefix into a variable. ##
$ip = @{
Name = 'public-ip-prefix-nat2'
ResourceGroupName = 'test-rg'
}
$prefixIP2 = Get-AzPublicIPprefix @ip
## Place ONLY the prefix you wish to keep in the array. DO NOT ADD THE SECONDARY VARIABLE ##
$preArray = $prefixIP1
## Add the IP address prefix to the NAT gateway. ##
$nt = @{
NatGateway = $nat
PublicIpPrefix = $preArray
}
Set-AzNatGateway @nt
## Place the virtual network into a variable. ##
$net = @{
Name = 'vnet-1'
ResourceGroupName = 'test-rg'
}
$vnet = Get-AzVirtualNetwork @net
## Place the public IP prefix you created previously into a variable. ##
$pip = @{
Name = 'public-ip-prefix-nat'
ResourceGroupName = 'test-rg'
}
$publicIPprefix = Get-AzPublicIPPrefix @pip
## Create NAT gateway resource ##
$nat = @{
ResourceGroupName = 'test-rgNAT'
Name = 'nat-gateway'
IdleTimeoutInMinutes = '4'
Sku = 'Standard'
Location = 'eastus2'
PublicIpPrefix = $publicIPprefix
}
$natGateway = New-AzNatGateway @nat
## Create the subnet configuration. ##
$sub = @{
Name = 'subnet-1'
VirtualNetwork = $vnet
NatGateway = $natGateway
AddressPrefix = '10.0.0.0/24'
}
Set-AzVirtualNetworkSubnetConfig @sub
## Save the configuration to the virtual network. ##
$vnet | Set-AzVirtualNetwork
# Specify the resource group and NAT gateway name
$resourceGroupName = "test-rg"
# Specify the virtual network name and subnet name
$virtualNetworkName = "vnet-1"
$subnetName = "subnet-1"
# Get the virtual network
$vnet = @{
Name = $virtualNetworkName
ResourceGroupName = $resourceGroupName
}
$virtualNetwork = Get-AzVirtualNetwork @vnet
# Get the subnet
$subnet = $virtualNetwork.Subnets | Where-Object {$_.Name -eq $subnetName}
# Remove the NAT gateway association from the subnet
$subnet.NatGateway = $null
# Update the subnet configuration
$subConfig = @{
Name = $subnetName
VirtualNetwork = $virtualNetwork
AddressPrefix = $subnet.AddressPrefix
}
Set-AzVirtualNetworkSubnetConfig @subConfig
# Update the virtual network
Set-AzVirtualNetwork -VirtualNetwork $virtualNetwork
## Create public IP prefix for NAT gateway ##
$ip = @{
Name = 'public-ip-prefix-nat2'
ResourceGroupName = 'test-rg'
Location = 'eastus2'
Sku = 'Standard'
PrefixLength = '29'
}
New-AzPublicIpPrefix @ip