# AzureSecurityRule

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

Represents a security rule configuration for an Azure Network Security Group.

## Definition

```csharp
namespace Aspire.Hosting.Azure;

public sealed class AzureSecurityRule
{
    // ...
}
```

## ATS metadata

### ATS DTO

- Serialized as a plain JSON object without a `$type` discriminator.

## Remarks

Security rules control inbound and outbound network traffic for subnets associated with the Network Security Group. Rules are evaluated in priority order, with lower numbers having higher priority.

## Constructors

- [AzureSecurityRule](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/constructors.md#constructor)

## Properties

- [Access](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#access) : `SecurityRuleAccess` `get; set` -- Gets or sets whether network traffic is allowed or denied.
- [Description](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#description) : `string?` `get; set` -- Gets or sets an optional description for the security rule.
- [DestinationAddressPrefix](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#destinationaddressprefix) : `string` `get; set` -- Gets or sets the destination address prefix. Defaults to "*" (any).
- [DestinationAddressPrefixReference](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#destinationaddressprefixreference) : `ReferenceExpression?` `get; set` -- Gets or sets a `ApplicationModel.ReferenceExpression` whose value is resolved at deploy time and used as the destination address prefix for the rule. Takes precedence over [AzureSecurityRule.DestinationAddressPrefix](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#destinationaddressprefix).
- [DestinationPortRange](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#destinationportrange) : `string` `get; set` -- Gets or sets the destination port range. Use "*" for any, or a range like "80-443".
- [Direction](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#direction) : `SecurityRuleDirection` `get; set` -- Gets or sets the direction of the rule.
- [Name](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#name) : `string` `get; set` -- Gets or sets the name of the security rule. This name must be unique within the Network Security Group.
- [Priority](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#priority) : `int` `get; set` -- Gets or sets the priority of the rule. Valid values are between 100 and 4096. Lower numbers have higher priority.
- [Protocol](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#protocol) : `SecurityRuleProtocol` `get; set` -- Gets or sets the network protocol this rule applies to.
- [SourceAddressPrefix](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#sourceaddressprefix) : `string` `get; set` -- Gets or sets the source address prefix. Defaults to "*" (any).
- [SourceAddressPrefixReference](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#sourceaddressprefixreference) : `ReferenceExpression?` `get; set` -- Gets or sets a `ApplicationModel.ReferenceExpression` whose value is resolved at deploy time and used as the source address prefix for the rule. Takes precedence over [AzureSecurityRule.SourceAddressPrefix](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#sourceaddressprefix).
- [SourcePortRange](/reference/api/csharp/aspire.hosting.azure.network/azuresecurityrule/properties.md#sourceportrange) : `string` `get; set` -- Gets or sets the source port range. Defaults to "*" (any).
