# AzureDelegatedSubnetResource.WithDelegatedSubnet

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

Configures the resource to use the specified subnet with appropriate service delegation.

## Remarks

This method automatically configures the subnet with the appropriate service delegation
for the target resource type (for example, "Microsoft.App/environments" for Azure Container Apps
and "Microsoft.Web/serverFarms" for Azure App Service).
A resource can only be associated with one delegated subnet. Repeating the call with the same subnet is idempotent.

## Definition

```go
type AzureDelegatedSubnetResource interface {
    // ... omitted for brevity
    WithDelegatedSubnet(subnet AzureSubnetResource) AzureDelegatedSubnetResource
}
```

## Signature

```go
WithDelegatedSubnet(subnet AzureSubnetResource) AzureDelegatedSubnetResource
```

## Parameters

- `subnet` ([`AzureSubnetResource`](/reference/api/go/aspire.hosting.azure.network/azuresubnetresource.md)) -- The subnet to associate with the resource.

## Returns

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

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

## Defined on

- [AzureDelegatedSubnetResource](/reference/api/go/aspire.hosting.azure.network/azuredelegatedsubnetresource.md) -- `interface`
