• 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

      

  • 相关阅读:
    [GSEAPY] 在Python里进行基因集富集分析
    scRNAseq R包公共单细胞数据获取
    pybedtools:在Python中使用BEDTools
    pybedtools 提取序列
    将博客搬至CSDN
    【转】SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    sql长日期数据以短日期格式显示【转】
    [转]YouTube架构学习体会
    [转]让Nginx 支持 ASP ASP.NET配置方法
    [转]LINQ查询总结
  • 原文地址:https://www.cnblogs.com/threestone/p/6000824.html
Copyright © 2020-2023  润新知