1. Packages
  2. Azure Classic
  3. API Docs
  4. network
  5. getNetworkSecurityGroup

We recommend using Azure Native.

Azure Classic v5.81.0 published on Monday, Jun 24, 2024 by Pulumi

azure.network.getNetworkSecurityGroup

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.81.0 published on Monday, Jun 24, 2024 by Pulumi

    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/v5/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)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azure:network/getNetworkSecurityGroup:getNetworkSecurityGroup
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Specifies the Name of the Network Security Group.
    ResourceGroupName string
    Specifies the Name of the Resource Group within which the Network Security Group exists
    Name string
    Specifies the Name of the Network Security Group.
    ResourceGroupName string
    Specifies the Name of the Resource Group within which the Network Security Group exists
    name String
    Specifies the Name of the Network Security Group.
    resourceGroupName String
    Specifies the Name of the Resource Group within which the Network Security Group exists
    name string
    Specifies the Name of the Network Security Group.
    resourceGroupName string
    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_name str
    Specifies the Name of the Resource Group within which the Network Security Group exists
    name String
    Specifies the Name of the Network Security Group.
    resourceGroupName 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.
    ResourceGroupName string
    SecurityRules List<GetNetworkSecurityGroupSecurityRule>
    One or more security_rule blocks as defined below.
    Tags 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.
    ResourceGroupName string
    SecurityRules []GetNetworkSecurityGroupSecurityRule
    One or more security_rule blocks as defined below.
    Tags 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.
    resourceGroupName String
    securityRules List<GetNetworkSecurityGroupSecurityRule>
    One or more security_rule blocks as defined below.
    tags 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.
    resourceGroupName string
    securityRules GetNetworkSecurityGroupSecurityRule[]
    One or more security_rule blocks as defined below.
    tags {[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_name str
    security_rules Sequence[GetNetworkSecurityGroupSecurityRule]
    One or more security_rule blocks as defined below.
    tags 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.
    resourceGroupName String
    securityRules List<Property Map>
    One or more security_rule blocks as defined below.
    tags 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.
    DestinationAddressPrefix string
    CIDR or destination IP range or * to match any IP.
    DestinationAddressPrefixes List<string>
    A list of CIDRs or destination IP ranges.
    DestinationPortRange string
    The Destination Port or Range.
    DestinationPortRanges List<string>
    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.
    SourceAddressPrefix string
    CIDR or source IP range or * to match any IP.
    SourceAddressPrefixes List<string>
    A list of CIDRs or source IP ranges.
    SourcePortRange string
    The Source Port or Range.
    SourcePortRanges List<string>
    DestinationApplicationSecurityGroupIds List<string>
    A List of destination Application Security Group IDs
    SourceApplicationSecurityGroupIds List<string>
    A List of source Application Security Group IDs
    Access string
    Is network traffic is allowed or denied?
    Description string
    The description for this rule.
    DestinationAddressPrefix string
    CIDR or destination IP range or * to match any IP.
    DestinationAddressPrefixes []string
    A list of CIDRs or destination IP ranges.
    DestinationPortRange string
    The Destination Port or Range.
    DestinationPortRanges []string
    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.
    SourceAddressPrefix string
    CIDR or source IP range or * to match any IP.
    SourceAddressPrefixes []string
    A list of CIDRs or source IP ranges.
    SourcePortRange string
    The Source Port or Range.
    SourcePortRanges []string
    DestinationApplicationSecurityGroupIds []string
    A List of destination Application Security Group IDs
    SourceApplicationSecurityGroupIds []string
    A List of source Application Security Group IDs
    access String
    Is network traffic is allowed or denied?
    description String
    The description for this rule.
    destinationAddressPrefix String
    CIDR or destination IP range or * to match any IP.
    destinationAddressPrefixes List<String>
    A list of CIDRs or destination IP ranges.
    destinationPortRange String
    The Destination Port or Range.
    destinationPortRanges List<String>
    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.
    sourceAddressPrefix String
    CIDR or source IP range or * to match any IP.
    sourceAddressPrefixes List<String>
    A list of CIDRs or source IP ranges.
    sourcePortRange String
    The Source Port or Range.
    sourcePortRanges List<String>
    destinationApplicationSecurityGroupIds List<String>
    A List of destination Application Security Group IDs
    sourceApplicationSecurityGroupIds List<String>
    A List of source Application Security Group IDs
    access string
    Is network traffic is allowed or denied?
    description string
    The description for this rule.
    destinationAddressPrefix string
    CIDR or destination IP range or * to match any IP.
    destinationAddressPrefixes string[]
    A list of CIDRs or destination IP ranges.
    destinationPortRange string
    The Destination Port or Range.
    destinationPortRanges string[]
    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.
    sourceAddressPrefix string
    CIDR or source IP range or * to match any IP.
    sourceAddressPrefixes string[]
    A list of CIDRs or source IP ranges.
    sourcePortRange string
    The Source Port or Range.
    sourcePortRanges string[]
    destinationApplicationSecurityGroupIds string[]
    A List of destination Application Security Group IDs
    sourceApplicationSecurityGroupIds string[]
    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_prefix str
    CIDR or destination IP range or * to match any IP.
    destination_address_prefixes Sequence[str]
    A list of CIDRs or destination IP ranges.
    destination_port_range str
    The Destination Port or Range.
    destination_port_ranges Sequence[str]
    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_prefix str
    CIDR or source IP range or * to match any IP.
    source_address_prefixes Sequence[str]
    A list of CIDRs or source IP ranges.
    source_port_range str
    The Source Port or Range.
    source_port_ranges Sequence[str]
    destination_application_security_group_ids Sequence[str]
    A List of destination Application Security Group IDs
    source_application_security_group_ids Sequence[str]
    A List of source Application Security Group IDs
    access String
    Is network traffic is allowed or denied?
    description String
    The description for this rule.
    destinationAddressPrefix String
    CIDR or destination IP range or * to match any IP.
    destinationAddressPrefixes List<String>
    A list of CIDRs or destination IP ranges.
    destinationPortRange String
    The Destination Port or Range.
    destinationPortRanges List<String>
    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.
    sourceAddressPrefix String
    CIDR or source IP range or * to match any IP.
    sourceAddressPrefixes List<String>
    A list of CIDRs or source IP ranges.
    sourcePortRange String
    The Source Port or Range.
    sourcePortRanges List<String>
    destinationApplicationSecurityGroupIds List<String>
    A List of destination Application Security Group IDs
    sourceApplicationSecurityGroupIds List<String>
    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.
    azure logo

    We recommend using Azure Native.

    Azure Classic v5.81.0 published on Monday, Jun 24, 2024 by Pulumi