你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Network Watchers - Get VM Security Rules
获取指定 VM 上已配置的有效安全组规则。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView?api-version=2023-09-01
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
network
|
path | True |
string |
网络观察程序的名称。 |
resource
|
path | True |
string |
资源组的名称。 |
subscription
|
path | True |
string |
可以唯一标识 Microsoft Azure 订阅的订阅凭据。 此订阅 ID 是每个服务调用的 URI 的一部分。 |
api-version
|
query | True |
string |
客户端 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
targetResourceId | True |
string |
目标 VM 的 ID。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
请求成功。 该操作返回 VM 上的安全组规则。 |
|
202 Accepted |
接受,操作将以异步方式完成。 |
|
Other Status Codes |
描述操作失败原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 流。
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 | 说明 |
---|---|
user_impersonation | 模拟用户帐户 |
示例
Get security group view
Sample Request
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkWatchers/nw1/securityGroupView?api-version=2023-09-01
{
"targetResourceId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1"
}
Sample Response
{
"networkInterfaces": [
{
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/nic1",
"securityRuleAssociations": {
"subnetAssociation": {
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1",
"securityRules": [
{
"name": "fe_rule",
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/AppNSG/securityRules/fe_rule",
"etag": "W/\"00000000-0000-0000-0000-000000000000\"",
"properties": {
"provisioningState": "Succeeded",
"description": "Allow Frontend",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "10.1.0.0/24",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
}
]
},
"defaultSecurityRules": [
{
"name": "AllowVnetInBound",
"id": "/subscriptions//resourceGroups//providers/Microsoft.Network/networkSecurityGroups//defaultSecurityRules/",
"properties": {
"provisioningState": "Succeeded",
"description": "Allow inbound traffic from all VMs in VNET",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "VirtualNetwork",
"destinationAddressPrefix": "VirtualNetwork",
"access": "Allow",
"priority": 65000,
"direction": "Inbound"
}
}
],
"effectiveSecurityRules": [
{
"name": "DefaultOutboundDenyAll",
"protocol": "All",
"sourcePortRange": "0-65535",
"destinationPortRange": "0-65535",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Deny",
"priority": 65500,
"direction": "Outbound"
}
]
}
}
]
}
Location: https:/management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkWatchers/nw1/queryStatus?api-version=2023-09-01
{
"networkInterfaces": [
{
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkInterfaces/nic1",
"securityRuleAssociations": {
"subnetAssociation": {
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1",
"securityRules": [
{
"name": "fe_rule",
"id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/AppNSG/securityRules/fe_rule",
"etag": "W/\"00000000-0000-0000-0000-000000000000\"",
"properties": {
"provisioningState": "Succeeded",
"description": "Allow Frontend",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "10.1.0.0/24",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
}
]
},
"defaultSecurityRules": [
{
"name": "AllowVnetInBound",
"id": "/subscriptions//resourceGroups//providers/Microsoft.Network/networkSecurityGroups//defaultSecurityRules/",
"properties": {
"provisioningState": "Succeeded",
"description": "Allow inbound traffic from all VMs in VNET",
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "VirtualNetwork",
"destinationAddressPrefix": "VirtualNetwork",
"access": "Allow",
"priority": 65000,
"direction": "Inbound"
}
}
],
"effectiveSecurityRules": [
{
"name": "DefaultOutboundDenyAll",
"protocol": "All",
"sourcePortRange": "0-65535",
"destinationPortRange": "0-65535",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Deny",
"priority": 65500,
"direction": "Outbound"
}
]
}
}
]
}
定义
名称 | 说明 |
---|---|
Application |
资源组中的应用程序安全组。 |
Effective |
有效的网络安全规则。 |
Effective |
此规则适用的网络协议。 |
Error |
常见错误详细信息表示形式。 |
Error |
错误对象。 |
Network |
网络接口及其自定义安全规则。 |
Provisioning |
当前预配状态。 |
Security |
网络接口及其所有相关的安全规则。 |
Security |
定义要为其检查安全组的 VM 的参数。 |
Security |
有关应用于指定 VM 的安全规则的信息。 |
Security |
网络安全规则。 |
Security |
是允许还是拒绝网络流量。 |
Security |
与网络接口关联的所有安全规则。 |
Security |
规则的方向。 direction 指定是要针对传入流量还是传出流量评估该规则。 |
Security |
此规则应用到的网络协议。 |
Subnet |
子网及其自定义安全规则。 |
ApplicationSecurityGroup
资源组中的应用程序安全组。
名称 | 类型 | 说明 |
---|---|---|
etag |
string |
一个唯一的只读字符串,每当资源更新时都会更改。 |
id |
string |
资源 ID。 |
location |
string |
资源位置。 |
name |
string |
资源名称。 |
properties.provisioningState |
应用程序安全组资源的预配状态。 |
|
properties.resourceGuid |
string |
应用程序安全组资源的资源 GUID 属性。 它唯一标识资源,即使用户更改其名称或跨订阅或资源组迁移资源也是如此。 |
tags |
object |
资源标记。 |
type |
string |
资源类型。 |
EffectiveNetworkSecurityRule
有效的网络安全规则。
名称 | 类型 | 说明 |
---|---|---|
access |
是允许还是拒绝网络流量。 |
|
destinationAddressPrefix |
string |
目标地址前缀。 |
destinationAddressPrefixes |
string[] |
目标地址前缀。 预期值包括 CIDR IP 范围、默认标记 (VirtualNetwork、AzureLoadBalancer、Internet) 、系统标记以及星号 (*) 。 |
destinationPortRange |
string |
目标端口或范围。 |
destinationPortRanges |
string[] |
目标端口范围。 预期值包括介于 0 和 65535 之间的单个整数、使用“-”作为分隔符 (的范围(例如 100-400) )或星号 (*) 。 |
direction |
规则的方向。 |
|
expandedDestinationAddressPrefix |
string[] |
展开的目标地址前缀。 |
expandedSourceAddressPrefix |
string[] |
展开的源地址前缀。 |
name |
string |
如果用户) 创建,则 (用户指定的安全规则的名称。 |
priority |
integer |
规则的优先级。 |
protocol |
此规则适用的网络协议。 |
|
sourceAddressPrefix |
string |
源地址前缀。 |
sourceAddressPrefixes |
string[] |
源地址前缀。 预期值包括 CIDR IP 范围、默认标记 (VirtualNetwork、AzureLoadBalancer、Internet) 、系统标记以及星号 (*) 。 |
sourcePortRange |
string |
源端口或范围。 |
sourcePortRanges |
string[] |
源端口范围。 预期值包括介于 0 和 65535 之间的单个整数、使用“-”作为分隔符 (的范围(例如 100-400) )或星号 (*) 。 |
EffectiveSecurityRuleProtocol
此规则适用的网络协议。
名称 | 类型 | 说明 |
---|---|---|
All |
string |
|
Tcp |
string |
|
Udp |
string |
ErrorDetails
常见错误详细信息表示形式。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
错误代码。 |
message |
string |
错误消息。 |
target |
string |
错误目标。 |
ErrorResponse
错误对象。
名称 | 类型 | 说明 |
---|---|---|
error |
错误 |
NetworkInterfaceAssociation
网络接口及其自定义安全规则。
名称 | 类型 | 说明 |
---|---|---|
id |
string |
网络接口 ID。 |
securityRules |
自定义安全规则的集合。 |
ProvisioningState
当前预配状态。
名称 | 类型 | 说明 |
---|---|---|
Deleting |
string |
|
Failed |
string |
|
Succeeded |
string |
|
Updating |
string |
SecurityGroupNetworkInterface
网络接口及其所有相关的安全规则。
名称 | 类型 | 说明 |
---|---|---|
id |
string |
网络接口的 ID。 |
securityRuleAssociations |
与网络接口关联的所有安全规则。 |
SecurityGroupViewParameters
定义要为其检查安全组的 VM 的参数。
名称 | 类型 | 说明 |
---|---|---|
targetResourceId |
string |
目标 VM 的 ID。 |
SecurityGroupViewResult
有关应用于指定 VM 的安全规则的信息。
名称 | 类型 | 说明 |
---|---|---|
networkInterfaces |
指定 VM 上的网络接口列表。 |
SecurityRule
网络安全规则。
名称 | 类型 | 说明 |
---|---|---|
etag |
string |
一个唯一的只读字符串,每当资源更新时都会更改。 |
id |
string |
资源 ID。 |
name |
string |
资源组中唯一的资源的名称。 此名称可用于访问资源。 |
properties.access |
允许或拒绝网络流量。 |
|
properties.description |
string |
此规则的说明。 限制为 140 个字符。 |
properties.destinationAddressPrefix |
string |
目标地址前缀。 CIDR 或目标 IP 范围。 也可以使用星号“*”来匹配所有源 IP。 也可以使用默认标记,例如“VirtualNetwork”、“AzureLoadBalancer”和“Internet”。 |
properties.destinationAddressPrefixes |
string[] |
目标地址前缀。 CIDR 或目标 IP 范围。 |
properties.destinationApplicationSecurityGroups |
指定为目标的应用程序安全组。 |
|
properties.destinationPortRange |
string |
目标端口或范围。 介于 0 和 65535 之间的整数或范围。 星号“*”也可用于匹配所有端口。 |
properties.destinationPortRanges |
string[] |
目标端口范围。 |
properties.direction |
规则的方向。 direction 指定是要针对传入流量还是传出流量评估该规则。 |
|
properties.priority |
integer |
规则的优先级。 该值可以介于 100 和 4096 之间。 对于集合中的每个规则,优先级编号必须是唯一的。 优先级编号越低,规则优先级越高。 |
properties.protocol |
此规则应用到的网络协议。 |
|
properties.provisioningState |
安全规则资源的预配状态。 |
|
properties.sourceAddressPrefix |
string |
CIDR 或源 IP 范围。 也可以使用星号“*”来匹配所有源 IP。 也可以使用默认标记,例如“VirtualNetwork”、“AzureLoadBalancer”和“Internet”。 如果这是入口规则,则指定网络流量的来源。 |
properties.sourceAddressPrefixes |
string[] |
CIDR 或源 IP 范围。 |
properties.sourceApplicationSecurityGroups |
指定为源的应用程序安全组。 |
|
properties.sourcePortRange |
string |
源端口或范围。 介于 0 和 65535 之间的整数或范围。 星号“*”也可用于匹配所有端口。 |
properties.sourcePortRanges |
string[] |
源端口范围。 |
type |
string |
资源类型。 |
SecurityRuleAccess
是允许还是拒绝网络流量。
名称 | 类型 | 说明 |
---|---|---|
Allow |
string |
|
Deny |
string |
SecurityRuleAssociations
与网络接口关联的所有安全规则。
名称 | 类型 | 说明 |
---|---|---|
defaultSecurityRules |
网络安全组的默认安全规则的集合。 |
|
effectiveSecurityRules |
有效安全规则的集合。 |
|
networkInterfaceAssociation |
网络接口及其自定义安全规则。 |
|
subnetAssociation |
子网及其自定义安全规则。 |
SecurityRuleDirection
规则的方向。 direction 指定是要针对传入流量还是传出流量评估该规则。
名称 | 类型 | 说明 |
---|---|---|
Inbound |
string |
|
Outbound |
string |
SecurityRuleProtocol
此规则应用到的网络协议。
名称 | 类型 | 说明 |
---|---|---|
* |
string |
|
Ah |
string |
|
Esp |
string |
|
Icmp |
string |
|
Tcp |
string |
|
Udp |
string |
SubnetAssociation
子网及其自定义安全规则。
名称 | 类型 | 说明 |
---|---|---|
id |
string |
子网 ID。 |
securityRules |
自定义安全规则的集合。 |