# AzureVirtualNetworkResource Constructors

- Package: [Aspire.Hosting.Azure.Network](/reference/api/csharp/aspire.hosting.azure.network.md)
- Type: [AzureVirtualNetworkResource](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkresource.md)
- Kind: `Constructors`
- Members: `3`

Represents an Azure Virtual Network resource.

## AzureVirtualNetworkResource(string, Action<AzureResourceInfrastructure>)

- Name: `Constructor(string, Action<AzureResourceInfrastructure>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs#L17-L27)

Represents an Azure Virtual Network resource.

```csharp
public class AzureVirtualNetworkResource
{
    public AzureVirtualNetworkResource(
        string name,
        Action<AzureResourceInfrastructure> configureInfrastructure)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `configureInfrastructure` (`Action<AzureResourceInfrastructure>`)
  Callback to configure the Azure Virtual Network resource.

## AzureVirtualNetworkResource(string, Action<AzureResourceInfrastructure>, string?)

- Name: `Constructor(string, Action<AzureResourceInfrastructure>, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs)

Initializes a new instance of the [AzureVirtualNetworkResource](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkresource.md) class with a string address prefix.

```csharp
public class AzureVirtualNetworkResource
{
    public AzureVirtualNetworkResource(
        string name,
        Action<AzureResourceInfrastructure> configureInfrastructure,
        string? addressPrefix)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `configureInfrastructure` (`Action<AzureResourceInfrastructure>`)
  Callback to configure the Azure Virtual Network resource.
- `addressPrefix` (`string?`)
  The address prefix for the virtual network (e.g., "10.0.0.0/16").

## AzureVirtualNetworkResource(string, Action<AzureResourceInfrastructure>, ParameterResource)

- Name: `Constructor(string, Action<AzureResourceInfrastructure>, ParameterResource)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Network/AzureVirtualNetworkResource.cs)

Initializes a new instance of the [AzureVirtualNetworkResource](/reference/api/csharp/aspire.hosting.azure.network/azurevirtualnetworkresource.md) class with a parameterized address prefix.

```csharp
public class AzureVirtualNetworkResource
{
    public AzureVirtualNetworkResource(
        string name,
        Action<AzureResourceInfrastructure> configureInfrastructure,
        ParameterResource addressPrefix)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `configureInfrastructure` (`Action<AzureResourceInfrastructure>`)
  Callback to configure the Azure Virtual Network resource.
- `addressPrefix` (`ParameterResource`)
  The parameter resource containing the address prefix for the virtual network.
