# AzureSubnetResource.AddPrivateEndpoint

- Module: [Aspire.Hosting.Azure.Network](/reference/api/go/aspire.hosting.azure.network.md)
- Defined on: [AzureSubnetResource](/reference/api/go/aspire.hosting.azure.network/azuresubnetresource.md)
- Version: `17.0.0`
- Kind: `method`

Adds an Azure Private Endpoint resource to the subnet.

## Remarks

This method automatically creates the Private DNS Zone, VNet Link, and DNS Zone Group
required for private endpoint DNS resolution. Private DNS Zones are shared across
multiple private endpoints that use the same zone name.
When supported by the target integration, the target resource (or its parent) is automatically
configured to deny public network access. Check the target integration's documentation for
exceptions and any separate configuration required to restrict public access.
To override automatic lockdown, use
`ConfigureInfrastructure` to customize
the network settings.

## Definition

```go
type AzureSubnetResource interface {
    // ... omitted for brevity
    AddPrivateEndpoint(target AzurePrivateEndpointTarget) AzurePrivateEndpointResource
}
```

## Signature

```go
AddPrivateEndpoint(target AzurePrivateEndpointTarget) AzurePrivateEndpointResource
```

## Parameters

- `target` ([`AzurePrivateEndpointTarget`](/reference/api/go/aspire.hosting.azure.network/azureprivateendpointtarget.md)) -- The target Azure resource to connect via private link.

## Returns

[`AzurePrivateEndpointResource`](/reference/api/go/aspire.hosting.azure.network/azureprivateendpointresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [AzureSubnetResource](/reference/api/go/aspire.hosting.azure.network/azuresubnetresource.md) -- `handle`
