# WithNatGateway

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

Associates a NAT Gateway with the subnet.

## Remarks

A NAT Gateway provides outbound internet connectivity for resources in the subnet.
A subnet can have at most one NAT Gateway.

## Definition

```go
func (AzureSubnetResource) WithNatGateway(natGateway AzureNatGatewayResource) AzureSubnetResource
```

## Parameters

- `natGateway` ([`AzureNatGatewayResource`](/reference/api/go/aspire.hosting.azure.network/azurenatgatewayresource.md)) -- The NAT Gateway to associate with the subnet.

## Returns

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

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

## Applies to

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