Azure Service Management APIs: The Old APIs That Works

After the initial bad experience with the new Azure Resource Management APIs, I took a different approach – try the old Service Management APIs. While transitioning from old system to new system, the old one may still be the best for an unexpected long period of time. Like VMware vSphere Client, VMware has declared end of life many times, but it’s still the favorite for most customers, while the future Web Client remains “future” since 2011.

There are actually some good documentation on using the old APIs. One of them is this “Getting Started With the Azure Java Management Libraries”. Following the tutorial is mostly straight forward, even though I don’t use the recommended Eclipse IDE with Maven. I had been using Eclipse for many years but found it could not kept up the pace after IBM slowed its involvements there, thus switched to NetBeans.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

To run the first sample is not very hard, but I did get into glitches that were mostly caused by the dependencies. Somehow there are many different packages in the namespace, and both the old and new management APIs are there. Even worse, some Java class names are exactly the same. That could end up to cases in which you think you got the right classes but you could not find the methods as shown in the sample. Unless you know exact package name, you know it’s a different class. But for newcomers, they all look the same. :)

So a simple way to avoid the problem is to simply copy what I have as the pom.xml for your Maven project.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

Here is the sample to list regions. Please change the subscription id to yours and upload a certificate as described following the code.

package org.doublecloud.azuredemo;
import java.util.ArrayList;
public class ClassicAzureListRegion
  public static void main(String[] args) throws Exception
    Configuration config = ManagementConfiguration.configure(
      new URI(""), // management api endpoint 
      "800d452f-5fcb-4151-97ec-bf748fb12ea0", // subscriptionId
      "keystore.jks", // path to the JKS file
      "password", // password for the JKS
    ManagementClient client = ManagementService.create(config);
    LocationsListResponse response = client.getLocationsOperations().list();
    ArrayList<LocationsListResponse.Location> locations = response.getLocations();
    // print out each region name
    for(LocationsListResponse.Location location : locations)

Before you run the code, you want to create certificate and upload it to your Azure account. Working with the class GUI for upload the certificate is quite simple. Just click on the Settings, and you won’t miss it.

Here are a few commands for you to create keystore and certificate, assuming you have JDK installed already. You should change the path to the JDK per your installation.

"c:\Program Files\Java\jdk1.8.0_31\bin\keytool.exe" -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
"c:\Program Files\Java\jdk1.8.0_31\bin\keytool.exe" -exportcert -alias selfsigned -file certForAzure.cer -keystore keystore.jks

BTW, if you want to change your password after creating the keystore, you can use the following command. If you use the same keystore, don’t forget to change the password in the source code accordingly.

"c:\Program Files\Java\jdk1.8.0_31\bin\keytool.exe" -storepasswd -keystore keystore.jks

You can place the keystore.jks file in the project home of the above program. For the certForAzure.cer file, you can delete it after you uploading it to Azure.

After you running the program, you should see the same as I did here:

East US
Central US
North Europe
West Europe
Southeast Asia
Japan West
Japan East
This entry was posted in Cloud Computing, Software Development and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Elsa
    Posted September 19, 2016 at 4:18 pm | Permalink

    Hi Steve! Thanks for the informative articles. I have a simple question for which I cannot somehow find answer – how do I list Virtual Machines?

  2. Posted September 19, 2016 at 5:56 pm | Permalink

    Hi Elsa,

    Good to hear from you. You mean how to list the virtual machines from Azure?


  3. Elsa
    Posted September 20, 2016 at 2:38 pm | Permalink

    yes! What APis do I need to run in the old set (or new for that matter). I thought this was goign to take me no more than 15 mins to figure out :-/

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.