zoukankan      html  css  js  c++  java
  • Azure PowerShell (12) 通过Azure PowerShell创建SSH登录的Linux VM

      《Windows Azure Platform 系列文章目录

      本章将介绍如何使用Azure PowerShell,创建SSH登录的Linux VM

      前提要求:

      1.安装Azure PowerShell

      2.准备好Linux SSH Key:

      Windows Azure Virtual Machine (25) 使用SSH登录Azure Linux虚拟机

      具体的PowerShell命令如下:

    #在弹出的界面中,输入Azure China用户名和密码
    Add-AzureAccount -Environment AzureChinaCloud
    
    #选择当前订阅名称
    Select-AzureSubscription '[YourSubscriptionName]' -Current
    
    #创建高级存储
    New-AzureStorageAccount -StorageAccountName "[YourStorageAccountName]" -Location "China East" -Type "Premium_LRS" 
    
    #云服务名称
    $AzureCloud='[YourDNSName]'
    
    #Upload the cert to the cloud service
    $Cert = Add-AzureCertificate -ServiceName $AzureCloud -CertToDeploy "C:myCert.pem"
     
    #Get the thumbprint from the uploaded cert
    $ThumbPrint = (Get-AzureCertificate -ServiceName $AzureCloud).Thumbprint
     
    #The local user to create on the linux vm
    $adminName = "azureuser"
    
    #Create the ssh key to be placed in the vm during deployment (inside the specified user's home dir)
    $sshkey = New-AzureSSHKey -PublicKey -Fingerprint $ThumbPrint -Path "/home/$adminName/.ssh/authorized_keys"
    
    =================================================
    #创建VM
    
    $storageAccount = "[YourStorageAccountName]"
    
    $vmName ="[YourVMName]"
    $location = "China East"
    $imageList = Get-AzureVMImage | where {$_.ImageName -like "*CentOS-66*"}
    $imageName=$imageList[$imageList.Length -1 ].ImageName
    $vmSize ="Standard_DS13"
    $vnetName = '[YourVNetName]'
    $IPAddress = '[YourPrivateIP]'
    $SubnetNames = '[VNetSubnet]'
    
    $OSDiskPath = "https://" + $storageAccount + ".blob.core.chinacloudapi.cn/vhds/" + $vmName + "_OS_P10.vhd"
    
    $vm = New-AzureVMConfig -Name $vmName -ImageName $imageName -InstanceSize $vmSize -MediaLocation $OSDiskPath  -AvailabilitySetName 'DBAvbSet' 
    
    Add-AzureProvisioningConfig -Linux -VM $vm -LinuxUser $adminName -NoSSHPassword -SSHPublicKeys $sshkey -NoSSHEndpoint
    
    Set-AzureSubnet -SubnetNames $SubnetNames -VM $vm | Set-AzureStaticVNetIP -IPAddress $IPAddress 
    
    New-AzureVM -ServiceName $AzureCloud -VM $VM -VNetName $vnetName -Location $location
    
    ##创建SSD磁盘
    $vm = Get-AzureVM -ServiceName $AzureCloud -Name $vmName
    $LunNo = 1
    $path = "http://" + $storageAccount + ".blob.core.chinacloudapi.cn/vhds/" + "myDataDisk_" + $LunNo + "_P20.vhd"
    $label = "Disk " + $LunNo
    Add-AzureDataDisk -CreateNew -MediaLocation $path -DiskSizeInGB 500 -DiskLabel $label -LUN $LunNo -HostCaching None -VM $vm | Update-AzureVm

      

  • 相关阅读:
    获取微信接口各种信息
    servlet
    springmvc上传图片,发送邮件
    linuxmint卸载软件
    linuxmint更改权限
    screen 链接远程桌面
    eclipse添加桌面快捷方式
    window精选软件
    windows Server2012 IIS8.0配置安装完整教程
    SQL Server 2012 sa 用户登录 18456 错误
  • 原文地址:https://www.cnblogs.com/threestone/p/6000824.html
Copyright © 2011-2022 走看看