Вот мой пример кода, как ссылка для вас.
import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.CloudException;
import com.microsoft.azure.credentials.ApplicationTokenCredentials;
import com.microsoft.azure.credentials.AzureTokenCredentials;
import com.microsoft.azure.management.Azure;
import com.microsoft.azure.management.compute.PowerState;
import com.microsoft.azure.management.compute.VirtualMachine;
import okhttp3.logging.HttpLoggingInterceptor;
String clientId = "xxxxx";
String domain = "xxxxx";
String secret = "xxxxx";
AzureEnvironment environment = AzureEnvironment.AZURE;
/*
* Or you can use the code `new AzureEnvironment(String authenticationEndpoint, String managementEndpoint, String resourceManagerEndpoint, String graphEndpoint)`,
* please see http://azure.github.io/azure-sdk-for-java/com/microsoft/azure/AzureEnvironment.html
*/
AzureTokenCredentials credentials = new ApplicationTokenCredentials(clientId, domain, secret, environment);
Azure azure = Azure.configure().withLogLevel(HttpLoggingInterceptor.Level.BASIC).authenticate(credentials).withDefaultSubscription();
// Get VM instance
String resourceGroup = "xxxx";
String vmName = "xxxx";
VirtualMachine vm = azure.virtualMachines().getByGroup(resourceGroup, vmName);
// Start the VM instance async
vm.start();
// Get the power status of the VM instance by polling
PowerState powerState = vm.powerState();
System.out.println(powerState);
Для интерфейсов, используемых в коде выше, пожалуйста, обратитесь к Javadocs http://azure.github.io/azure-sdk-for-java/.
Надеюсь, это поможет.