Azure ARM (22) 使用Azure PowerShell创建Azure RM VM
《Windows Azure Platform 系列文章目录》
在Azure China获得VM Image,可以执行下面的脚本。
Get-AzureRmVMImagePublisher -Location chinaeast Get-AzureRmVMImageOffer -Location chinaeast -PublisherName 'OpenLogic' Get-AzureRmVMImagesku -Location chinaeast -PublisherName 'OpenLogic' -Offer CentOS Get-AzureRMVMImage -location chinaeast -publisherName 'OpenLogic' -sku '6.9' -Offer CentOS Get-AzureRMVMImage -location chinaeast -publisherName 'OpenLogic' -sku '6.9' -Offer CentOS -Version 6.9.
在Azure China创建Linux VM,可以执行下面的脚本。
Login-AzureRmAccount -Environment AzureChinaCloud #这里设置订阅名称
$subscriptionName = '订阅名称' Select-AzureRmSubscription -SubscriptionName $subscriptionName #需要手动创建虚拟网络
$resourceGroupName = "这里设置资源组"
$virtualNetworkName = "这里设置虚拟网络" $locationName = "China East"
$virtualNetwork = Get-AzureRmVirtualNetwork -ResourceGroupName $resourceGroupName -Name $virtualNetworkName #自动创建blob
#$BlobURL = New-AzureRmStorageAccount -Location $locationName -ResourceGroupName $resourceGroupName -Name testvmshstorage -SkuName "Standard_LRS"
$BlobURL = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name testvmshstorage #新建network interface
#$publicIPAddress = "MyNewPIP"
#$publicIp = New-AzureRmPublicIpAddress -Name $publicIPAddress -ResourceGroupName $ResourceGroupName -Location $locationName -AllocationMethod Dynamic #虚拟机名称
$vmName = "这里设置虚拟机名称"
$vmSize = "Standard_D3_V2" #新建Network Security Group:
# Create an inbound network security group rule for port
$nsgRuleSSH = New-AzureRmNetworkSecurityRuleConfig -Name default-allow-ssh -Protocol Tcp `
-Direction Inbound -Priority -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
-DestinationPortRange -Access Allow $nsgName = $vmName + "-nsg" # Create a network security group
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroupName -Location $locationName -Name $nsgName -SecurityRules $nsgRuleSSH #虚拟机创建虚拟网络的第一个子网里
$nicName = $vmName + "-nic"
$networkInterface = New-AzureRmNetworkInterface -ResourceGroupName $resourceGroupName -Name $nicName -Location $locationName -SubnetId $virtualNetwork.Subnets[].Id -NetworkSecurityGroupId $nsg.Id #新建可用性组
$avbSetName = "My-AvbSet"
$availabilitySet = New-AzureRmAvailabilitySet -ResourceGroupName $resourceGroupName -Name $avbSetName -Location $locationName #.Set the administrator account name and password for the virtual machine.
$username = "Linux用户名";
$password = 'Linux密码';
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ($UserName, $securePassword) #.Choose virtual machine size, set computername and credential
$VM= New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetID $availabilitySet.Id -ErrorAction Stop
$VM = Set-AzureRmVMOperatingSystem -VM $VM -Linux -ComputerName $vmName -Credential $cred -ErrorAction Stop #.Choose source image
$VM = Set-AzureRmVMSourceImage -VM $VM -publisherName 'OpenLogic' -sku '6.9' -Offer CentOS -Version 6.9. #.Add the network interface to the configuration
$VM = Add-AzureRmVMNetworkInterface -VM $VM -Id $networkInterface.id #.Add storage that the virtual hard disk will use.
$BlobPath = "vhds/"+ $vmName +"-OSDisk.vhd"
$OSDiskUri = $BlobURL.PrimaryEndpoints.Blob + $BlobPath
$DiskName = "linuxvmosdisk"
$VM = Set-AzureRmVMOSDisk -VM $VM -Name $DiskName -VhdUri $OSDiskUri -CreateOption fromImage -ErrorAction Stop #. Create a virtual machine
New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VM -ErrorAction Stop
Write-Host "Successfully created a virtual machine $VMName" -ForegroundColor Green
Azure ARM (22) 使用Azure PowerShell创建Azure RM VM的更多相关文章
- [New Portal]Windows Azure Virtual Machine (16) 使用Azure PowerShell创建Azure Virtual Machine
<Windows Azure Platform 系列文章目录> 注:本章内容和之前的[New Portal]Windows Azure Virtual Machine (12) 在本地制作 ...
- 使用 PowerShell 创建 Azure VM 的自定义映像
自定义映像类似于应用商店映像,不同的是自定义映像的创建者是你自己. 自定义映像可用于启动配置,例如预加载应用程序.应用程序配置和其他 OS 配置. 在本教程中,你将创建自己的 Azure 虚拟机自定义 ...
- Azure ARM (22) Azure Policy入门
<Windows Azure Platform 系列文章目录> 我们知道,在Azure服务层级中,分为以下几个层次: 1.企业合同 2.订阅 3.资源组 4.资源 我们使用的Azure资源 ...
- Azure机器学习入门(二)创建Azure机器学习工作区
我们将开始深入了解如何使用Azure机器学习的基本功能,帮助您开始迈向Azure机器学习的数据科学家之路. Azure ML Studio (Azure Machine Learning Studio ...
- Azure机器学习入门(三)创建Azure机器学习实验
在此动手实践中,我们将在Azure机器学习Studio中一步步地开发预测分析模型,首先我们从UCI机器学习库的链接下载普查收入数据集的样本并开始动手实践: http://archive.ics.uci ...
- 使用PowerShell创建Azure Storage的SAS Token访问Azure Blob文件
Azure的存储包含Storage Account.Container.Blob等具体的关系如下: 我们常用的blob存储,存放在Storage Account的Container里面. 目前有三种方 ...
- Azure ARM (10) ARM模式下的虚拟机和Classic Model虚拟机的区别
<Windows Azure Platform 系列文章目录> 本文内容比较多,请大家仔细阅读,谢谢! 请读者注意,在Azure ARM平台,有两种虚拟机模式:经典虚拟机和ARM虚拟机 A ...
- 在Azure China用自定义镜像创建Azure VM Scale Set
在Azure China用自定义镜像创建Azure VM Scale Set 在此感谢世纪互联的工程师Johnny Lee和Lan,你们给了我很大的帮助.因为Azure China的官网没有给出完整的 ...
- Azure ARM (16) 基于角色的访问控制 (Role Based Access Control, RBAC) - 使用默认的Role
<Windows Azure Platform 系列文章目录> 今天上午刚刚和客户沟通过,趁热打铁写一篇Blog. 熟悉Microsoft Azure平台的读者都知道,在老的Classic ...
随机推荐
- JavaScript操作符-3---算数,逻辑,赋值,比较,三元
JavaScript操作符 学习目标 1.掌握什么是表达式 2.掌握javascript操作符的分类 3.掌握算数操作符 什么是表达式 将类型的数据(如常量.变量.函数等),用运算符号按一定的规则链接 ...
- 【leetcode】9-PalindromeNumber
problem Palindrome Number 回文数字: 什么是回文数字? 要求不能使用字符串: 翻转一半的数字: 如何判断数字到一半啦? 参考 1.leetcode-problem: 完
- scrapy常用命令
终端命令 创建一个项目: scrapy startproject name 利用蜘蛛名创建一个py文件: scrapy genspider name domain.name 在终端运行:scrapy ...
- Unity 思考问题的办法
Unity 思考问题的办法 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享. ...
- P2157 [SDOI2009]学校食堂 (dp+状态压缩)
题目链接:传送门 题目: 题目描述 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人口味也不一定相同,但每个人 ...
- ubuntu安装mysql遇到的问题
ERROR 1698 (28000): Access denied for user 'root'@'localhost' ubantu linux下安装新版mysql,登录时必须sudo mysql ...
- 实验吧—Web——WP之 what a fuck!这是什么鬼东西?
打开链接——> 发现是一大堆符号,可能有些人见过这些样子的,这是一种编码方式,叫:jother编码 jother编码是一种运用于javasscript语言中利用少量字符构造精简的匿名函数方法,对 ...
- hello1分析
1:选择hello1文件夹并单击“打开项目”.展开“Web页”节点,然后双击该index.xhtml文件以在编辑器中查看它. 该index.xhtml文件是Facelets应用程序的默认登录页面.在典 ...
- shell-dict-uniq-count
shell dict #!/bin/bash result_file="a" declare -A mydict :>${result_file} total=`cat $ ...
- zabbix——拓扑图入门
zabbix的拓扑图是动态的,当你配置好拓扑图后,一旦网络中那个节点出现了问题,很容易在拓扑图中看出问题具体出在哪个位置. 新建一个拓扑图 我们常用到的图标有rack(机柜)还有rackmountab ...