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
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章标题:Azurepowershell使用平台镜像创建ARM非托管磁盘虚拟机-创新互联
分享网址:http://lswzjz.com/article/ddcgsj.html