Azure   发布时间:2019-11-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Azure 基础:使用 powershell 创建虚拟机大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

Hell 在 azure 上创建虚拟主机(Ubuntu 服务器)。

title="Azure 基础:使用 powersHell 创建虚拟机" alt="Azure 基础:使用 powersHell 创建虚拟机" src="https://cn.js-code.com/res/2019/02-09/09/cd51d4a717a9d8792e8a76e726246f62.png" >

我们创建虚机的同时也要把这些组件一一的创建出来。

用这个脚本,所以把用到的变量全都放在一起便于修改或使用脚本的参数进行初始化:

= LOCATIOn = = + = + mname = = mname + = = + ename = mname + ename = + = = mname + = = = password =

是需要这么多的变量,这里先不解释,在后面用到一个说一个。

用户名和密码创建凭据对象:

password = ConvertTo-SecureString password -AsPlaintext - = New-Object System.Management.Automation.PSCredential (,password)

resource Group

一个新的 resource Group,这个虚机及其所有相关的组件都归属于同一个 resource Group:

New-AzureRmresourceGroup -Name -LOCATIOn LOCATIOn

LOCATIOn 中指定 resource Group 的位置为东亚(访问速度比较快)。

= New-AzureRmVirtualNetworkSubnetConfig -Name -AddressPrefix 192.168.1.0/24

= New-AzureRmVirtualNetwork -resourceGroupName -LOCATIOn LOCATIOn-Name -AddressPrefix 192.168.0.0/16 -Subnet

= New-AzureRmPublicIpaddress -resourceGroupName -LOCATIOn LOCATIOn-AlLOCATIOnMethod Static -IdleTimeoutInminutes 4-Name

= New-AzureRmNetworkSecurityRuleConfig -Name --Direction Inbound -Priority 200 -sourceAddressPrefix * -sourcePortRange * -DesTinationAddressPrefix *-DesTinationPortRange 22 -Access Allow

= New-AzureRmNetworkSecurityGroup -resourceGroupName -LOCATIOn LOCATIOn-Name -SecurityRules

= New-AzureRmNetworkInterface -Name ename -resourceGroupName -LOCATIOn LOCATIOn-SubnetId .Subnets[0].Id -PublicIpaddressId .Id -NetworkSecurityGroupId .Id

= New-AzureRmStorageAccount -resourceGroupName -Name ename -Type -LOCATIOn LOCATIOn

= .PriMaryEndpoints.blob.ToString() + + +

= New-AzureRmVMConfig -Vmname mname -VMSize |-AzureRmVMOperaTingSystem -Linux -ComputerName mname -Credential -DisablepasswordAuthentication |-AzureRmVMsourceImage -PublisherName Canonical -Offer UbuntuServer -Skus -Version latest |-AzureRmVMNetworkInterface -Id .Id |-AzureRmVMOSDisk -VhdUri -CreateOption FromImage

我们创建的虚机操作系统为 Ubuntu Server 16.04-LTS,禁止使用用户名密码的方式登录。要让用户能够通过公钥的方式登录必须提供用户的公钥:

=

Add-AzureRmVMSshPublicKey -VM -KeyData -Path

New-AzureRmVM -resourceGroupName -LOCATIOn LOCATIOn -VM

需要用户先进行登录,那么在 PowerSHell 脚本中该如何做呢?http://www.cnblogs.com/sparkdev/p/6358266.html" target="_blank">Azure 基础:用 PowerSHell 自动登录》一文中有详细的介绍,有兴趣的朋友可以参

大佬总结

以上是大佬教程为你收集整理的Azure 基础:使用 powershell 创建虚拟机全部内容,希望文章能够帮你解决Azure 基础:使用 powershell 创建虚拟机所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: