Created
March 18, 2016 02:59
-
-
Save m-moris/b74651b5d50badf9f758 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.autorest; | |
import java.io.IOException; | |
import com.microsoft.azure.CloudException; | |
import com.microsoft.azure.credentials.ApplicationTokenCredentials; | |
import com.microsoft.azure.management.compute.ComputeManagementClient; | |
import com.microsoft.azure.management.compute.ComputeManagementClientImpl; | |
import com.microsoft.azure.management.compute.models.VirtualMachine; | |
import com.microsoft.rest.ServiceCall; | |
import com.microsoft.rest.ServiceCallback; | |
import com.microsoft.rest.ServiceResponse; | |
import okhttp3.logging.HttpLoggingInterceptor; | |
public class App3 { | |
public static void main(String[] args) throws CloudException, IllegalArgumentException, IOException, InterruptedException { | |
String subscriptionId = "<<your subscription id>>"; | |
String tenantId = "<<your tenant id>>"; | |
String clientId = "<<your client id>>"; | |
String clientKey = "<<your client key>>"; | |
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials( | |
clientId, tenantId, clientKey, null); | |
ComputeManagementClient client = new ComputeManagementClientImpl(credentials); | |
client.setSubscriptionId(subscriptionId); | |
client.setLogLevel(HttpLoggingInterceptor.Level.BODY); | |
String rg = "your resource-group-name"; | |
String rs = "your vm name"; | |
ServiceCallback<VirtualMachine> serviceCallback = new ServiceCallback<VirtualMachine>() { | |
@Override | |
public void failure(Throwable t) { | |
System.err.println("failed"); | |
} | |
@Override | |
public void success(ServiceResponse<VirtualMachine> result) { | |
VirtualMachine vm = result.getBody(); | |
System.out.println(vm.getId()); | |
} | |
}; | |
ServiceCall async = client.getVirtualMachinesOperations().getAsync(rg, rs, "instanceview", serviceCallback); | |
System.out.println("done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment