# AzureSubnetResource

- Module: [Aspire.Hosting.Azure.Network](/reference/api/typescript/aspire.hosting.azure.network.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents an Azure Subnet resource.

## Definition

```typescript
interface AzureSubnetResource
  extends IResource,
    IResourceWithParent,
    AzureVirtualNetworkResource]] {
  addPrivateEndpoint(target: IAzurePrivateEndpointTarget): AzurePrivateEndpointResource;
  allowInbound(
      port?: string,
      from?: string,
      to?: string,
      protocol?: SecurityRuleProtocol,
      priority?: number,
      name?: string): AzureSubnetResource;
  allowOutbound(
      port?: string,
      from?: string,
      to?: string,
      protocol?: SecurityRuleProtocol,
      priority?: number,
      name?: string): AzureSubnetResource;
  denyInbound(
      port?: string,
      from?: string,
      to?: string,
      protocol?: SecurityRuleProtocol,
      priority?: number,
      name?: string): AzureSubnetResource;
  denyOutbound(
      port?: string,
      from?: string,
      to?: string,
      protocol?: SecurityRuleProtocol,
      priority?: number,
      name?: string): AzureSubnetResource;
  withNatGateway(natGateway: AzureNatGatewayResource): AzureSubnetResource;
  withNetworkSecurityGroup(nsg: AzureNetworkSecurityGroupResource): AzureSubnetResource;
}
```

## Methods

- [addPrivateEndpoint](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/addprivateendpoint.md) -- `method` -- Adds an Azure Private Endpoint resource to the subnet.
    ```typescript
  addPrivateEndpoint(target: IAzurePrivateEndpointTarget): AzurePrivateEndpointResource
  ```
- [allowInbound](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/allowinbound.md) -- `method` -- Adds an inbound allow rule to the subnet's Network Security Group.
    ```typescript
  allowInbound(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): AzureSubnetResource
  ```
- [allowOutbound](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/allowoutbound.md) -- `method` -- Adds an outbound allow rule to the subnet's Network Security Group.
    ```typescript
  allowOutbound(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): AzureSubnetResource
  ```
- [denyInbound](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/denyinbound.md) -- `method` -- Adds an inbound deny rule to the subnet's Network Security Group.
    ```typescript
  denyInbound(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): AzureSubnetResource
  ```
- [denyOutbound](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/denyoutbound.md) -- `method` -- Adds an outbound deny rule to the subnet's Network Security Group.
    ```typescript
  denyOutbound(port?: string, from?: string, to?: string, protocol?: SecurityRuleProtocol, priority?: number, name?: string): AzureSubnetResource
  ```
- [withNatGateway](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/withnatgateway.md) -- `method` -- Associates a NAT Gateway with the subnet.
    ```typescript
  withNatGateway(natGateway: AzureNatGatewayResource): AzureSubnetResource
  ```
- [withNetworkSecurityGroup](/reference/api/typescript/aspire.hosting.azure.network/azuresubnetresource/withnetworksecuritygroup.md) -- `method` -- Associates a Network Security Group with the subnet.
    ```typescript
  withNetworkSecurityGroup(nsg: AzureNetworkSecurityGroupResource): AzureSubnetResource
  ```
