# WithDelegatedSubnet

- Module: [Aspire.Hosting.Azure.Network](/reference/api/go/aspire.hosting.azure.network.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`AzureDelegatedSubnetResource`](/reference/api/go/aspire.hosting.azure.network/azuredelegatedsubnetresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

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
func (AzureDelegatedSubnetResource) 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()`.

## Applies to

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