# AzureVirtualNetworkExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Azure.Network](/reference/api/csharp/aspire.hosting.azure.network.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkExtensions.cs)

Provides extension methods for adding Azure Virtual Network resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class AzureVirtualNetworkExtensions
{
    // ...
}
```

## Methods

- [AddAzureVirtualNetwork(IDistributedApplicationBuilder, string, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#addazurevirtualnetwork-idistributedapplicationbuilder-string-string) : `IResourceBuilder<AzureVirtualNetworkResource>` `extension` `ats ignored` -- Adds an Azure Virtual Network resource to the application model.
- [AddAzureVirtualNetwork(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#addazurevirtualnetwork-idistributedapplicationbuilder-string-iresourcebuilder-parameterresource) : `IResourceBuilder<AzureVirtualNetworkResource>` `extension` `ats ignored` -- Adds an Azure Virtual Network resource to the application model with a parameterized address prefix.
- [AddSubnet(IResourceBuilder<AzureVirtualNetworkResource>, string, string, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#addsubnet-iresourcebuilder-azurevirtualnetworkresource-string-string-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats ignored` -- Adds an Azure Subnet to the Virtual Network.
- [AddSubnet(IResourceBuilder<AzureVirtualNetworkResource>, string, IResourceBuilder<ParameterResource>, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#addsubnet-iresourcebuilder-azurevirtualnetworkresource-string-iresourcebuilder-parameterresource-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats ignored` -- Adds an Azure Subnet to the Virtual Network with a parameterized address prefix.
- [AllowInbound(IResourceBuilder<AzureSubnetResource>, string?, string?, string?, SecurityRuleProtocol?, int?, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#allowinbound-iresourcebuilder-azuresubnetresource-string-string-string-securityruleprotocol-int-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Adds an inbound allow rule to the subnet's Network Security Group.
- [AllowOutbound(IResourceBuilder<AzureSubnetResource>, string?, string?, string?, SecurityRuleProtocol?, int?, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#allowoutbound-iresourcebuilder-azuresubnetresource-string-string-string-securityruleprotocol-int-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Adds an outbound allow rule to the subnet's Network Security Group.
- [DenyInbound(IResourceBuilder<AzureSubnetResource>, string?, string?, string?, SecurityRuleProtocol?, int?, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#denyinbound-iresourcebuilder-azuresubnetresource-string-string-string-securityruleprotocol-int-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Adds an inbound deny rule to the subnet's Network Security Group.
- [DenyOutbound(IResourceBuilder<AzureSubnetResource>, string?, string?, string?, SecurityRuleProtocol?, int?, string?)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#denyoutbound-iresourcebuilder-azuresubnetresource-string-string-string-securityruleprotocol-int-string) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Adds an outbound deny rule to the subnet's Network Security Group.
- [WithDelegatedSubnet(IResourceBuilder<T>, IResourceBuilder<AzureSubnetResource>)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#withdelegatedsubnet-iresourcebuilder-t-iresourcebuilder-azuresubnetresource) : `IResourceBuilder<T>` `extension` `ats export` -- Configures the resource to use the specified subnet with appropriate service delegation.
- [WithNatGateway(IResourceBuilder<AzureSubnetResource>, IResourceBuilder<AzureNatGatewayResource>)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#withnatgateway-iresourcebuilder-azuresubnetresource-iresourcebuilder-azurenatgatewayresource) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Associates a NAT Gateway with the subnet.
- [WithNetworkSecurityGroup(IResourceBuilder<AzureSubnetResource>, IResourceBuilder<AzureNetworkSecurityGroupResource>)](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkextensions/methods.md#withnetworksecuritygroup-iresourcebuilder-azuresubnetresource-iresourcebuilder-azurenetworksecuritygroupresource) : `IResourceBuilder<AzureSubnetResource>` `extension` `ats export` -- Associates a Network Security Group with the subnet.
