azure simple command which can create the vm
程序员文章站
2022-03-09 12:04:37
...
Once a Managed OS Disk has been created, it can also be used to create a VM:
订阅id
#Provide the subscription Id
subscriptionId=<subscription id>
安全组的name
#Provide the name of your resource group
resourceGroupName=myResourceGroupName
#Provide the name of the Managed Disk
managedDiskName=myDiskName
#Provide the OS type
osType=linux
#Provide the name of the virtual machine
virtualMachineName=myVirtualMachineName123
#为订阅的id 设置上下文,其实是账户
#Set the context to the subscription Id where Managed Disk exists and where VM will be created
az account set --subscription $subscriptionId
#获取管理的disk的resource ID
#Get the resource Id of the managed disk
managedDiskId=$(az disk show --name $managedDiskName --resource-group $resourceGroupName --query [id] -o tsv)
创建一个azure vm need the vm name the resource group, the store disk and the os type
#Create VM by attaching existing managed disks as OS
az vm create --name $virtualMachineName --resource-group $resourceGroupName --attach-os-disk $managedDiskId --os-type $osType
上一篇: 学java需要什么基础?
下一篇: 如何使用SQL BETWEEN 操作符