《Windows Azure Platform 系列文章目录

  刚刚在帮助一个合作伙伴研究需求,他们的虚拟机全面的网络安全组(Network Security Group, NSG)会经常变动,如果手动修改非常麻烦。

  看看是否有批量设置的方法。我仔细研究了一下,记一下笔记。

  注意:这里介绍的是Azure ARM模式下的,虚拟机的Azure NSG网络安全组。

  前提需求:

  1.安装Azure PowerShell

  2.Azure ARM模式下的资源

  具体运行的Azure PowerShell

Add-AzureRmAccount -EnvironmentName AzureChinaCloud
#在弹出的界面中,输入用户名和密码,则登陆通过
#不过关闭PowerShell以后,下次要重新进行身份验证 #选择相应的订阅名称:
Select-AzureRmSubscription -SubscriptionName 'Training'| Select-AzureRmSubscription #请注意下面的NSG必须之前是已经存在的
$resourceGroupName='LeiLinuxRG'
$nsgName= 'LeiCentOS68-nsg' #创建允许外部对3306端口访问,源IP必须是192.168.1.0/24
$ruleName1= 'Inbound3306-rule'
$sourceIP= '192.168.1.0/24'
$destinationPort = 3306 $nsg = Get-AzureRmNetworkSecurityGroup -Name $nsgName -ResourceGroupName $resourceGroupName $nsg | Add-AzureRmNetworkSecurityRuleConfig -Name $ruleName1 -Description "Allow 3306" -Access `
Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix $sourceIP `
-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange $destinationPort #创建允许外部对3389端口访问,源IP必须是192.168.1.0/24
$ruleName2= 'Inbound3389-rule'
$destinationPort = 3389 $nsg | Add-AzureRmNetworkSecurityRuleConfig -Name $ruleName2 -Description "Allow RDP" -Access `
Allow -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix $sourceIP `
-SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange $destinationPort $nsg | Set-AzureRmNetworkSecurityGroup

Azure PowerShell (13) 批量设置Azure ARM Network Security Group (NSG)的更多相关文章

  1. Azure PowerShell (14) 批量导出Azure ASM ACL和ARM NSG配置信息

    <Windows Azure Platform 系列文章目录> 最近有一个客户需求,需要批量导出Azure Classic VM的ACL (Access Control List), 还有 ...

  2. Azure PowerShell (15) 批量导出Azure ASM/ARM VM信息

    <Windows Azure Platform 系列文章目录> 客户又提出新的需求,需要知道所有订阅下的虚拟机数量.运行情况等信息. 我花了点时间,写了一个PowerShell脚本,发布到 ...

  3. Azure PowerShell (5) 使用Azure PowerShell创建简单的Azure虚拟机和Linux虚拟机

    <Windows Azure Platform 系列文章目录> 本文介绍的是国外的Azure Global.如果是国内由世纪互联运维的Azure China,请参考这篇文档: Azure ...

  4. 使用Windows Azure PowerShell远程管理Windows Azure虚拟机

    对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...

  5. Azure ARM (22) 使用Azure PowerShell创建Azure RM VM

    <Windows Azure Platform 系列文章目录> 在Azure China获得VM Image,可以执行下面的脚本. Get-AzureRmVMImagePublisher ...

  6. Windows Azure HandBook (3) 浅谈Azure安全性

    <Windows Azure Platform 系列文章目录> 2015年3月5日-6日,参加了上海的Azure University活动.作为桌长与微软合作伙伴交流了Azure相关的技术 ...

  7. Windows Azure Virtual Network (6) 设置Azure Virtual Machine固定公网IP (Virtual IP Address, VIP) (1)

    <Windows Azure Platform 系列文章目录> 注意:本文介绍的是Global Azure (http://www.windowsazure.com),如果你使用的是由世纪 ...

  8. 【Azure Developer】使用Java SDK代码创建Azure VM (包含设置NSG,及添加数据磁盘SSD)

    在参考Azure官方文档进行VM创建时,发现其中没有包含如何设置NSG的内容,以及如何在创建时就添加数据磁盘的代码(设置磁盘为SSD类型).本文的内容以"使用 Java 创建和管理 Azur ...

  9. 使用 Azure PowerShell 模块创建和管理 Windows VM

    Azure 虚拟机提供完全可配置的灵活计算环境. 本教程介绍 Azure 虚拟机的基本部署项目,例如选择 VM 大小.选择 VM 映像和部署 VM. 你将学习如何执行以下操作: 创建并连接到 VM 选 ...

随机推荐

  1. [转]RabbitMQ系列(一):Windows下RabbitMQ安装及入门

    https://blog.csdn.net/hzw19920329/article/details/53156015 1.Windows下安装RabbitMQ需要以下几个步骤 (1):下载erlang ...

  2. 解决Python2.7的UnicodeEncodeError: ‘ascii’ codec can’t encode异常错误

    更改 sys.defaultencoding 为文件的编码方式  #! /usr/bin/env python  # -*- coding: utf-8 -*-  import sys  reload ...

  3. 打开视图 :1449 - the user specified as a definer ('root'@'%')does not exist

    从一个数据库数据迁移到本地localhost   程序在调用到数据库的视图时报错,直接在数据库中打开视图时也报错,类似:   mysql 1449 : The user specified as a ...

  4. ZOJ 1006:Do the Untwist(模拟)

    Do the Untwist Time Limit: 2 Seconds      Memory Limit: 65536 KB Cryptography deals with methods of ...

  5. 代码规范V1.1

    作业要求:[https://edu.cnblogs.com/campus/nenu/SWE2017FALL/homework/993] 代码规范文档/代码规范执行记录:[https://coding. ...

  6. kafka安装和部署

    阅读目录 一.环境配置 二.操作过程 Kafka介绍 安装及部署 回到顶部 一.环境配置 操作系统:Cent OS 7 Kafka版本:0.9.0.0 Kafka官网下载:请点击 JDK版本:1.7. ...

  7. djangorestful framework (三)学习

    十.分页器 -简单分页: -from rest_framework.pagination import PageNumberPagination -生成一个对象 -调用对象的.page.paginat ...

  8. web前端的问题整理

    css实现三列布局?如果中间又是自适应布局怎么做?

  9. Go Example--打点器

    package main import ( "time" "fmt" ) func main() { // 定时器 是当你想要在未来某一刻执行一次时使用的 - ...

  10. hibernate中带查询条件的分页

    所谓分页,从数据库中分,则是封装一个分页类.利用分页对象进行分页. 但,分页往往带查询条件. 分页类的三个重要数据:[当前页码数],[数据库中的总记录数],[每页显示的数据的条数] 原理:select ...