Tag not monitored by Microsoft.
Azure SDK version problem while crating API
Hey Azure Experts,
I’m working on creating an API to copy a VM image across regions using the Azure SDK for Java. However, I encountered an issue with the com.azure.resourcemanager.compute.models.Image import while using Azure SDK version 2.35.0. It seems like the SDK no longer includes this class or has changed the way VM images are handled.
❓ Issue
I tried using the following import:
import
but it does not exist in the current SDK version.
I searched online and found some older solutions, but they seem to rely on a different SDK version.
🔧 Approach
Here’s the Java code I’m using to copy a VM image from one region to another (East US ➝ West US):
✅ Steps in My Implementation:
1️⃣ Fetch the source image from the resource group. 2️⃣ Create a snapshot from the source image. 3️⃣ Generate a SAS URL for the snapshot. 4️⃣ Copy the snapshot to the target region using the SAS URL. 5️⃣ Create a new VM image in the target region from the copied snapshot.
import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.compute.models.Snapshot;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.SnapshotStorageAccountTypes;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import java.time.Duration;
public class AzureImageCopy {
public static void main(String[] args) {
String subscriptionId = "