To create an Azure Private Endpoint in the Azure Portal, you can follow these steps:
- Navigate to your desired resource (such as a storage account or Azure SQL database).
- Click on “Private endpoint connections” in the left-hand menu.
- Click on the “Add” button to create a new private endpoint connection.
- Configure the private endpoint connection by selecting the virtual network, subnet, and private IP address that you want to use for the private endpoint.
- 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.