azure-libraries-for-java/notes/prepare-for-1.0.0-beta5.md

7.8 KiB

Prepare for Azure Management Libraries for Java 1.0.0-beta5#

Steps to migrate code that uses Azure Management Libraries for Java from beta 4 to beta 5 …

If this note missed any breaking changes, please open a pull request.

Create() defaults to Managed Disks#

In VirtualMachine, VirtualMachineScaleSet and VirtualMachineScaleSetVM the OS and data disks getters and withers default to managed disks.

The withers and getters for storage account based (unmanaged) OS and data disks are renamed to include the term unmanaged.

Create() creates unmanaged disks on explicit requests##

Starting in 1.0.0-beta5, if you like to continue to use the storage account based (unmanaged) operating system and data disks, you may use withUnmanagedDisks() in the define() ... create() method chain.

The following sample statement creates a virtual machine with an unmanaged operating system disk:

azure.virtualMachines().define("myLinuxVM")
   .withRegion(Region.US_EAST)
   .withNewResourceGroup(rgName)
   .withNewPrimaryNetwork("10.0.0.0/28")
   .withPrimaryPrivateIpAddressDynamic()
   .withNewPrimaryPublicIpAddress("mylinuxvmdns")
   .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
   .withRootUsername("tirekicker")
   .withSsh(sshKey)
   // Unmanaged disks - uses Storage Account
   .withUnmanagedDisks()
   .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
   .create();

For additional sample code, please see Manage Virtual Machine With Unmanaged Disks ready-to-run sample.

Converting virtual machines with storage account based disks to use managed disks

You can convert a virtual machine with unmanaged disks (Storage Account based) to managed disks with a single reboot.

PagedList<VirtualMachine> virtualMachines = azure.virtualMachines().list();
for (VirtualMachine virtualMachine : virtualMachines) {
    if (!virtualMachine.isManagedDiskEnabled()) {
        virtualMachine.deallocate();
        virtualMachine.convertToManaged();
    }
}

Change Method Names

From To Ref
VirtualMachineScaleSetVM.isOsBasedOnPlatformImage() VirtualMachineScaleSetVM.isOSBasedOnPlatformImage() #1409
VirtualMachineScaleSetVM.getPlatformImage() VirtualMachineScaleSetVM.getOSPlatformImage() #1409
VirtualMachineScaleSetVM.customImageVhdUri() VirtualMachineScaleSetVM.storedImageUnmanagedVhdUri() #1409
VirtualMachineScaleSetVM.osDiskVhdUri() VirtualMachineScaleSetVM.osUnmanagedDiskVhdUri() #1409
VirtualMachine.withOsDisk() VirtualMachine.withSpecializedOsUnmanagedDisk() #1409
VirtualMachine.withOsDiskCaching() VirtualMachine.withOSDiskCaching() #1409
VirtualMachine.withOsDiskSizeInGb() VirtualMachine.withOSDiskSizeInGB() #1409
VirtualMachine.osDiskVhdUri() VirtualMachine.osUnmanagedDiskVhdUri() #1409
VirtualMachine.getPlatformImage() VirtualMachine.getOSPlatformImage() #1409
VirtualMachine.defineNewDataDisk() VirtualMachine.defineUnmanagedDataDisk() #1409
VirtualMachine.withNewDataDisk() VirtualMachine.withNewUnmanagedDataDisk() #1409
VirtualMachine.withExistingDataDisk() VirtualMachine.withExistingUnmanagedDataDisk() #1409
VirtualMachine.withoutDataDisk() VirtualMachine.withoutUnmanagedDataDisk() #1409
VirtualMachine.updateDataDisk() VirtualMachine.updateUnmanagedDataDisk() #1409
VirtualMachine.dataDisks() VirtualMachine.unmanagedDataDisks() #1409
Subscriptions.getByName() Subscriptions..getById() #1396

Change Receiving Variable Type

From To For Method Ref
Observable<Void> Completable SupportDeletingByName.deleteByNameAsync() #1388
Observable<Void> Completable SupportDeletingById.deleteByIdAsync() #1388
Observable<Void> Completable SupportDeletingByGroup.deleteByGroupAsync() #1388
List<DataDiskImage> Map<Integer, DataDiskImage> VirtualMachineImage.dataDiskImages() #1409
List<ResourceT> Map<String, ResourceT> {ResourceCollection}.create(List<Creatable<ResourceT>>)

e.g. VirtualMachines.create(List<Creatable<VirtualMachine>>)
#1381

Change visibility

Name Visibility Note Ref
setInner(T) internal we already documented setInner as "internal use only", making it really internal #1381