How do I create Azure Private Endpoints in the Azure Portal or Powershell?

To create an Azure Private Endpoint in the Azure Portal, you can follow these steps:

  1. Navigate to your desired resource (such as a storage account or Azure SQL database).
  2. Click on “Private endpoint connections” in the left-hand menu.
  3. Click on the “Add” button to create a new private endpoint connection.
  4. Configure the private endpoint connection by selecting the virtual network, subnet, and private IP address that you want to use for the private endpoint.
  5. Review and create the private endpoint connection.

To create an Azure Private Endpoint using PowerShell, you can use the New-AzPrivateEndpoint cmdlet. Here’s an example:

powershell
$resourceGroup = "myResourceGroup"
$location = "eastus"
$subnetName = "mySubnet"
$privateEndpointName = "myPrivateEndpoint"
$privateEndpointConnectionName = "myPrivateEndpointConnection"
$resourceName = "myStorageAccount"
$groupId = "blob"

# Get the subnet ID
$subnetId = (Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork (Get-AzVirtualNetwork -ResourceGroupName $resourceGroup -Name "myVNet")).Id

# Create the private endpoint
$privateEndpoint = New-AzPrivateEndpoint `
    -Name $privateEndpointName `
    -ResourceGroupName $resourceGroup `
    -Location $location `
    -SubnetId $subnetId `
    -PrivateServiceConnectionResourceId (Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $resourceName).Id `
    -GroupId $groupId

# Create the private endpoint connection
New-AzPrivateEndpointConnection `
    -Name $privateEndpointConnectionName `
    -ResourceGroupName $resourceGroup `
    -PrivateEndpoint $privateEndpoint `
    -RemoteResourceId (Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $resourceName).Id `
    -GroupId $groupId

This PowerShell script creates a private endpoint for an Azure Storage account and connects it to a subnet in an Azure virtual network.

Author: tonyhughes