Network Watchers - Get VM Security Rules
Gets the configured and effective security group rules on the specified VM.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView?api-version=2023-05-01
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
network
|
path | True |
string |
The name of the network watcher. |
resource
|
path | True |
string |
The name of the resource group. |
subscription
|
path | True |
string |
The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
api-version
|
query | True |
string |
Client API version. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
targetResourceId | True |
string |
ID of the target VM. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
Request successful. The operation returns security group rules on the VM. |
|
202 Accepted |
Accepted and the operation will complete asynchronously. |
|
Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
Get security group view
Sample Request
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkWatchers/nw1/securityGroupView?api-version=2023-05-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-05-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"
}
]
}
}
]
}
Definitions
Name | Description |
---|---|
Application |
An application security group in a resource group. |
Effective |
Effective network security rules. |
Effective |
The network protocol this rule applies to. |
Error |
Common error details representation. |
Error |
The error object. |
Network |
Network interface and its custom security rules. |
Provisioning |
The current provisioning state. |
Security |
Network interface and all its associated security rules. |
Security |
Parameters that define the VM to check security groups for. |
Security |
The information about security rules applied to the specified VM. |
Security |
Network security rule. |
Security |
Whether network traffic is allowed or denied. |
Security |
All security rules associated with the network interface. |
Security |
The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic. |
Security |
Network protocol this rule applies to. |
Subnet |
Subnet and it's custom security rules. |
ApplicationSecurityGroup
An application security group in a resource group.
Name | Type | Description |
---|---|---|
etag |
string |
A unique read-only string that changes whenever the resource is updated. |
id |
string |
Resource ID. |
location |
string |
Resource location. |
name |
string |
Resource name. |
properties.provisioningState |
The provisioning state of the application security group resource. |
|
properties.resourceGuid |
string |
The resource GUID property of the application security group resource. It uniquely identifies a resource, even if the user changes its name or migrate the resource across subscriptions or resource groups. |
tags |
object |
Resource tags. |
type |
string |
Resource type. |
EffectiveNetworkSecurityRule
Effective network security rules.
Name | Type | Description |
---|---|---|
access |
Whether network traffic is allowed or denied. |
|
destinationAddressPrefix |
string |
The destination address prefix. |
destinationAddressPrefixes |
string[] |
The destination address prefixes. Expected values include CIDR IP ranges, Default Tags (VirtualNetwork, AzureLoadBalancer, Internet), System Tags, and the asterisk (*). |
destinationPortRange |
string |
The destination port or range. |
destinationPortRanges |
string[] |
The destination port ranges. Expected values include a single integer between 0 and 65535, a range using '-' as separator (e.g. 100-400), or an asterisk (*). |
direction |
The direction of the rule. |
|
expandedDestinationAddressPrefix |
string[] |
Expanded destination address prefix. |
expandedSourceAddressPrefix |
string[] |
The expanded source address prefix. |
name |
string |
The name of the security rule specified by the user (if created by the user). |
priority |
integer |
The priority of the rule. |
protocol |
The network protocol this rule applies to. |
|
sourceAddressPrefix |
string |
The source address prefix. |
sourceAddressPrefixes |
string[] |
The source address prefixes. Expected values include CIDR IP ranges, Default Tags (VirtualNetwork, AzureLoadBalancer, Internet), System Tags, and the asterisk (*). |
sourcePortRange |
string |
The source port or range. |
sourcePortRanges |
string[] |
The source port ranges. Expected values include a single integer between 0 and 65535, a range using '-' as separator (e.g. 100-400), or an asterisk (*). |
EffectiveSecurityRuleProtocol
The network protocol this rule applies to.
Name | Type | Description |
---|---|---|
All |
string |
|
Tcp |
string |
|
Udp |
string |
ErrorDetails
Common error details representation.
Name | Type | Description |
---|---|---|
code |
string |
Error code. |
message |
string |
Error message. |
target |
string |
Error target. |
ErrorResponse
The error object.
Name | Type | Description |
---|---|---|
error |
Error |
NetworkInterfaceAssociation
Network interface and its custom security rules.
Name | Type | Description |
---|---|---|
id |
string |
Network interface ID. |
securityRules |
Collection of custom security rules. |
ProvisioningState
The current provisioning state.
Name | Type | Description |
---|---|---|
Deleting |
string |
|
Failed |
string |
|
Succeeded |
string |
|
Updating |
string |
SecurityGroupNetworkInterface
Network interface and all its associated security rules.
Name | Type | Description |
---|---|---|
id |
string |
ID of the network interface. |
securityRuleAssociations |
All security rules associated with the network interface. |
SecurityGroupViewParameters
Parameters that define the VM to check security groups for.
Name | Type | Description |
---|---|---|
targetResourceId |
string |
ID of the target VM. |
SecurityGroupViewResult
The information about security rules applied to the specified VM.
Name | Type | Description |
---|---|---|
networkInterfaces |
List of network interfaces on the specified VM. |
SecurityRule
Network security rule.
Name | Type | Description |
---|---|---|
etag |
string |
A unique read-only string that changes whenever the resource is updated. |
id |
string |
Resource ID. |
name |
string |
The name of the resource that is unique within a resource group. This name can be used to access the resource. |
properties.access |
The network traffic is allowed or denied. |
|
properties.description |
string |
A description for this rule. Restricted to 140 chars. |
properties.destinationAddressPrefix |
string |
The destination address prefix. CIDR or destination IP range. Asterisk '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. |
properties.destinationAddressPrefixes |
string[] |
The destination address prefixes. CIDR or destination IP ranges. |
properties.destinationApplicationSecurityGroups |
The application security group specified as destination. |
|
properties.destinationPortRange |
string |
The destination port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used to match all ports. |
properties.destinationPortRanges |
string[] |
The destination port ranges. |
properties.direction |
The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic. |
|
properties.priority |
integer |
The priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule. |
properties.protocol |
Network protocol this rule applies to. |
|
properties.provisioningState |
The provisioning state of the security rule resource. |
|
properties.sourceAddressPrefix |
string |
The CIDR or source IP range. Asterisk '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies where network traffic originates from. |
properties.sourceAddressPrefixes |
string[] |
The CIDR or source IP ranges. |
properties.sourceApplicationSecurityGroups |
The application security group specified as source. |
|
properties.sourcePortRange |
string |
The source port or range. Integer or range between 0 and 65535. Asterisk '*' can also be used to match all ports. |
properties.sourcePortRanges |
string[] |
The source port ranges. |
type |
string |
The type of the resource. |
SecurityRuleAccess
Whether network traffic is allowed or denied.
Name | Type | Description |
---|---|---|
Allow |
string |
|
Deny |
string |
SecurityRuleAssociations
All security rules associated with the network interface.
Name | Type | Description |
---|---|---|
defaultSecurityRules |
Collection of default security rules of the network security group. |
|
effectiveSecurityRules |
Collection of effective security rules. |
|
networkInterfaceAssociation |
Network interface and it's custom security rules. |
|
subnetAssociation |
Subnet and it's custom security rules. |
SecurityRuleDirection
The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoing traffic.
Name | Type | Description |
---|---|---|
Inbound |
string |
|
Outbound |
string |
SecurityRuleProtocol
Network protocol this rule applies to.
Name | Type | Description |
---|---|---|
* |
string |
|
Ah |
string |
|
Esp |
string |
|
Icmp |
string |
|
Tcp |
string |
|
Udp |
string |
SubnetAssociation
Subnet and it's custom security rules.
Name | Type | Description |
---|---|---|
id |
string |
Subnet ID. |
securityRules |
Collection of custom security rules. |