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

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Manages the association between a Network Interface and a Network Security Group.

    Example Usage

    using Pulumi;
    using Azure = Pulumi.Azure;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
            {
                Location = "West Europe",
            });
            var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new Azure.Network.VirtualNetworkArgs
            {
                AddressSpaces = 
                {
                    "10.0.0.0/16",
                },
                Location = exampleResourceGroup.Location,
                ResourceGroupName = exampleResourceGroup.Name,
            });
            var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new Azure.Network.SubnetArgs
            {
                ResourceGroupName = exampleResourceGroup.Name,
                VirtualNetworkName = exampleVirtualNetwork.Name,
                AddressPrefixes = 
                {
                    "10.0.2.0/24",
                },
            });
            var exampleNetworkSecurityGroup = new Azure.Network.NetworkSecurityGroup("exampleNetworkSecurityGroup", new Azure.Network.NetworkSecurityGroupArgs
            {
                Location = exampleResourceGroup.Location,
                ResourceGroupName = exampleResourceGroup.Name,
            });
            var exampleNetworkInterface = new Azure.Network.NetworkInterface("exampleNetworkInterface", new Azure.Network.NetworkInterfaceArgs
            {
                Location = exampleResourceGroup.Location,
                ResourceGroupName = exampleResourceGroup.Name,
                IpConfigurations = 
                {
                    new Azure.Network.Inputs.NetworkInterfaceIpConfigurationArgs
                    {
                        Name = "testconfiguration1",
                        SubnetId = exampleSubnet.Id,
                        PrivateIpAddressAllocation = "Dynamic",
                    },
                },
            });
            var exampleNetworkInterfaceSecurityGroupAssociation = new Azure.Network.NetworkInterfaceSecurityGroupAssociation("exampleNetworkInterfaceSecurityGroupAssociation", new Azure.Network.NetworkInterfaceSecurityGroupAssociationArgs
            {
                NetworkInterfaceId = exampleNetworkInterface.Id,
                NetworkSecurityGroupId = exampleNetworkSecurityGroup.Id,
            });
        }
    
    }
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/network"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
    			Location: pulumi.String("West Europe"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
    			AddressSpaces: pulumi.StringArray{
    				pulumi.String("10.0.0.0/16"),
    			},
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    		})
    		if err != nil {
    			return err
    		}
    		exampleSubnet, err := network.NewSubnet(ctx, "exampleSubnet", &network.SubnetArgs{
    			ResourceGroupName:  exampleResourceGroup.Name,
    			VirtualNetworkName: exampleVirtualNetwork.Name,
    			AddressPrefixes: pulumi.StringArray{
    				pulumi.String("10.0.2.0/24"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleNetworkSecurityGroup, err := network.NewNetworkSecurityGroup(ctx, "exampleNetworkSecurityGroup", &network.NetworkSecurityGroupArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    		})
    		if err != nil {
    			return err
    		}
    		exampleNetworkInterface, err := network.NewNetworkInterface(ctx, "exampleNetworkInterface", &network.NetworkInterfaceArgs{
    			Location:          exampleResourceGroup.Location,
    			ResourceGroupName: exampleResourceGroup.Name,
    			IpConfigurations: network.NetworkInterfaceIpConfigurationArray{
    				&network.NetworkInterfaceIpConfigurationArgs{
    					Name:                       pulumi.String("testconfiguration1"),
    					SubnetId:                   exampleSubnet.ID(),
    					PrivateIpAddressAllocation: pulumi.String("Dynamic"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = network.NewNetworkInterfaceSecurityGroupAssociation(ctx, "exampleNetworkInterfaceSecurityGroupAssociation", &network.NetworkInterfaceSecurityGroupAssociationArgs{
    			NetworkInterfaceId:     exampleNetworkInterface.ID(),
    			NetworkSecurityGroupId: exampleNetworkSecurityGroup.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    

    Example coming soon!

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
    const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
        addressSpaces: ["10.0.0.0/16"],
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
    });
    const exampleSubnet = new azure.network.Subnet("exampleSubnet", {
        resourceGroupName: exampleResourceGroup.name,
        virtualNetworkName: exampleVirtualNetwork.name,
        addressPrefixes: ["10.0.2.0/24"],
    });
    const exampleNetworkSecurityGroup = new azure.network.NetworkSecurityGroup("exampleNetworkSecurityGroup", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
    });
    const exampleNetworkInterface = new azure.network.NetworkInterface("exampleNetworkInterface", {
        location: exampleResourceGroup.location,
        resourceGroupName: exampleResourceGroup.name,
        ipConfigurations: [{
            name: "testconfiguration1",
            subnetId: exampleSubnet.id,
            privateIpAddressAllocation: "Dynamic",
        }],
    });
    const exampleNetworkInterfaceSecurityGroupAssociation = new azure.network.NetworkInterfaceSecurityGroupAssociation("exampleNetworkInterfaceSecurityGroupAssociation", {
        networkInterfaceId: exampleNetworkInterface.id,
        networkSecurityGroupId: exampleNetworkSecurityGroup.id,
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
    example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
        address_spaces=["10.0.0.0/16"],
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name)
    example_subnet = azure.network.Subnet("exampleSubnet",
        resource_group_name=example_resource_group.name,
        virtual_network_name=example_virtual_network.name,
        address_prefixes=["10.0.2.0/24"])
    example_network_security_group = azure.network.NetworkSecurityGroup("exampleNetworkSecurityGroup",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name)
    example_network_interface = azure.network.NetworkInterface("exampleNetworkInterface",
        location=example_resource_group.location,
        resource_group_name=example_resource_group.name,
        ip_configurations=[azure.network.NetworkInterfaceIpConfigurationArgs(
            name="testconfiguration1",
            subnet_id=example_subnet.id,
            private_ip_address_allocation="Dynamic",
        )])
    example_network_interface_security_group_association = azure.network.NetworkInterfaceSecurityGroupAssociation("exampleNetworkInterfaceSecurityGroupAssociation",
        network_interface_id=example_network_interface.id,
        network_security_group_id=example_network_security_group.id)
    

    Example coming soon!

    Create NetworkInterfaceSecurityGroupAssociation Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new NetworkInterfaceSecurityGroupAssociation(name: string, args: NetworkInterfaceSecurityGroupAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def NetworkInterfaceSecurityGroupAssociation(resource_name: str,
                                                 args: NetworkInterfaceSecurityGroupAssociationArgs,
                                                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def NetworkInterfaceSecurityGroupAssociation(resource_name: str,
                                                 opts: Optional[ResourceOptions] = None,
                                                 network_interface_id: Optional[str] = None,
                                                 network_security_group_id: Optional[str] = None)
    func NewNetworkInterfaceSecurityGroupAssociation(ctx *Context, name string, args NetworkInterfaceSecurityGroupAssociationArgs, opts ...ResourceOption) (*NetworkInterfaceSecurityGroupAssociation, error)
    public NetworkInterfaceSecurityGroupAssociation(string name, NetworkInterfaceSecurityGroupAssociationArgs args, CustomResourceOptions? opts = null)
    public NetworkInterfaceSecurityGroupAssociation(String name, NetworkInterfaceSecurityGroupAssociationArgs args)
    public NetworkInterfaceSecurityGroupAssociation(String name, NetworkInterfaceSecurityGroupAssociationArgs args, CustomResourceOptions options)
    
    type: azure:network:NetworkInterfaceSecurityGroupAssociation
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args NetworkInterfaceSecurityGroupAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args NetworkInterfaceSecurityGroupAssociationArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args NetworkInterfaceSecurityGroupAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args NetworkInterfaceSecurityGroupAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args NetworkInterfaceSecurityGroupAssociationArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var networkInterfaceSecurityGroupAssociationResource = new Azure.Network.NetworkInterfaceSecurityGroupAssociation("networkInterfaceSecurityGroupAssociationResource", new()
    {
        NetworkInterfaceId = "string",
        NetworkSecurityGroupId = "string",
    });
    
    example, err := network.NewNetworkInterfaceSecurityGroupAssociation(ctx, "networkInterfaceSecurityGroupAssociationResource", &network.NetworkInterfaceSecurityGroupAssociationArgs{
    	NetworkInterfaceId:     pulumi.String("string"),
    	NetworkSecurityGroupId: pulumi.String("string"),
    })
    
    var networkInterfaceSecurityGroupAssociationResource = new NetworkInterfaceSecurityGroupAssociation("networkInterfaceSecurityGroupAssociationResource", NetworkInterfaceSecurityGroupAssociationArgs.builder()
        .networkInterfaceId("string")
        .networkSecurityGroupId("string")
        .build());
    
    network_interface_security_group_association_resource = azure.network.NetworkInterfaceSecurityGroupAssociation("networkInterfaceSecurityGroupAssociationResource",
        network_interface_id="string",
        network_security_group_id="string")
    
    const networkInterfaceSecurityGroupAssociationResource = new azure.network.NetworkInterfaceSecurityGroupAssociation("networkInterfaceSecurityGroupAssociationResource", {
        networkInterfaceId: "string",
        networkSecurityGroupId: "string",
    });
    
    type: azure:network:NetworkInterfaceSecurityGroupAssociation
    properties:
        networkInterfaceId: string
        networkSecurityGroupId: string
    

    NetworkInterfaceSecurityGroupAssociation Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The NetworkInterfaceSecurityGroupAssociation resource accepts the following input properties:

    NetworkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    NetworkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    NetworkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    NetworkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId String
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId String
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    network_interface_id str
    The ID of the Network Interface. Changing this forces a new resource to be created.
    network_security_group_id str
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId String
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId String
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the NetworkInterfaceSecurityGroupAssociation resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing NetworkInterfaceSecurityGroupAssociation Resource

    Get an existing NetworkInterfaceSecurityGroupAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: NetworkInterfaceSecurityGroupAssociationState, opts?: CustomResourceOptions): NetworkInterfaceSecurityGroupAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            network_interface_id: Optional[str] = None,
            network_security_group_id: Optional[str] = None) -> NetworkInterfaceSecurityGroupAssociation
    func GetNetworkInterfaceSecurityGroupAssociation(ctx *Context, name string, id IDInput, state *NetworkInterfaceSecurityGroupAssociationState, opts ...ResourceOption) (*NetworkInterfaceSecurityGroupAssociation, error)
    public static NetworkInterfaceSecurityGroupAssociation Get(string name, Input<string> id, NetworkInterfaceSecurityGroupAssociationState? state, CustomResourceOptions? opts = null)
    public static NetworkInterfaceSecurityGroupAssociation get(String name, Output<String> id, NetworkInterfaceSecurityGroupAssociationState state, CustomResourceOptions options)
    resources:  _:    type: azure:network:NetworkInterfaceSecurityGroupAssociation    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    NetworkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    NetworkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    NetworkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    NetworkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId String
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId String
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId string
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId string
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    network_interface_id str
    The ID of the Network Interface. Changing this forces a new resource to be created.
    network_security_group_id str
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.
    networkInterfaceId String
    The ID of the Network Interface. Changing this forces a new resource to be created.
    networkSecurityGroupId String
    The ID of the Network Security Group which should be attached to the Network Interface. Changing this forces a new resource to be created.

    Import

    Associations between Network Interfaces and Network Security Group can be imported using the resource id, e.g.

     $ pulumi import azure:network/networkInterfaceSecurityGroupAssociation:NetworkInterfaceSecurityGroupAssociation association1 "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.network/networkInterfaces/example|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkSecurityGroups/group1"
    

    To learn more about importing existing cloud resources, see Importing resources.

    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.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.