您好,登录后才能下订单哦!
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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。