共用方式為


az network nsg rule

管理網路安全組規則。

命令

名稱 Description 類型 狀態
az network nsg rule create

建立網路安全組規則。

核心 GA
az network nsg rule delete

刪除網路安全組規則。

核心 GA
az network nsg rule list

列出網路安全組中的所有規則。

核心 GA
az network nsg rule show

取得網路安全組規則的詳細數據。

核心 GA
az network nsg rule update

更新網路安全組規則。

核心 GA
az network nsg rule wait

將 CLI 置於等候狀態,直到符合條件為止。

核心 GA

az network nsg rule create

建立網路安全組規則。

az network nsg rule create --name
                           --nsg-name
                           --priority
                           --resource-group
                           [--access {Allow, Deny}]
                           [--description]
                           [--destination-address-prefixes]
                           [--destination-asgs]
                           [--destination-port-ranges]
                           [--direction {Inbound, Outbound}]
                           [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                           [--protocol {*, Ah, Esp, Icmp, Tcp, Udp}]
                           [--source-address-prefixes]
                           [--source-asgs]
                           [--source-port-ranges]

範例

建立具有最高優先順序的基本「允許」NSG 規則。

az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule --priority 100

針對優先順序最低的特定IP位址範圍,針對TCP建立「拒絕」規則。

az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule --priority 4096 --source-address-prefixes 208.130.28.0/24 --source-port-ranges 80 --destination-address-prefixes '*' --destination-port-ranges 80 8080 --access Deny --protocol Tcp --description "Deny from specific IP address ranges on 80 and 8080."

使用服務標籤建立安全性規則 (https://aka.ms/servicetags).

az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRuleWithTags --priority 400 --source-address-prefixes VirtualNetwork --destination-address-prefixes Storage --destination-port-ranges '*' --direction Outbound --access Allow --protocol Tcp --description "Allow VirtualNetwork to Storage."

使用應用程式安全組建立安全性規則 (https://aka.ms/applicationsecuritygroups).

az network nsg rule create -g MyResourceGroup --nsg-name MyNsg -n MyNsgRuleWithAsg --priority 500 --source-address-prefixes Internet --destination-port-ranges 80 8080 --destination-asgs Web --access Allow --protocol Tcp --description "Allow Internet to Web ASG on ports 80,8080."

必要參數

--name -n

網路安全組規則的名稱。

--nsg-name

網路安全組的名稱。

--priority

規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

選擇性參數

--access

允許或拒絕網路流量。

接受的值: Allow, Deny
預設值: Allow
--description

此規則的描述。 限制為140個字元。

--destination-address-prefixes

CIDR 前置詞或IP範圍的空間分隔清單。 或者,指定 'VirtualNetwork'、'AzureLoadBalancer'、'Internet' 或 '*' 的其中一個,以符合所有 IP。 此外,它也支援所有可用的服務標籤,例如 'ApiManagement'、'SqlManagement'、'AzureMonitor'等等。支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

預設值: ['*']
--destination-asgs

應用程式安全組名稱或標識子的空間分隔清單。 受後端伺服器限制,暫時此自變數僅支援一個應用程式安全組名稱或標識符。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--destination-port-ranges

以空格分隔的埠清單或埠範圍介於0-65535之間。 使用 『*』 來比對所有埠。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

預設值: ['80']
--direction

規則的方向。 方向會指定規則是否會在傳入或傳出流量上進行評估。

接受的值: Inbound, Outbound
預設值: Inbound
--no-wait

請勿等候長時間執行的作業完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--protocol

此規則適用的網路協定。

接受的值: *, Ah, Esp, Icmp, Tcp, Udp
預設值: *
--source-address-prefixes

CIDR 前置詞或IP範圍的空間分隔清單。 或者,指定 'VirtualNetwork'、'AzureLoadBalancer'、'Internet' 或 '*' 的其中一個,以符合所有 IP。 此外,它也支援所有可用的服務標籤,例如 'ApiManagement'、'SqlManagement'、'AzureMonitor'等等。支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

預設值: ['*']
--source-asgs

應用程式安全組名稱或標識子的空間分隔清單。 受後端伺服器限制,暫時此自變數僅支援一個應用程式安全組名稱或標識符。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--source-port-ranges

以空格分隔的埠清單或埠範圍介於0-65535之間。 使用 『*』 來比對所有埠。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

預設值: ['*']
全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。

az network nsg rule delete

刪除網路安全組規則。

az network nsg rule delete [--ids]
                           [--name]
                           [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                           [--nsg-name]
                           [--resource-group]
                           [--subscription]

範例

刪除網路安全組規則。

az network nsg rule delete -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule

選擇性參數

--ids

一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

網路安全組規則的名稱。

--no-wait

請勿等候長時間執行的作業完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--nsg-name

網路安全組的名稱。

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。

az network nsg rule list

列出網路安全組中的所有規則。

az network nsg rule list --nsg-name
                         --resource-group
                         [--include-default]

範例

列出網路安全組中的所有規則。

az network nsg rule list -g MyResourceGroup --nsg-name MyNsg

必要參數

--nsg-name

網路安全組的名稱。

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

選擇性參數

--include-default

在輸出中包含預設安全性規則。

預設值: False
全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。

az network nsg rule show

取得網路安全組規則的詳細數據。

az network nsg rule show [--ids]
                         [--name]
                         [--nsg-name]
                         [--resource-group]
                         [--subscription]

範例

取得網路安全組規則的詳細數據。

az network nsg rule show -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule

選擇性參數

--ids

一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

網路安全組規則的名稱。

--nsg-name

網路安全組的名稱。

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。

az network nsg rule update

更新網路安全組規則。

az network nsg rule update [--access {Allow, Deny}]
                           [--add]
                           [--description]
                           [--destination-address-prefixes]
                           [--destination-asgs]
                           [--destination-port-ranges]
                           [--direction {Inbound, Outbound}]
                           [--force-string {0, 1, f, false, n, no, t, true, y, yes}]
                           [--ids]
                           [--name]
                           [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                           [--nsg-name]
                           [--priority]
                           [--protocol {*, Ah, Esp, Icmp, Tcp, Udp}]
                           [--remove]
                           [--resource-group]
                           [--set]
                           [--source-address-prefixes]
                           [--source-asgs]
                           [--source-port-ranges]
                           [--subscription]

範例

使用新的通配符目的地位址前綴更新 NSG 規則。

az network nsg rule update -g MyResourceGroup --nsg-name MyNsg -n MyNsgRule --destination-address-prefix '*'

更新網路安全組規則。

az network nsg rule update --name MyNsgRule --nsg-name MyNsg --resource-group MyResourceGroup --source-address-prefixes 208.130.28/24

選擇性參數

--access

允許或拒絕網路流量。

接受的值: Allow, Deny
--add

藉由指定路徑和索引鍵值組,將物件加入物件清單。 範例: --add property.listProperty <key=value, string or JSON string>.

--description

此規則的描述。 限制為140個字元。

--destination-address-prefixes

CIDR 前置詞或IP範圍的空間分隔清單。 或者,指定 'VirtualNetwork'、'AzureLoadBalancer'、'Internet' 或 '*' 的其中一個,以符合所有 IP。 此外,它也支援所有可用的服務標籤,例如 'ApiManagement'、'SqlManagement'、'AzureMonitor'等等。支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--destination-asgs

應用程式安全組名稱或標識子的空間分隔清單。 受後端伺服器限制,暫時此自變數僅支援一個應用程式安全組名稱或標識符。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--destination-port-ranges

以空格分隔的埠清單或埠範圍介於0-65535之間。 使用 『*』 來比對所有埠。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--direction

規則的方向。 方向會指定規則是否會在傳入或傳出流量上進行評估。

接受的值: Inbound, Outbound
--force-string

使用 'set' 或 'add' 時,請保留字串常值,而不是嘗試轉換成 JSON。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--ids

一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

網路安全組規則的名稱。

--no-wait

請勿等候長時間執行的作業完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--nsg-name

網路安全組的名稱。

--priority

規則的優先順序。 此值可以介於 100 到 4096 之間。 集合中每個規則的優先順序號碼必須是唯一的。 優先順序數位越低,規則的優先順序就越高。

--protocol

此規則適用的網路協定。

接受的值: *, Ah, Esp, Icmp, Tcp, Udp
--remove

從清單中移除屬性或專案。 範例: --remove property.list <indexToRemove>--remove propertyToRemove

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

--set

指定要設定的屬性路徑和值,以更新物件。 範例: --set property1.property2=<value>.

--source-address-prefixes

CIDR 前置詞或IP範圍的空間分隔清單。 或者,指定 'VirtualNetwork'、'AzureLoadBalancer'、'Internet' 或 '*' 的其中一個,以符合所有 IP。 此外,它也支援所有可用的服務標籤,例如 'ApiManagement'、'SqlManagement'、'AzureMonitor'等等。支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--source-asgs

應用程式安全組名稱或標識子的空間分隔清單。 受後端伺服器限制,暫時此自變數僅支援一個應用程式安全組名稱或標識符。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--source-port-ranges

以空格分隔的埠清單或埠範圍介於0-65535之間。 使用 『*』 來比對所有埠。 支援速記語法、json-file 和 yaml-file。 請嘗試 “??” 以顯示更多。

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。

az network nsg rule wait

將 CLI 置於等候狀態,直到符合條件為止。

az network nsg rule wait [--created]
                         [--custom]
                         [--deleted]
                         [--exists]
                         [--ids]
                         [--interval]
                         [--name]
                         [--nsg-name]
                         [--resource-group]
                         [--subscription]
                         [--timeout]
                         [--updated]

選擇性參數

--created

請等候在 'Succeeded' 使用 'provisioningState' 建立。

預設值: False
--custom

等到條件符合自定義 JMESPath 查詢為止。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。

--deleted

等到刪除為止。

預設值: False
--exists

等候資源存在。

預設值: False
--ids

一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--interval

輪詢間隔以秒為單位。

預設值: 30
--name -n

網路安全組規則的名稱。

--nsg-name

網路安全組的名稱。

--resource-group -g

資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--timeout

以秒為單位的等候上限。

預設值: 3600
--updated

等到 provisioningState 更新為 'Succeeded'。

預設值: False
全域參數
--debug

提高日誌詳細程度以顯示所有調試日誌。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。

--verbose

增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。