使用Java SDK使用临时OS磁盘创建Azure虚拟机

时间:2019-06-05 14:35:58

标签: java azure

根据Azure documentation,可以将临时操作系统磁盘用于Azure VM。

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

但是,我找不到有关如何使用Java SDK创建虚拟机的任何示例。

是否可以使用Java SDK?

1 个答案:

答案 0 :(得分:0)

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}]

希望有帮助。