Microsoft.Network networkSecurityGroups/securityRules 2016-06-01

言論

如需建立網路安全組的指引,請參閱 使用 Bicep建立虛擬網路資源。

Bicep 資源定義

networkSecurityGroups/securityRules 資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.Network/networkSecurityGroups/securityRules 資源,請將下列 Bicep 新增至範本。

resource symbolicname 'Microsoft.Network/networkSecurityGroups/securityRules@2016-06-01' = {
  parent: resourceSymbolicName
  etag: 'string'
  name: 'string'
  properties: {
    access: 'string'
    description: 'string'
    destinationAddressPrefix: 'string'
    destinationPortRange: 'string'
    direction: 'string'
    priority: int
    protocol: 'string'
    provisioningState: 'string'
    sourceAddressPrefix: 'string'
    sourcePortRange: 'string'
  }
}

屬性值

Microsoft.Network/networkSecurityGroups/securityRules

名字 描述 價值
ETAG 每當更新資源時變更的唯一隻讀字串 字串
名字 資源名稱 字串 (必要)
父代 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。

如需詳細資訊,請參閱 父資源外部的子資源
類型資源的符號名稱:networkSecurityGroups
性能 SecurityRulePropertiesFormat

SecurityRulePropertiesFormat

名字 描述 價值
訪問 取得或設定允許或拒絕網路流量。 可能的值為 'Allow' 和 'Deny' '允許'
'拒絕' (必要)
描述 取得或設定此規則的描述。 限制為140個字元。 字串
destinationAddressPrefix 的 取得或設定目的地位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 字串 (必要)
destinationPortRange 取得或設定目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串
方向 取得或設定規則的方向。InBound 或輸出。 方向會指定規則是否會在傳入或傳出流量上進行評估。 “入站”
'輸出' (必要)
優先權 取得或設定規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 整數 (int)
通訊協定 取得或設定套用此規則的網路通訊協定。 可以是 Tcp、Udp 或 All。。 '*'
'tcp'
'Udp' (必要)
佈建狀態 取得 PublicIP 資源更新/刪除/失敗的布建狀態 字串
sourceAddressPrefix 的 取得或設定來源位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 字串 (必要)
sourcePortRange 取得或設定來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串

使用範例

Bicep 範例

部署網路安全規則的基本範例。

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' = {
  parent: networkSecurityGroup
  name: 'allow_management_inbound'
  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": "2016-06-01",
  "name": "string",
  "etag": "string",
  "properties": {
    "access": "string",
    "description": "string",
    "destinationAddressPrefix": "string",
    "destinationPortRange": "string",
    "direction": "string",
    "priority": "int",
    "protocol": "string",
    "provisioningState": "string",
    "sourceAddressPrefix": "string",
    "sourcePortRange": "string"
  }
}

屬性值

Microsoft.Network/networkSecurityGroups/securityRules

名字 描述 價值
apiVersion API 版本 '2016-06-01'
ETAG 每當更新資源時變更的唯一隻讀字串 字串
名字 資源名稱 字串 (必要)
性能 SecurityRulePropertiesFormat
型別 資源類型 “Microsoft.Network/networkSecurityGroups/securityRules”

SecurityRulePropertiesFormat

名字 描述 價值
訪問 取得或設定允許或拒絕網路流量。 可能的值為 'Allow' 和 'Deny' '允許'
'拒絕' (必要)
描述 取得或設定此規則的描述。 限制為140個字元。 字串
destinationAddressPrefix 的 取得或設定目的地位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 字串 (必要)
destinationPortRange 取得或設定目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串
方向 取得或設定規則的方向。InBound 或輸出。 方向會指定規則是否會在傳入或傳出流量上進行評估。 “入站”
'輸出' (必要)
優先權 取得或設定規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 整數 (int)
通訊協定 取得或設定套用此規則的網路通訊協定。 可以是 Tcp、Udp 或 All。。 '*'
'tcp'
'Udp' (必要)
佈建狀態 取得 PublicIP 資源更新/刪除/失敗的布建狀態 字串
sourceAddressPrefix 的 取得或設定來源位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 字串 (必要)
sourcePortRange 取得或設定來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串

使用範例

Azure 快速入門範本

下列 Azure 快速入門範本 部署此資源類型。

範本 描述
部署深色追蹤自動調整 vSensors

部署至 Azure
此範本可讓您部署 Darktrace vSensors 的自動自動調整部署

Terraform (AzAPI 提供者) 資源定義

networkSecurityGroups/securityRules 資源類型可以使用目標作業來部署:

  • 資源群組

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.Network/networkSecurityGroups/securityRules 資源,請將下列 Terraform 新增至範本。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Network/networkSecurityGroups/securityRules@2016-06-01"
  name = "string"
  parent_id = "string"
  body = {
    etag = "string"
    properties = {
      access = "string"
      description = "string"
      destinationAddressPrefix = "string"
      destinationPortRange = "string"
      direction = "string"
      priority = int
      protocol = "string"
      provisioningState = "string"
      sourceAddressPrefix = "string"
      sourcePortRange = "string"
    }
  }
}

屬性值

Microsoft.Network/networkSecurityGroups/securityRules

名字 描述 價值
ETAG 每當更新資源時變更的唯一隻讀字串 字串
名字 資源名稱 字串 (必要)
父項識別碼 此資源為父系之資源的標識碼。 類型資源的標識碼:networkSecurityGroups
性能 SecurityRulePropertiesFormat
型別 資源類型 “Microsoft.Network/networkSecurityGroups/securityRules@2016-06-01”

SecurityRulePropertiesFormat

名字 描述 價值
訪問 取得或設定允許或拒絕網路流量。 可能的值為 'Allow' 和 'Deny' '允許'
'拒絕' (必要)
描述 取得或設定此規則的描述。 限制為140個字元。 字串
destinationAddressPrefix 的 取得或設定目的地位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 字串 (必要)
destinationPortRange 取得或設定目的地埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串
方向 取得或設定規則的方向。InBound 或輸出。 方向會指定規則是否會在傳入或傳出流量上進行評估。 “入站”
'輸出' (必要)
優先權 取得或設定規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。 整數 (int)
通訊協定 取得或設定套用此規則的網路通訊協定。 可以是 Tcp、Udp 或 All。。 '*'
'tcp'
'Udp' (必要)
佈建狀態 取得 PublicIP 資源更新/刪除/失敗的布建狀態 字串
sourceAddressPrefix 的 取得或設定來源位址前置詞。 CIDR 或來源IP範圍。 星號 『*』 也可以用來比對所有來源 IP。 您也可以使用默認標籤,例如 'VirtualNetwork'、'AzureLoadBalancer' 和 'Internet'。 如果這是輸入規則,請指定網路流量的來源。 字串 (必要)
sourcePortRange 取得或設定來源埠或範圍。 介於 0 到 65535 之間的整數或範圍。 星號 『*』 也可以用來比對所有埠。 字串

使用範例

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    = ["*"]
}