Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用azure java sdk列出自定义映像(从ARM VM捕获)_Java_Azure_Azure Java Sdk_Azureportal - Fatal编程技术网

如何使用azure java sdk列出自定义映像(从ARM VM捕获)

如何使用azure java sdk列出自定义映像(从ARM VM捕获),java,azure,azure-java-sdk,azureportal,Java,Azure,Azure Java Sdk,Azureportal,如何获取从使用ARM创建的azure虚拟机捕获的映像,以便我可以使用它作为使用azure java sdk创建所有后续虚拟机的基础映像?有一个官方博客可以帮助您开始使用azure java sdk进行服务管理。请参阅 为了实现这一需求,您需要在Java项目中添加一些maven包。请参阅下面的依赖项 <dependency> <groupId>com.microsoft.azure</groupId> <artifactId>azur

如何获取从使用ARM创建的azure虚拟机捕获的映像,以便我可以使用它作为使用azure java sdk创建所有后续虚拟机的基础映像?

有一个官方博客可以帮助您开始使用azure java sdk进行服务管理。请参阅

为了实现这一需求,您需要在Java项目中添加一些maven包。请参阅下面的依赖项

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-svc-mgmt</artifactId>
    <version>0.9.0</version>
</dependency>
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-svc-mgmt-compute</artifactId>
    <version>0.9.0</version>
</dependency>

最近azure发布了Java SDK 1.0.0作为LTS版本

请参阅下面的代码以使用自定义映像创建vm

       VirtualMachineCustomImage customImage = azure.virtualMachineCustomImages().getByResourceGroup("resource_gr_name", "image_name");

       Creatable<VirtualMachine> linuxVM = azure.virtualMachines().define(vmName)
               .withRegion(Region.US_WEST)
               .withExistingResourceGroup("rishi")
               .withExistingPrimaryNetwork(network)
               .withSubnet("default") // Referencing the default subnet name when no name specified at creation
               .withPrimaryPrivateIPAddressDynamic()
               .withoutPrimaryPublicIPAddress()
               .withLinuxCustomImage(customImage.id())
               .withRootUsername("centos")
               .withRootPassword("mdfxrJ68")
               .withNewDataDisk(19)
               .withDataDiskDefaultCachingType(CachingTypes.READ_WRITE)
               .withDataDiskDefaultStorageAccountType(StorageAccountTypes.PREMIUM_LRS)
               .withExistingStorageAccount(storageAccount)
               .withOSDiskSizeInGB(10)
               .withExistingStorageAccount(storageAccount)
               .withSize(VirtualMachineSizeTypes.STANDARD_DS1_V2);


        azure.virtualMachines().create(linuxVM);
VirtualMachineCustomImage customImage=azure.virtualMachineCustomImages().getByResourceGroup(“资源组名称”、“图像组名称”);
可创建的linuxVM=azure.VirtualMachine().define(vmName)
.withRegion(美国西部地区)
.现有资源集团(“rishi”)
.使用现有的主网络(网络)
.withSubnet(“默认”)//在创建时未指定名称时引用默认子网名称
.withPrimaryPrivateIPAddressDynamic()
.不带Primary PublicIP地址()
.withLinuxCustomImage(customImage.id())
.withRootUsername(“centos”)
.withRootPassword(“mdfxrJ68”)
.withNewDataDisk(19)
.withDataDiskDefaultCachingType(CachingTypes.READ_WRITE)
.withDataDiskDefaultStorageAccountType(StorageAccountTypes.PREMIUM\u LRS)
.使用现有的storageAccount(storageAccount)
.带OSDiskSizeingB(10)
.使用现有的storageAccount(storageAccount)
.具有大小(虚拟机类型。标准\u DS1\u V2);
azure.VirtualMachine().create(linuxVM);

HI@Peter Pan-MSFT。谢谢你的答复。。但我的问题是使用ARM获取图像。。上面的示例正在使用服务管理API。。。不是资源管理API。@Sam您可以使用ASM而不是ARM列出图像。请参考我的答案以了解线索。
       VirtualMachineCustomImage customImage = azure.virtualMachineCustomImages().getByResourceGroup("resource_gr_name", "image_name");

       Creatable<VirtualMachine> linuxVM = azure.virtualMachines().define(vmName)
               .withRegion(Region.US_WEST)
               .withExistingResourceGroup("rishi")
               .withExistingPrimaryNetwork(network)
               .withSubnet("default") // Referencing the default subnet name when no name specified at creation
               .withPrimaryPrivateIPAddressDynamic()
               .withoutPrimaryPublicIPAddress()
               .withLinuxCustomImage(customImage.id())
               .withRootUsername("centos")
               .withRootPassword("mdfxrJ68")
               .withNewDataDisk(19)
               .withDataDiskDefaultCachingType(CachingTypes.READ_WRITE)
               .withDataDiskDefaultStorageAccountType(StorageAccountTypes.PREMIUM_LRS)
               .withExistingStorageAccount(storageAccount)
               .withOSDiskSizeInGB(10)
               .withExistingStorageAccount(storageAccount)
               .withSize(VirtualMachineSizeTypes.STANDARD_DS1_V2);


        azure.virtualMachines().create(linuxVM);