Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,762 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How to add Network security group, application security group & custom NIC to existing virtual machine using azure bicep
and also, is azure bicep support migrated virtual machine module?
here is an example for you to use but be careful you need to modify it
// Define the Network Security Group (NSG)
resource nsg 'Microsoft.Network/networkSecurityGroups@2023-04-01' = {
name: 'nsgName'
location: 'location'
tags: {
// Your tags here
}
properties: {
// Define your security rules and other properties here
}
}
// Define the Application Security Group (ASG)
resource asg 'Microsoft.Network/applicationSecurityGroups@2023-04-01' = {
name: 'asgName'
location: 'location'
tags: {
// Your tags here
}
}
// Define the Virtual Machine
resource vm 'Microsoft.Compute/virtualMachines@2020-06-01' = {
name: 'vmName'
location: 'location'
properties: {
// Other VM properties
networkProfile: {
networkInterfaceConfigurations: [
{
name: 'nicConfigurationName'
properties: {
ipConfigurations: [
{
name: 'ipConfigName'
properties: {
// IP configuration properties
subnet: {
// Subnet reference
}
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
// Public IP address reference
}
// Associate the NSG with NIC
networkSecurityGroup: {
id: nsg.id
}
// Associate the ASG with NIC
applicationSecurityGroups: [
{
id: asg.id
}
]
}
}
]
// Other NIC properties
}
}
]
}
}
}