Reputation: 1225
Starting from the code below I'm trying to add the security group $nsg to the network interface $interface The current value of $interface.NetworkSecurityGroup is null
The security group and the newtork interface arealready created. How do I assign the security group to the network interface?
$resourceGroupName = "evoeitrg"
$interfaceName = "evoeitinterface"
$securityGroupName = "NsgWebServer"
$interface = Get-AzureRmNetworkInterface -Name $interfaceName -ResourceGroupName $resourceGroupName
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroupName -Name $securityGroupName
Upvotes: 3
Views: 2410
Reputation: 12228
This seems to be what you're looking for
$sg = Get-AzureRmNetworkSecurityGroup
$nic1 = New-AzureRmNetworkInterface -Name testnic `
-ResourceGroupName $rg `
-Location westeurope `
-SubnetId $subnetid
$nic1.NetworkSecurityGroup = $sg[1]
$nic1 | Set-AzureRmNetworkInterface
Upvotes: 4