Source:
public ImageStatusResult checkImageStatus(AuthenticatedContext ac, CloudStack stack, Image image) { String imageResourceGroupName = azureResourceGroupMetadataProvider.getImageResourceGroupName(ac.getCloudContext(), stack); AzureClient client = ac.getParameter(AzureClient.class); AzureCredentialView acv = new AzureCredentialView(ac.getCloudCredential()); String imageStorageName = armStorage.getImageStorageName(acv, ac.getCloudContext(), stack); try { CopyState copyState = client.getCopyStatus(imageResourceGroupName, imageStorageName, IMAGES_CONTAINER, image.getImageName()); if (CopyStatus.SUCCESS.equals(copyState.getStatus())) { if (StringUtils.isEmpty(armStorage.getCustomImageId(client, ac, stack))) { return new ImageStatusResult(ImageStatus.CREATE_FAILED, ImageStatusResult.COMPLETED); } return new ImageStatusResult(ImageStatus.CREATE_FINISHED, ImageStatusResult.COMPLETED); } else if (CopyStatus.ABORTED.equals(copyState.getStatus()) || CopyStatus.INVALID.equals(copyState.getStatus())) { return new ImageStatusResult(ImageStatus.CREATE_FAILED, 0); } else { int percentage = (int) (((double) copyState.getBytesCopied() * ImageStatusResult.COMPLETED) / copyState.getTotalBytes()); LOGGER.info("CopyStatus, Total:{} / Pending:{} bytes, {}%", copyState.getTotalBytes(), copyState.getBytesCopied(), percentage); return new ImageStatusResult(ImageStatus.IN_PROGRESS, percentage); } } catch (RuntimeException ex) { String msg = String.format("Failed to check the status of the image in resource group '%s', image storage name '%s'", imageResourceGroupName, imageStorageName); LOGGER.warn(msg, ex); return new ImageStatusResult(ImageStatus.IN_PROGRESS, ImageStatusResult.HALF); } }

Target:
public ImageStatusResult checkImageStatus(AuthenticatedContext ac, CloudStack stack, Image image) { String imageResourceGroupName = azureResourceGroupMetadataProvider.getImageResourceGroupName(ac.getCloudContext(), stack); AzureClient client = ac.getParameter(AzureClient.class); AzureCredentialView acv = new AzureCredentialView(ac.getCloudCredential()); String imageStorageName = armStorage.getImageStorageName(acv, ac.getCloudContext(), stack); try { CopyState copyState = client.getCopyStatus(imageResourceGroupName, imageStorageName, IMAGES_CONTAINER, image.getImageName()); if (CopyStatus.SUCCESS.equals(copyState.getStatus())) { if (StringUtils.isEmpty(armStorage.getCustomImageId(client, ac, stack))) { LOGGER.error("The image is not found in the storage."); return new ImageStatusResult(ImageStatus.CREATE_FAILED, ImageStatusResult.COMPLETED); } LOGGER.info("The image copy has been finished."); return new ImageStatusResult(ImageStatus.CREATE_FINISHED, ImageStatusResult.COMPLETED); } else if (CopyStatus.ABORTED.equals(copyState.getStatus()) || CopyStatus.INVALID.equals(copyState.getStatus())) { LOGGER.error("The image copy has been failed with status: {}", copyState.getStatus()); return new ImageStatusResult(ImageStatus.CREATE_FAILED, 0); } else { int percentage = (int) (((double) copyState.getBytesCopied() * ImageStatusResult.COMPLETED) / copyState.getTotalBytes()); LOGGER.info("CopyStatus, Total:{} / Pending:{} bytes, {}%", copyState.getTotalBytes(), copyState.getBytesCopied(), percentage); return new ImageStatusResult(ImageStatus.IN_PROGRESS, percentage); } } catch (RuntimeException ex) { String msg = String.format("Failed to check the status of the image in resource group '%s', image storage name '%s'", imageResourceGroupName, imageStorageName); LOGGER.warn(msg, ex); return new ImageStatusResult(ImageStatus.IN_PROGRESS, ImageStatusResult.HALF); } }