重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Azurepowershell使用平台镜像创建ARM非托管磁盘虚拟机

Select-AzureRmSubscription -SubscriptionName "xxxxxxxx"  # 选择订阅环境

成都网站制作、做网站,成都做网站公司-创新互联已向上千家企业提供了,网站设计,网站制作,网络营销等服务!设计与技术结合,多年网站推广经验,合理的价格为您打造企业品质网站。

 

# 网络选项

$myVirtualNetworkResourceGroup = " xxxxxxxx "  # 虚拟网络资源组 

$myVirtualNetworkName = " xxxxxxxx "  # 虚拟网络

$myVirtualNetworkSubnetName = " xxxxxxxx " # 虚拟子网

$myResourceGroupName = " xxxxxxxx "

$myLocation = " xxxxxxxx "

$myAvailabilitySetName = " xxxxxxxx "

$myNetworkInterfaceName = " xxxxxxxx "

 

$myPublicIpAddressName = " xxxxxxxx "

$myDomainName = " xxxxxxxx "

$myLoadBalancerFrontendName = " xxxxxxxx "  # 负载均衡器前端名称

$myLoadBalancerBackendName = " xxxxxxxx "  # 负载均衡器后端名称

$myLoadBalanceName = " xxxxxxxx "

$myStorageAccountName = " xxxxxxxx "

# $myOSDiskUri = "http://" + $myStorageAccountName + ".blob.core.chinacloudapi.cn/vhds/" + "myOSDisk.vhd"

$myVMName = " xxxxxxxx "

$myVMSize = "Standard_D3_V2"

$myUsername = "leo"    ###自定义用户名称

$myPassword = "xxxxxxxx"  ###虚拟机账户密码

 

 

# 创建资源组

$myResourceGroup = New-AzureRmResourceGroup -Name $myResourceGroupName -Location $myLocation

 

# 创建可用性集

$myAvailabilitySet = New-AzureRmAvailabilitySet -Location $myLocation -Name $myAvailabilitySetName -ResourceGroupName $myResourceGroupName

 

# 创建存储账号

$myStorageAccount = New-AzureRMStorageAccount -Location $myLocation -Name $myStorageAccountName -ResourceGroupName $myResourceGroupName -SkuName Standard_LRS

 

# 创建公共IP地址

$myPublicIpAddressName = New-AzureRmPublicIpAddress -ResourceGroupName $myResourceGroupName -AllocationMethod Dynamic -Name $myPublicIpAddressName -Location $myLocation -DomainNameLabel $myDomainName

 

# 创建前端池

$myLoadBalancerFrontend = New-AzureRmLoadBalancerFrontendIpConfig -Name $myLoadBalancerFrontendName -PublicIpAddress $myPublicIpAddressName

 

# 创建后端池

$myLoadBalancerBackend = New-AzureRmLoadBalancerBackendAddressPoolConfig -Name $myLoadBalancerBackendName

 

# 创建负载均衡集

$myLoadBalancer = New-AzureRmLoadBalancer -Location $myLocation -Name $myLoadBalanceName -ResourceGroupName $myResourceGroupName -FrontendIpConfiguration $myLoadBalancerFrontend -BackendAddressPool $myLoadBalancerBackend

 

# 新建网络接口

$myVirtualNetwork = Get-AzureRmVirtualNetwork -ResourceGroupName $myVirtualNetworkResourceGroup -Name $myVirtualNetworkName

$myVirtualNetworkSubnet = Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $myVirtualNetwork -Name $myVirtualNetworkSubnetName

$myNetworkInterface = New-AzureRmNetworkInterface -Name $myNetworkInterfaceName -ResourceGroupName  $myResourceGroupName -Location $myLocation -Subnet $myVirtualNetworkSubnet -LoadBalancerBackendAddressPool $myLoadBalancerBackend

 

# 创建登陆凭证

$myCred = New-Object System.Management.Automation.PSCredential($myUsername, (ConvertTo-SecureString $myPassword -AsPlainText -Force))

 

# 系统磁盘路径

$myURL = "http://" + $myStorageAccountName + ".blob.core.chinacloudapi.cn/vhds/" + $myVMName + "myOSDisk.vhd"

 

 

# 虚拟机配置

$vmConfig = New-AzureRmVMConfig -VMName $myVMName -VMSize $myVMSize -AvailabilitySetId $myAvailabilitySet.Id | `

Set-AzureRmVMOperatingSystem -Windows -ComputerName $myVMName -Credential $myCred | `

Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2016-Datacenter-zhcn -Version latest | `

Add-AzureRmVMNetworkInterface -Id $myNetworkInterface.Id | `

Set-AzureRmVMOSDisk -CreateOption FromImage -VhdUri $myURL -Windows

 

# 创建虚拟机

$myVM = New-AzureRmVM -ResourceGroupName $myResourceGroupName -Location $myLocation -VM $vmConfig


本文标题:Azurepowershell使用平台镜像创建ARM非托管磁盘虚拟机
本文路径:http://cqcxhl.com/article/jhicce.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP