Azure / Azure Stack – IaaS VM ARM NSG Template Integration

In my last blog post about the Network Security Group feature I have shown you how to create a NSG via PowerShell and explained why they are important.

-> http://www.danielstechblog.de/azure-azure-stack-iaas-vm-arm-network-security-group/

Today I will show you how to implement the creation and attach process directly into the IaaS VM ARM template.

First of all we create a new resource for the NSG itself and define a security rule for the RDP access.

StackNSG01

Attaching the NSG to a subnet of a virtual network is very easy. You have just to provide the NSG ID in the properties of the subnet.

StackNSG02

Also the attachment of a NSG to a NIC is the same as it is for the subnet. You have to provide the NSG ID in the properties of the NIC.

StackNSG03

Next step is to deploy the ARM JSON template to Azure via the Azure PowerShell Cmdlets.

$ResourceGroupName=”Azure-Stack-Demo”
$Location=”westeurope”
New-AzureResourceGroup -Name $ResourceGroupName -Location $Location
New-AzureResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateFile “C:VolumeSkyDriveSyncAzureARMProductionNPNetwork.json” -TemplateParameterFile “C:VolumeSkyDriveSyncAzureARMProductionNPNetwork.parameters.json” -Verbose

VERBOSE: 21:22:10 – Template is valid.
VERBOSE: 21:22:10 – Create template deployment ‘Network’.
VERBOSE: 21:22:18 – Resource Microsoft.Network/publicIPAddresses ‘azstcpdemo-01-PublicIP01’ provisioning status is running
VERBOSE: 21:22:18 – Resource Microsoft.Network/virtualNetworks ‘Azure-Stack-Network-Demo’ provisioning status is running
VERBOSE: 21:22:18 – Resource Microsoft.Network/networkSecurityGroups ‘Azure-Stack-NSG-Demo’ provisioning status is running
VERBOSE: 21:22:28 – Resource Microsoft.Network/publicIPAddresses ‘azstcpdemo-01-PublicIP01’ provisioning status is succeeded
VERBOSE: 21:22:28 – Resource Microsoft.Network/virtualNetworks ‘Azure-Stack-Network-Demo’ provisioning status is succeeded
VERBOSE: 21:22:28 – Resource Microsoft.Network/networkSecurityGroups ‘Azure-Stack-NSG-Demo’ provisioning status is succeeded
VERBOSE: 21:22:33 – Resource Microsoft.Network/networkInterfaces ‘azstcpdemo-01-NIC01’ provisioning status is succeeded

As you can see the NSG is attached to the right resources.

StackNSG04StackNSG05

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply