We recommend using Azure Native.
Azure v6.28.0 published on Friday, Oct 3, 2025 by Pulumi
azure.network.getNetworkSecurityGroup
Start a Neo task
Explain and create an azure.network.getNetworkSecurityGroup resource
Use this data source to access information about an existing Network Security Group.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.network.getNetworkSecurityGroup({
name: "example",
resourceGroupName: exampleAzurermResourceGroup.name,
});
export const location = example.then(example => example.location);
import pulumi
import pulumi_azure as azure
example = azure.network.get_network_security_group(name="example",
resource_group_name=example_azurerm_resource_group["name"])
pulumi.export("location", example.location)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := network.LookupNetworkSecurityGroup(ctx, &network.LookupNetworkSecurityGroupArgs{
Name: "example",
ResourceGroupName: exampleAzurermResourceGroup.Name,
}, nil)
if err != nil {
return err
}
ctx.Export("location", example.Location)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Network.GetNetworkSecurityGroup.Invoke(new()
{
Name = "example",
ResourceGroupName = exampleAzurermResourceGroup.Name,
});
return new Dictionary<string, object?>
{
["location"] = example.Apply(getNetworkSecurityGroupResult => getNetworkSecurityGroupResult.Location),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.network.NetworkFunctions;
import com.pulumi.azure.network.inputs.GetNetworkSecurityGroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = NetworkFunctions.getNetworkSecurityGroup(GetNetworkSecurityGroupArgs.builder()
.name("example")
.resourceGroupName(exampleAzurermResourceGroup.name())
.build());
ctx.export("location", example.location());
}
}
variables:
example:
fn::invoke:
function: azure:network:getNetworkSecurityGroup
arguments:
name: example
resourceGroupName: ${exampleAzurermResourceGroup.name}
outputs:
location: ${example.location}
API Providers
This data source uses the following Azure API Providers:
Microsoft.Network- 2024-05-01
Using getNetworkSecurityGroup
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getNetworkSecurityGroup(args: GetNetworkSecurityGroupArgs, opts?: InvokeOptions): Promise<GetNetworkSecurityGroupResult>
function getNetworkSecurityGroupOutput(args: GetNetworkSecurityGroupOutputArgs, opts?: InvokeOptions): Output<GetNetworkSecurityGroupResult>def get_network_security_group(name: Optional[str] = None,
resource_group_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetNetworkSecurityGroupResult
def get_network_security_group_output(name: Optional[pulumi.Input[str]] = None,
resource_group_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetNetworkSecurityGroupResult]func LookupNetworkSecurityGroup(ctx *Context, args *LookupNetworkSecurityGroupArgs, opts ...InvokeOption) (*LookupNetworkSecurityGroupResult, error)
func LookupNetworkSecurityGroupOutput(ctx *Context, args *LookupNetworkSecurityGroupOutputArgs, opts ...InvokeOption) LookupNetworkSecurityGroupResultOutput> Note: This function is named LookupNetworkSecurityGroup in the Go SDK.
public static class GetNetworkSecurityGroup
{
public static Task<GetNetworkSecurityGroupResult> InvokeAsync(GetNetworkSecurityGroupArgs args, InvokeOptions? opts = null)
public static Output<GetNetworkSecurityGroupResult> Invoke(GetNetworkSecurityGroupInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetNetworkSecurityGroupResult> getNetworkSecurityGroup(GetNetworkSecurityGroupArgs args, InvokeOptions options)
public static Output<GetNetworkSecurityGroupResult> getNetworkSecurityGroup(GetNetworkSecurityGroupArgs args, InvokeOptions options)
fn::invoke:
function: azure:network/getNetworkSecurityGroup:getNetworkSecurityGroup
arguments:
# arguments dictionaryThe following arguments are supported:
- Name string
- Specifies the Name of the Network Security Group.
- Resource
Group stringName - Specifies the Name of the Resource Group within which the Network Security Group exists
- Name string
- Specifies the Name of the Network Security Group.
- Resource
Group stringName - Specifies the Name of the Resource Group within which the Network Security Group exists
- name String
- Specifies the Name of the Network Security Group.
- resource
Group StringName - Specifies the Name of the Resource Group within which the Network Security Group exists
- name string
- Specifies the Name of the Network Security Group.
- resource
Group stringName - Specifies the Name of the Resource Group within which the Network Security Group exists
- name str
- Specifies the Name of the Network Security Group.
- resource_
group_ strname - Specifies the Name of the Resource Group within which the Network Security Group exists
- name String
- Specifies the Name of the Network Security Group.
- resource
Group StringName - Specifies the Name of the Resource Group within which the Network Security Group exists
getNetworkSecurityGroup Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Location string
- The supported Azure location where the resource exists.
- Name string
- The name of the security rule.
- Resource
Group stringName - Security
Rules List<GetNetwork Security Group Security Rule> - One or more
security_ruleblocks as defined below. - Dictionary<string, string>
- A mapping of tags assigned to the resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Location string
- The supported Azure location where the resource exists.
- Name string
- The name of the security rule.
- Resource
Group stringName - Security
Rules []GetNetwork Security Group Security Rule - One or more
security_ruleblocks as defined below. - map[string]string
- A mapping of tags assigned to the resource.
- id String
- The provider-assigned unique ID for this managed resource.
- location String
- The supported Azure location where the resource exists.
- name String
- The name of the security rule.
- resource
Group StringName - security
Rules List<GetNetwork Security Group Security Rule> - One or more
security_ruleblocks as defined below. - Map<String,String>
- A mapping of tags assigned to the resource.
- id string
- The provider-assigned unique ID for this managed resource.
- location string
- The supported Azure location where the resource exists.
- name string
- The name of the security rule.
- resource
Group stringName - security
Rules GetNetwork Security Group Security Rule[] - One or more
security_ruleblocks as defined below. - {[key: string]: string}
- A mapping of tags assigned to the resource.
- id str
- The provider-assigned unique ID for this managed resource.
- location str
- The supported Azure location where the resource exists.
- name str
- The name of the security rule.
- resource_
group_ strname - security_
rules Sequence[GetNetwork Security Group Security Rule] - One or more
security_ruleblocks as defined below. - Mapping[str, str]
- A mapping of tags assigned to the resource.
- id String
- The provider-assigned unique ID for this managed resource.
- location String
- The supported Azure location where the resource exists.
- name String
- The name of the security rule.
- resource
Group StringName - security
Rules List<Property Map> - One or more
security_ruleblocks as defined below. - Map<String>
- A mapping of tags assigned to the resource.
Supporting Types
GetNetworkSecurityGroupSecurityRule
- Access string
- Is network traffic is allowed or denied?
- Description string
- The description for this rule.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP.
- Destination
Address List<string>Prefixes - A list of CIDRs or destination IP ranges.
- Destination
Port stringRange - The Destination Port or Range.
- Destination
Port List<string>Ranges - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- Name string
- Specifies the Name of the Network Security Group.
- Priority int
- The priority of the rule
- Protocol string
- The network protocol this rule applies to.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP.
- Source
Address List<string>Prefixes - A list of CIDRs or source IP ranges.
- Source
Port stringRange - The Source Port or Range.
- Source
Port List<string>Ranges - Destination
Application List<string>Security Group Ids - A List of destination Application Security Group IDs
- Source
Application List<string>Security Group Ids - A List of source Application Security Group IDs
- Access string
- Is network traffic is allowed or denied?
- Description string
- The description for this rule.
- Destination
Address stringPrefix - CIDR or destination IP range or * to match any IP.
- Destination
Address []stringPrefixes - A list of CIDRs or destination IP ranges.
- Destination
Port stringRange - The Destination Port or Range.
- Destination
Port []stringRanges - Direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- Name string
- Specifies the Name of the Network Security Group.
- Priority int
- The priority of the rule
- Protocol string
- The network protocol this rule applies to.
- Source
Address stringPrefix - CIDR or source IP range or * to match any IP.
- Source
Address []stringPrefixes - A list of CIDRs or source IP ranges.
- Source
Port stringRange - The Source Port or Range.
- Source
Port []stringRanges - Destination
Application []stringSecurity Group Ids - A List of destination Application Security Group IDs
- Source
Application []stringSecurity Group Ids - A List of source Application Security Group IDs
- access String
- Is network traffic is allowed or denied?
- description String
- The description for this rule.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP.
- destination
Address List<String>Prefixes - A list of CIDRs or destination IP ranges.
- destination
Port StringRange - The Destination Port or Range.
- destination
Port List<String>Ranges - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name String
- Specifies the Name of the Network Security Group.
- priority Integer
- The priority of the rule
- protocol String
- The network protocol this rule applies to.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP.
- source
Address List<String>Prefixes - A list of CIDRs or source IP ranges.
- source
Port StringRange - The Source Port or Range.
- source
Port List<String>Ranges - destination
Application List<String>Security Group Ids - A List of destination Application Security Group IDs
- source
Application List<String>Security Group Ids - A List of source Application Security Group IDs
- access string
- Is network traffic is allowed or denied?
- description string
- The description for this rule.
- destination
Address stringPrefix - CIDR or destination IP range or * to match any IP.
- destination
Address string[]Prefixes - A list of CIDRs or destination IP ranges.
- destination
Port stringRange - The Destination Port or Range.
- destination
Port string[]Ranges - direction string
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name string
- Specifies the Name of the Network Security Group.
- priority number
- The priority of the rule
- protocol string
- The network protocol this rule applies to.
- source
Address stringPrefix - CIDR or source IP range or * to match any IP.
- source
Address string[]Prefixes - A list of CIDRs or source IP ranges.
- source
Port stringRange - The Source Port or Range.
- source
Port string[]Ranges - destination
Application string[]Security Group Ids - A List of destination Application Security Group IDs
- source
Application string[]Security Group Ids - A List of source Application Security Group IDs
- access str
- Is network traffic is allowed or denied?
- description str
- The description for this rule.
- destination_
address_ strprefix - CIDR or destination IP range or * to match any IP.
- destination_
address_ Sequence[str]prefixes - A list of CIDRs or destination IP ranges.
- destination_
port_ strrange - The Destination Port or Range.
- destination_
port_ Sequence[str]ranges - direction str
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name str
- Specifies the Name of the Network Security Group.
- priority int
- The priority of the rule
- protocol str
- The network protocol this rule applies to.
- source_
address_ strprefix - CIDR or source IP range or * to match any IP.
- source_
address_ Sequence[str]prefixes - A list of CIDRs or source IP ranges.
- source_
port_ strrange - The Source Port or Range.
- source_
port_ Sequence[str]ranges - destination_
application_ Sequence[str]security_ group_ ids - A List of destination Application Security Group IDs
- source_
application_ Sequence[str]security_ group_ ids - A List of source Application Security Group IDs
- access String
- Is network traffic is allowed or denied?
- description String
- The description for this rule.
- destination
Address StringPrefix - CIDR or destination IP range or * to match any IP.
- destination
Address List<String>Prefixes - A list of CIDRs or destination IP ranges.
- destination
Port StringRange - The Destination Port or Range.
- destination
Port List<String>Ranges - direction String
- The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name String
- Specifies the Name of the Network Security Group.
- priority Number
- The priority of the rule
- protocol String
- The network protocol this rule applies to.
- source
Address StringPrefix - CIDR or source IP range or * to match any IP.
- source
Address List<String>Prefixes - A list of CIDRs or source IP ranges.
- source
Port StringRange - The Source Port or Range.
- source
Port List<String>Ranges - destination
Application List<String>Security Group Ids - A List of destination Application Security Group IDs
- source
Application List<String>Security Group Ids - A List of source Application Security Group IDs
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
