Add config for disabling nsg rule when creating VM

This commit is contained in:
zhoxing-ms 2022-04-22 12:03:39 +08:00
Родитель a0057a0e4b
Коммит 11570aa3e9
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -193,7 +193,7 @@ def build_nic_resource(_, name, location, tags, vm_name, subnet_id, private_ip_a
return nic
def build_nsg_resource(_, name, location, tags, nsg_rule):
def build_nsg_resource(cmd, name, location, tags, nsg_rule):
nsg = {
'type': 'Microsoft.Network/networkSecurityGroups',
'name': name,
@ -203,7 +203,7 @@ def build_nsg_resource(_, name, location, tags, nsg_rule):
'dependsOn': []
}
if nsg_rule != 'NONE':
if nsg_rule != 'NONE' and not cmd.cli_ctx.config.getboolean('vm', 'disable_nsg_rule', fallback=False):
rule_name = 'rdp' if nsg_rule == 'RDP' else 'default-allow-ssh'
rule_dest_port = '3389' if nsg_rule == 'RDP' else '22'

Просмотреть файл

@ -3016,7 +3016,7 @@ def create_vmss(cmd, vmss_name, resource_group_name, image=None,
if load_balancer_sku and load_balancer_sku.lower() == 'standard' and nsg is None and os_type:
nsg_name = '{}NSG'.format(vmss_name)
master_template.add_resource(build_nsg_resource(
None, nsg_name, location, tags, 'rdp' if os_type.lower() == 'windows' else 'ssh'))
cmd, nsg_name, location, tags, 'rdp' if os_type.lower() == 'windows' else 'ssh'))
nsg = "[resourceId('Microsoft.Network/networkSecurityGroups', '{}')]".format(nsg_name)
vmss_dependencies.append('Microsoft.Network/networkSecurityGroups/{}'.format(nsg_name))