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

Sure, here are the steps to create an Azure Service Endpoint in the Azure Portal:

  1. Go to the Azure Portal and navigate to the resource group where you want to create the Service Endpoint.
  2. Select “Add” button and search for “Service Endpoint” in the search bar.
  3. Select “Service Endpoint” from the results and click on “Create”.
  4. In the “Basics” tab, enter a name for the Service Endpoint, select the subscription and the virtual network to which the Service Endpoint should be attached.
  5. In the “Resource” tab, select the service for which you want to create the Service Endpoint. For example, if you want to create a Service Endpoint for Azure Storage, select “Microsoft.Storage” as the resource provider.
  6. In the “Target sub-resource” section, select the specific sub-resource that the Service Endpoint should connect to. For example, if you want to create a Service Endpoint for a specific Storage Account, select “blob, file, queue, or table”.
  7. In the “Review + create” tab, review your settings and click on “Create” to create the Service Endpoint.

Here’s an example Powershell script to create a Service Endpoint for Azure Storage:





# Login to your Azure account
Connect-AzAccount

# Set variables
$resourceGroup = "myResourceGroup"
$virtualNetworkName = "myVirtualNetwork"
$subnetName = "mySubnet"
$serviceEndpointName = "myStorageEndpoint"
$storageAccountId = "/subscriptions/subscription-id/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"

# Get the virtual network
$vnet = Get-AzVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroup

# Get the subnet
$subnet = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet

# Create the Service Endpoint
Add-AzVirtualNetworkSubnetConfig -Name $subnet.Name -VirtualNetwork $vnet `
  -ServiceEndpointStorage $storageAccountId `
  -ServiceEndpointName $serviceEndpointName
  
# Update the virtual network
Set-AzVirtualNetwork -VirtualNetwork $vnet

This script creates a Service Endpoint for Azure Storage on a subnet in a virtual network. The Service Endpoint is named “myStorageEndpoint” and connects to the specified Storage Account.

Author: tonyhughes