我已成功使用
ruby sdk
但我找不到任何从托管映像创建的示例。我想做这样的事情,但是使用SDK:
az image create --name fedora-75-20180724 --resource-group myteam --source https://eastusimg.blob.core.windows.net/images/fedora-28-20180724.vhd --os-type linux
# create vm without option "--use-unmanaged-disk, --os-type, --storage-account"
az vm create -g myteam -n managed-master --image fedora28-20180724 --size Standard_DS2_V2 --nics managed-master --os-disk-size-gb 40 --public-ip-address-dns-name managed-master --os-disk-name managed-master
但我不清楚该怎么做,也找不到这样的例子。我看到的例子有
here
和
here
. 基本上我不知道如何构造
StorageProfile
或者我需要更多的东西。所以我希望有一个创建这样一个VM的代码示例。
谢谢您。
更新一个基于@4c74356b41答案的工作(除非我忘了什么)示例:
ComputeModels::StorageProfile.new.tap do |store_profile|
store_profile.image_reference = ComputeModels::ImageReference.new.tap do |ref|
# obtain `image` by `compute_client.images.list_by_resource_group`
# make sure they are in the same region though or you'll see 404
ref.id = image.id
end
store_profile.os_disk = ComputeModels::OSDisk.new.tap do |os_disk|
os_disk.name = "my-unique-disk-name"
os_disk.disk_size_gb = 42 # optionally change size
os_disk.caching = ComputeModels::CachingTypes::ReadWrite # this is a test machine
os_disk.create_option = ComputeModels::DiskCreateOptionTypes::FromImage
# setting `managed_disk` is optional
os_disk.managed_disk = ComputeModels::ManagedDiskParameters.new.tap do |params|
params.storage_account_type = StorageModels::SkuName::StandardLRS
end
end
end