- 最新
- 2025-07-01
- 2025-05-01
- 2025-03-01
- 2025-01-01
- 2024-10-01
- 2024-07-01
- 2024-05-01
- 2024-03-01
- 2024-01-01
- 2023-11-01
- 2023-09-01
- 2023-06-01
- 2023-05-01
- 2023-04-01
- 2023-02-01
- 2022-11-01
- 2022-09-01
- 2022-07-01
- 2022-05-01
- 2022-01-01
- 2021-08-01
- 2021-05-01
- 2021-03-01
- 2021-02-01
- 2020-11-01
- 2020-08-01
- 2020-07-01
- 2020-06-01
- 2020-05-01
- 2020-04-01
- 2020-03-01
- 2019-12-01
- 2019-11-01
- 2019-09-01
- 2019-08-01
- 2019-07-01
- 2019-06-01
- 2019-04-01
- 2019-02-01
- 2018-12-01
- 2018-11-01
- 2018-10-01
- 2018-08-01
- 2018-07-01
- 2018-06-01
- 2018-04-01
- 2018-02-01
- 2018-01-01
- 2017-11-01
- 2017-10-01
- 2017-09-01
- 2017-08-01
- 2017-06-01
- 2017-03-30
- 2017-03-01
- 2016-12-01
- 2016-09-01
- 2016-06-01
- 2016-03-30
- 2015-06-15
- 2015-05-01-預覽版
言論
如需建立網路安全組的指引,請參閱 使用 Bicep建立虛擬網路資源。
Bicep 資源定義
networkSecurityGroups/securityRules 資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Network/networkSecurityGroups/securityRules 資源,請將下列 Bicep 新增至範本。
resource symbolicname 'Microsoft.Network/networkSecurityGroups/securityRules@2025-07-01' = {
parent: resourceSymbolicName
name: 'string'
properties: {
access: 'string'
description: 'string'
destinationAddressPrefix: 'string'
destinationAddressPrefixes: [
'string'
]
destinationApplicationSecurityGroups: [
{
id: 'string'
location: 'string'
properties: {}
tags: {
{customized property}: 'string'
}
}
]
destinationPortRange: 'string'
destinationPortRanges: [
'string'
]
direction: 'string'
priority: int
protocol: 'string'
sourceAddressPrefix: 'string'
sourceAddressPrefixes: [
'string'
]
sourceApplicationSecurityGroups: [
{
id: 'string'
location: 'string'
properties: {}
tags: {
{customized property}: 'string'
}
}
]
sourcePortRange: 'string'
sourcePortRanges: [
'string'
]
}
}
屬性值
Microsoft.Network/networkSecurityGroups/securityRules
| 名字 | 描述 | 價值 |
|---|---|---|
| 名字 | 資源名稱 | 字串 (必要) |
| 父代 | 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。 如需詳細資訊,請參閱 父資源外部的子資源。 |
類型資源的符號名稱:networkSecurityGroups |
| 性能 | 安全性規則的屬性。 | CommonSecurityRuleProperties格式 |
CommonApplicationSecurityGroup
| 名字 | 描述 | 價值 |
|---|---|---|
| 識別碼 | 資源標識碼。 | 字串 |
| 位置 | 資源位置。 | 字串 |
| 性能 | 應用程式安全組的屬性。 | CommonApplicationSecurityGroupPropertiesFormat |
| 標籤 | 資源標籤。 | CommonResourceTags |
CommonApplicationSecurityGroupPropertiesFormat
| 名字 | 描述 | 價值 |
|---|
CommonResourceTags
| 名字 | 描述 | 價值 |
|---|
CommonSecurityRuleProperties格式
| 名字 | 描述 | 價值 |
|---|---|---|
| 訪問 | 允許或拒絕網路流量。 | '允許' '拒絕' (必要) |
| 描述 | 此規則的描述。 限制為140個字元。 | 字串 |
| destinationAddressPrefix 的 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 | 字串 |
| destinationAddress前綴 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 | 字串[] |
| destinationApplicationSecurityGroups | 指定為目的地的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| destinationPortRange | 目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| destinationPortRanges | 目的地埠範圍。 | 字串[] |
| 方向 | 規則的方向。 方向會指定規則是否會在傳入或傳出流量上進行評估。 | “入站” '輸出' (必要) |
| 優先權 | 規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 | int (必要) |
| 通訊協定 | 此規則適用的網路協定。 | '*' “啊” 'ESP' “ICMP” 'tcp' 'Udp' (必要) |
| sourceAddressPrefix 的 | CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 | 字串 |
| sourceAddress前綴 | CIDR 或來源IP範圍。 | 字串[] |
| sourceApplicationSecurityGroups | 指定為來源的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| sourcePortRange | 來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| sourcePort範圍 | 來源埠範圍。 | 字串[] |
使用範例
Bicep 範例
部署網路安全規則的基本範例。
param resourceName string = 'acctest0001'
param location string = 'westeurope'
resource networkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2022-07-01' = {
name: 'mi-security-group1-230630034008554952'
location: location
properties: {
securityRules: []
}
}
resource securityRule 'Microsoft.Network/networkSecurityGroups/securityRules@2022-09-01' = {
name: 'allow_management_inbound'
parent: networkSecurityGroup
properties: {
access: 'Allow'
destinationAddressPrefix: '*'
destinationPortRange: ''
destinationPortRanges: [
'9000'
'1438'
'1440'
'9003'
'1452'
]
direction: 'Inbound'
priority: 106
protocol: 'Tcp'
sourceAddressPrefix: '*'
sourcePortRange: '*'
}
}
ARM 樣本資源定義
networkSecurityGroups/securityRules 資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Network/networkSecurityGroups/securityRules 資源,請將下列 JSON 新增至範本。
{
"type": "Microsoft.Network/networkSecurityGroups/securityRules",
"apiVersion": "2025-07-01",
"name": "string",
"properties": {
"access": "string",
"description": "string",
"destinationAddressPrefix": "string",
"destinationAddressPrefixes": [ "string" ],
"destinationApplicationSecurityGroups": [
{
"id": "string",
"location": "string",
"properties": {
},
"tags": {
"{customized property}": "string"
}
}
],
"destinationPortRange": "string",
"destinationPortRanges": [ "string" ],
"direction": "string",
"priority": "int",
"protocol": "string",
"sourceAddressPrefix": "string",
"sourceAddressPrefixes": [ "string" ],
"sourceApplicationSecurityGroups": [
{
"id": "string",
"location": "string",
"properties": {
},
"tags": {
"{customized property}": "string"
}
}
],
"sourcePortRange": "string",
"sourcePortRanges": [ "string" ]
}
}
屬性值
Microsoft.Network/networkSecurityGroups/securityRules
| 名字 | 描述 | 價值 |
|---|---|---|
| apiVersion | API 版本 | '2025-07-01' |
| 名字 | 資源名稱 | 字串 (必要) |
| 性能 | 安全性規則的屬性。 | CommonSecurityRuleProperties格式 |
| 型別 | 資源類型 | “Microsoft.Network/networkSecurityGroups/securityRules” |
CommonApplicationSecurityGroup
| 名字 | 描述 | 價值 |
|---|---|---|
| 識別碼 | 資源標識碼。 | 字串 |
| 位置 | 資源位置。 | 字串 |
| 性能 | 應用程式安全組的屬性。 | CommonApplicationSecurityGroupPropertiesFormat |
| 標籤 | 資源標籤。 | CommonResourceTags |
CommonApplicationSecurityGroupPropertiesFormat
| 名字 | 描述 | 價值 |
|---|
CommonResourceTags
| 名字 | 描述 | 價值 |
|---|
CommonSecurityRuleProperties格式
| 名字 | 描述 | 價值 |
|---|---|---|
| 訪問 | 允許或拒絕網路流量。 | '允許' '拒絕' (必要) |
| 描述 | 此規則的描述。 限制為140個字元。 | 字串 |
| destinationAddressPrefix 的 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 | 字串 |
| destinationAddress前綴 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 | 字串[] |
| destinationApplicationSecurityGroups | 指定為目的地的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| destinationPortRange | 目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| destinationPortRanges | 目的地埠範圍。 | 字串[] |
| 方向 | 規則的方向。 方向會指定規則是否會在傳入或傳出流量上進行評估。 | “入站” '輸出' (必要) |
| 優先權 | 規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 | int (必要) |
| 通訊協定 | 此規則適用的網路協定。 | '*' “啊” 'ESP' “ICMP” 'tcp' 'Udp' (必要) |
| sourceAddressPrefix 的 | CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 | 字串 |
| sourceAddress前綴 | CIDR 或來源IP範圍。 | 字串[] |
| sourceApplicationSecurityGroups | 指定為來源的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| sourcePortRange | 來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| sourcePort範圍 | 來源埠範圍。 | 字串[] |
使用範例
Azure 快速入門範本
下列 Azure 快速入門範本 部署此資源類型。
| 範本 | 描述 |
|---|---|
|
部署深色追蹤自動調整 vSensors |
此範本可讓您部署 Darktrace vSensors 的自動自動調整部署 |
Terraform (AzAPI 提供者) 資源定義
networkSecurityGroups/securityRules 資源類型可以使用目標作業來部署:
- 資源群組
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Network/networkSecurityGroups/securityRules 資源,請將下列 Terraform 新增至範本。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Network/networkSecurityGroups/securityRules@2025-07-01"
name = "string"
parent_id = "string"
body = {
properties = {
access = "string"
description = "string"
destinationAddressPrefix = "string"
destinationAddressPrefixes = [
"string"
]
destinationApplicationSecurityGroups = [
{
id = "string"
location = "string"
properties = {
}
tags = {
{customized property} = "string"
}
}
]
destinationPortRange = "string"
destinationPortRanges = [
"string"
]
direction = "string"
priority = int
protocol = "string"
sourceAddressPrefix = "string"
sourceAddressPrefixes = [
"string"
]
sourceApplicationSecurityGroups = [
{
id = "string"
location = "string"
properties = {
}
tags = {
{customized property} = "string"
}
}
]
sourcePortRange = "string"
sourcePortRanges = [
"string"
]
}
}
}
屬性值
Microsoft.Network/networkSecurityGroups/securityRules
| 名字 | 描述 | 價值 |
|---|---|---|
| 名字 | 資源名稱 | 字串 (必要) |
| 父項識別碼 | 此資源為父系之資源的標識碼。 | 類型資源的標識碼:networkSecurityGroups |
| 性能 | 安全性規則的屬性。 | CommonSecurityRuleProperties格式 |
| 型別 | 資源類型 | 「Microsoft。Network/networkSecurityGroups/securityRules@2025-07-01” |
CommonApplicationSecurityGroup
| 名字 | 描述 | 價值 |
|---|---|---|
| 識別碼 | 資源標識碼。 | 字串 |
| 位置 | 資源位置。 | 字串 |
| 性能 | 應用程式安全組的屬性。 | CommonApplicationSecurityGroupPropertiesFormat |
| 標籤 | 資源標籤。 | CommonResourceTags |
CommonApplicationSecurityGroupPropertiesFormat
| 名字 | 描述 | 價值 |
|---|
CommonResourceTags
| 名字 | 描述 | 價值 |
|---|
CommonSecurityRuleProperties格式
| 名字 | 描述 | 價值 |
|---|---|---|
| 訪問 | 允許或拒絕網路流量。 | '允許' '拒絕' (必要) |
| 描述 | 此規則的描述。 限制為140個字元。 | 字串 |
| destinationAddressPrefix 的 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 | 字串 |
| destinationAddress前綴 | 目的地位址前置詞。 CIDR 或目的地IP範圍。 | 字串[] |
| destinationApplicationSecurityGroups | 指定為目的地的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| destinationPortRange | 目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| destinationPortRanges | 目的地埠範圍。 | 字串[] |
| 方向 | 規則的方向。 方向會指定規則是否會在傳入或傳出流量上進行評估。 | “入站” '輸出' (必要) |
| 優先權 | 規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 | int (必要) |
| 通訊協定 | 此規則適用的網路協定。 | '*' “啊” 'ESP' “ICMP” 'tcp' 'Udp' (必要) |
| sourceAddressPrefix 的 | CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 | 字串 |
| sourceAddress前綴 | CIDR 或來源IP範圍。 | 字串[] |
| sourceApplicationSecurityGroups | 指定為來源的應用程式安全組。 | CommonApplicationSecurityGroup[] |
| sourcePortRange | 來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 | 字串 |
| sourcePort範圍 | 來源埠範圍。 | 字串[] |
使用範例
Terraform 範例
部署網路安全規則的基本範例。
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}
provider "azapi" {
skip_provider_registration = false
}
variable "resource_name" {
type = string
default = "acctest0001"
}
variable "location" {
type = string
default = "westeurope"
}
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}
resource "azapi_resource" "networkSecurityGroup" {
type = "Microsoft.Network/networkSecurityGroups@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = "mi-security-group1-230630034008554952"
location = var.location
body = {
properties = {
securityRules = [
]
}
}
schema_validation_enabled = false
response_export_values = ["*"]
lifecycle {
ignore_changes = [body.properties.securityRules]
}
}
resource "azapi_resource" "securityRule" {
type = "Microsoft.Network/networkSecurityGroups/securityRules@2022-09-01"
parent_id = azapi_resource.networkSecurityGroup.id
name = "allow_management_inbound"
body = {
properties = {
access = "Allow"
destinationAddressPrefix = "*"
destinationPortRange = ""
destinationPortRanges = [
"9000",
"1438",
"1440",
"9003",
"1452",
]
direction = "Inbound"
priority = 106
protocol = "Tcp"
sourceAddressPrefix = "*"
sourcePortRange = "*"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}