首页 > 解决方案 > 使用 Java SDK 创建具有临时 OS 磁盘的 Azure 虚拟机

问题描述

根据 Azure文档,可以为 Azure VM 使用临时 OS 磁盘。

我需要带有临时 OS 磁盘的 CentOS VM。

但是,我找不到任何关于如何使用 Java SDK 创建 VM 的示例。

是否可以使用 Java SDK?

标签: javaazure

解决方案


Alex,不太确定 Java sdk,但您可以使用 ARM 模板或 Azure cli 创建带有临时 OS 磁盘的 VM。

以下是通过 ARM 的示例:

{ 
  "type": "Microsoft.Compute/virtualMachines", 
  "name": "myVirtualMachine", 
  "location": "East US 2", 
  "apiVersion": "2018-06-01", 
  "properties": { 
       "storageProfile": { 
            "osDisk": { 
              "diffDiskSettings": { 
                "option": "Local" 
              }, 
              "caching": "ReadOnly", 
              "createOption": "FromImage" 
            }, 
            "imageReference": { 
                "publisher": "MicrosoftWindowsServer", 
                "offer": "WindowsServer", 
                "sku": "2016-Datacenter-smalldisk", 
                "version": "latest" 
            }, 
            "hardwareProfile": { 
                 "vmSize": "Standard_DS2_v2" 
             } 
      }, 
      "osProfile": { 
        "computerNamePrefix": "myvirtualmachine", 
        "adminUsername": "azureuser", 
        "adminPassword": "P@ssw0rd!" 
      } 
    } 
 } 

通过 CLI

az vm create --name
             --resource-group
             [--accelerated-networking {false, true}]
             [--admin-password]
             [--admin-username]
             [--asgs]
             [--assign-identity]
             [--attach-data-disks]
             [--attach-os-disk]
             [--authentication-type {all, password, ssh}]
             [--availability-set]
             [--boot-diagnostics-storage]
             [--computer-name]
             [--custom-data]
             [--data-disk-caching]
             [--data-disk-sizes-gb]
             [--ephemeral-os-disk {false, true}]
             [--generate-ssh-keys]
             [--image]
             [--license-type {None, Windows_Client, Windows_Server}]
             [--location]
             [--nics]
             [--no-wait]
             [--nsg]
             [--nsg-rule {RDP, SSH}]
             [--os-disk-caching {None, ReadOnly, ReadWrite}]
             [--os-disk-name]
             [--os-disk-size-gb]
             [--os-type {linux, windows}]
             [--plan-name]
             [--plan-product]
             [--plan-promotion-code]
             [--plan-publisher]
             [--ppg]
             [--private-ip-address]
             [--public-ip-address]
             [--public-ip-address-allocation {dynamic, static}]
             [--public-ip-address-dns-name]
             [--public-ip-sku {Basic, Standard}]
             [--role]
             [--scope]
             [--secrets]
             [--size]
             [--ssh-dest-key-path]
             [--ssh-key-values]
             [--storage-account]
             [--storage-container-name]
             [--storage-sku]
             [--subnet]
             [--subnet-address-prefix]
             [--subscription]
             [--tags]
             [--ultra-ssd-enabled {false, true}]
             [--use-unmanaged-disk]
             [--validate]
             [--vnet-address-prefix]
             [--vnet-name]
             [--zone {1, 2, 3}]

希望能帮助到你。


推荐阅读