Skip to content

Commit 11570aa

Browse files
committed
Add config for disabling nsg rule when creating VM
1 parent a0057a0 commit 11570aa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/azure-cli/azure/cli/command_modules/vm/_template_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def build_nic_resource(_, name, location, tags, vm_name, subnet_id, private_ip_a
193193
return nic
194194

195195

196-
def build_nsg_resource(_, name, location, tags, nsg_rule):
196+
def build_nsg_resource(cmd, name, location, tags, nsg_rule):
197197
nsg = {
198198
'type': 'Microsoft.Network/networkSecurityGroups',
199199
'name': name,
@@ -203,7 +203,7 @@ def build_nsg_resource(_, name, location, tags, nsg_rule):
203203
'dependsOn': []
204204
}
205205

206-
if nsg_rule != 'NONE':
206+
if nsg_rule != 'NONE' and not cmd.cli_ctx.config.getboolean('vm', 'disable_nsg_rule', fallback=False):
207207
rule_name = 'rdp' if nsg_rule == 'RDP' else 'default-allow-ssh'
208208
rule_dest_port = '3389' if nsg_rule == 'RDP' else '22'
209209

src/azure-cli/azure/cli/command_modules/vm/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3016,7 +3016,7 @@ def _get_public_ip_address_allocation(value, sku):
30163016
if load_balancer_sku and load_balancer_sku.lower() == 'standard' and nsg is None and os_type:
30173017
nsg_name = '{}NSG'.format(vmss_name)
30183018
master_template.add_resource(build_nsg_resource(
3019-
None, nsg_name, location, tags, 'rdp' if os_type.lower() == 'windows' else 'ssh'))
3019+
cmd, nsg_name, location, tags, 'rdp' if os_type.lower() == 'windows' else 'ssh'))
30203020
nsg = "[resourceId('Microsoft.Network/networkSecurityGroups', '{}')]".format(nsg_name)
30213021
vmss_dependencies.append('Microsoft.Network/networkSecurityGroups/{}'.format(nsg_name))
30223022

0 commit comments

Comments
 (0)