in plugin-azure-server-base/src/main/java/jetbrains/buildServer/clouds/azure/AzureCloudClientBase.java [87:112]
protected T checkAndCreateImage(@NotNull D imageDetails) {
final String profileId = StringUtil.emptyIfNull(myParameters.getParameter("profileId"));
final String sourceId = imageDetails.getSourceId();
final T cloudImage = createImage(imageDetails);
// Try to find existing images
final T image = (T) myImagesHolder.findImage(profileId, sourceId);
if (image != null) {
for (G instance : image.getInstances()) {
cloudImage.addInstance(instance);
}
} else {
try {
final Map<String, AbstractInstance> realInstances = myApiConnector.fetchInstances(cloudImage);
cloudImage.detectNewInstances(realInstances);
} catch (CheckedCloudException e) {
final String message = String.format("Failed to get instances for image %s: %s", sourceId, e.getMessage());
LOG.warnAndDebugDetails(message, e);
cloudImage.updateErrors(TypedCloudErrorInfo.fromException(e));
}
}
myImagesHolder.addImage(profileId, cloudImage);
return cloudImage;
}