We recommend using Azure Native.
Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi
azure.network.getNetworkSecurityGroup
Explore with Pulumi AI
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.applyValue(getNetworkSecurityGroupResult -> getNetworkSecurityGroupResult.location()));
}
}
variables:
example:
fn::invoke:
function: azure:network:getNetworkSecurityGroup
arguments:
name: example
resourceGroupName: ${exampleAzurermResourceGroup.name}
outputs:
location: ${example.location}
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 dictionary
The following arguments are supported:
- Name
This property is required. string - Specifies the Name of the Network Security Group.
- Resource
Group Name This property is required. string - Specifies the Name of the Resource Group within which the Network Security Group exists
- Name
This property is required. string - Specifies the Name of the Network Security Group.
- Resource
Group Name This property is required. string - Specifies the Name of the Resource Group within which the Network Security Group exists
- name
This property is required. String - Specifies the Name of the Network Security Group.
- resource
Group Name This property is required. String - Specifies the Name of the Resource Group within which the Network Security Group exists
- name
This property is required. string - Specifies the Name of the Network Security Group.
- resource
Group Name This property is required. string - Specifies the Name of the Resource Group within which the Network Security Group exists
- name
This property is required. str - Specifies the Name of the Network Security Group.
- resource_
group_ name This property is required. str - Specifies the Name of the Resource Group within which the Network Security Group exists
- name
This property is required. String - Specifies the Name of the Network Security Group.
- resource
Group Name This property is required. String - 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_rule
blocks 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_rule
blocks 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_rule
blocks 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_rule
blocks 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_rule
blocks 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_rule
blocks as defined below. - Map<String>
- A mapping of tags assigned to the resource.
Supporting Types
GetNetworkSecurityGroupSecurityRule
- Access
This property is required. string - Is network traffic is allowed or denied?
- Description
This property is required. string - The description for this rule.
- Destination
Address Prefix This property is required. string - CIDR or destination IP range or * to match any IP.
- Destination
Address Prefixes This property is required. List<string> - A list of CIDRs or destination IP ranges.
- Destination
Port Range This property is required. string - The Destination Port or Range.
- Destination
Port Ranges This property is required. List<string> - Direction
This property is required. string - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- Name
This property is required. string - Specifies the Name of the Network Security Group.
- Priority
This property is required. int - The priority of the rule
- Protocol
This property is required. string - The network protocol this rule applies to.
- Source
Address Prefix This property is required. string - CIDR or source IP range or * to match any IP.
- Source
Address Prefixes This property is required. List<string> - A list of CIDRs or source IP ranges.
- Source
Port Range This property is required. string - The Source Port or Range.
- Source
Port Ranges This property is required. List<string> - 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
This property is required. string - Is network traffic is allowed or denied?
- Description
This property is required. string - The description for this rule.
- Destination
Address Prefix This property is required. string - CIDR or destination IP range or * to match any IP.
- Destination
Address Prefixes This property is required. []string - A list of CIDRs or destination IP ranges.
- Destination
Port Range This property is required. string - The Destination Port or Range.
- Destination
Port Ranges This property is required. []string - Direction
This property is required. string - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- Name
This property is required. string - Specifies the Name of the Network Security Group.
- Priority
This property is required. int - The priority of the rule
- Protocol
This property is required. string - The network protocol this rule applies to.
- Source
Address Prefix This property is required. string - CIDR or source IP range or * to match any IP.
- Source
Address Prefixes This property is required. []string - A list of CIDRs or source IP ranges.
- Source
Port Range This property is required. string - The Source Port or Range.
- Source
Port Ranges This property is required. []string - 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
This property is required. String - Is network traffic is allowed or denied?
- description
This property is required. String - The description for this rule.
- destination
Address Prefix This property is required. String - CIDR or destination IP range or * to match any IP.
- destination
Address Prefixes This property is required. List<String> - A list of CIDRs or destination IP ranges.
- destination
Port Range This property is required. String - The Destination Port or Range.
- destination
Port Ranges This property is required. List<String> - direction
This property is required. String - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name
This property is required. String - Specifies the Name of the Network Security Group.
- priority
This property is required. Integer - The priority of the rule
- protocol
This property is required. String - The network protocol this rule applies to.
- source
Address Prefix This property is required. String - CIDR or source IP range or * to match any IP.
- source
Address Prefixes This property is required. List<String> - A list of CIDRs or source IP ranges.
- source
Port Range This property is required. String - The Source Port or Range.
- source
Port Ranges This property is required. List<String> - 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
This property is required. string - Is network traffic is allowed or denied?
- description
This property is required. string - The description for this rule.
- destination
Address Prefix This property is required. string - CIDR or destination IP range or * to match any IP.
- destination
Address Prefixes This property is required. string[] - A list of CIDRs or destination IP ranges.
- destination
Port Range This property is required. string - The Destination Port or Range.
- destination
Port Ranges This property is required. string[] - direction
This property is required. string - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name
This property is required. string - Specifies the Name of the Network Security Group.
- priority
This property is required. number - The priority of the rule
- protocol
This property is required. string - The network protocol this rule applies to.
- source
Address Prefix This property is required. string - CIDR or source IP range or * to match any IP.
- source
Address Prefixes This property is required. string[] - A list of CIDRs or source IP ranges.
- source
Port Range This property is required. string - The Source Port or Range.
- source
Port Ranges This property is required. string[] - 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
This property is required. str - Is network traffic is allowed or denied?
- description
This property is required. str - The description for this rule.
- destination_
address_ prefix This property is required. str - CIDR or destination IP range or * to match any IP.
- destination_
address_ prefixes This property is required. Sequence[str] - A list of CIDRs or destination IP ranges.
- destination_
port_ range This property is required. str - The Destination Port or Range.
- destination_
port_ ranges This property is required. Sequence[str] - direction
This property is required. str - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name
This property is required. str - Specifies the Name of the Network Security Group.
- priority
This property is required. int - The priority of the rule
- protocol
This property is required. str - The network protocol this rule applies to.
- source_
address_ prefix This property is required. str - CIDR or source IP range or * to match any IP.
- source_
address_ prefixes This property is required. Sequence[str] - A list of CIDRs or source IP ranges.
- source_
port_ range This property is required. str - The Source Port or Range.
- source_
port_ ranges This property is required. Sequence[str] - 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
This property is required. String - Is network traffic is allowed or denied?
- description
This property is required. String - The description for this rule.
- destination
Address Prefix This property is required. String - CIDR or destination IP range or * to match any IP.
- destination
Address Prefixes This property is required. List<String> - A list of CIDRs or destination IP ranges.
- destination
Port Range This property is required. String - The Destination Port or Range.
- destination
Port Ranges This property is required. List<String> - direction
This property is required. String - The direction specifies if rule will be evaluated on incoming or outgoing traffic.
- name
This property is required. String - Specifies the Name of the Network Security Group.
- priority
This property is required. Number - The priority of the rule
- protocol
This property is required. String - The network protocol this rule applies to.
- source
Address Prefix This property is required. String - CIDR or source IP range or * to match any IP.
- source
Address Prefixes This property is required. List<String> - A list of CIDRs or source IP ranges.
- source
Port Range This property is required. String - The Source Port or Range.
- source
Port Ranges This property is required. List<String> - 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
azurerm
Terraform Provider.