public static void test(Subscription subscription) throws Exception {
    String newAvailabilitySetName = "marcinsas";
    AvailabilitySet availabilitySet;

    // Create a new availability set in a new default group
    availabilitySet =
        subscription
            .availabilitySets()
            .define(newAvailabilitySetName)
            .withRegion(Region.US_WEST)
            .withNewResourceGroup()
            .create();

    // Get info about a specific availability set using its group and name
    availabilitySet = subscription.availabilitySets(availabilitySet.id());
    printAvailabilitySet(availabilitySet);

    // Listing availability sets in a specific resource group
    Map<String, AvailabilitySet> availabilitySets =
        subscription.availabilitySets().asMap(availabilitySet.resourceGroup());
    System.out.println(
        String.format(
            "Availability set ids in group '%s': \n\t%s",
            availabilitySet.resourceGroup(), StringUtils.join(availabilitySets.keySet(), ",\n\t")));

    // Delete availability set
    availabilitySet.delete();

    // Delete its group
    subscription.resourceGroups().delete(availabilitySet.resourceGroup());

    // Create a new group
    ResourceGroup group =
        subscription
            .resourceGroups()
            .define("marcinstestgroup")
            .withRegion(Region.US_WEST)
            .create();

    // Create an availability set in an existing group
    availabilitySet =
        subscription
            .availabilitySets()
            .define(newAvailabilitySetName + "2")
            .withRegion(Region.US_WEST)
            .withExistingResourceGroup(group)
            .withTag("hello", "world")
            .withoutTag("hello")
            .create();

    // Get an existing availability set based onb group and name
    availabilitySet =
        subscription.availabilitySets(availabilitySet.resourceGroup(), availabilitySet.name());
    printAvailabilitySet(availabilitySet);

    // Delete the entire group
    subscription.resourceGroups().delete(group.id());
  }
 public static void main(String[] args) {
   try {
     Subscription subscription = Subscription.authenticate("my.azureauth", null);
     test(subscription);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public static void test(Subscription subscription) throws Exception {
    // List provider namespaces
    Map<String, Provider> providers = subscription.providers().asMap();
    System.out.println(
        String.format("Provider namespaces: %s\t", StringUtils.join(providers.keySet(), "\n\t")));

    // List providers
    for (Provider provider : providers.values()) {
      System.out.println(provider.id() + " - " + provider.registrationState());
    }

    if (providers.size() > 0) {
      // Get information about a specific provider
      Provider provider = subscription.providers("microsoft.classicstorage");

      System.out.println(
          String.format(
              "Found provider: %s\n"
                  + "\tRegistration State: %s\n"
                  + "\tAPI versions for resource types:",
              provider.id(), provider.registrationState()));

      for (ResourceType t : provider.resourceTypes().values()) {
        System.out.println(
            String.format("\t\t%s: %s", t.id(), StringUtils.join(t.apiVersions(), ", ")));
      }

      // Get latest API version for a specific resource type
      String resourceType = "storageAccounts";
      System.out.println(
          String.format(
              "\n\t\tLatest version for type %s: %s",
              resourceType, provider.resourceTypes().get(resourceType).latestApiVersion()));

      // Get latest API version for a specific resource type - shortcut
      System.out.println(
          String.format(
              "\n\t\tLatest version for type %s: %s",
              resourceType, provider.resourceTypes(resourceType).latestApiVersion()));
    }
  }