Azure management libraries for Java generally available now

Veröffentlicht am 25 April, 2017

Principal Program Manager, Azure Developer Experience

Today, we are announcing the general availability of the new, simplified Azure management libraries for Java for Compute, Storage, SQL Database, Networking, Resource Manager, Key Vault, Redis, CDN and Batch services.

Azure Management Libraries for Java are open source - https://github.com/Azure/azure-sdk-for-java.

Service | feature Generally available Available as preview Coming soon

Compute

Virtual machines and VM extensions
Virtual machine scale sets
Managed disks

 

Azure container services
Azure container registry

Storage

Storage accounts

 

Encryption

SQL Database

Databases
Firewalls
Elastic pools

 

 

Networking

Virtual networks
Network interfaces
IP addresses
Routing table
Network security groups
DNS
Traffic managers

Load balances
Application gateways

 

More services

Resource Manager
Key Vault
Redis
CDN
Batch

App service - Web apps
Functions
Service bus

Monitor
Graph RBAC
DocumentDB
Scheduler

Fundamentals

Authentication - core

Async methods

 

Generally available means that developers can use these libraries in production with full support by Microsoft through GitHub or Azure support channels. Preview features are flagged with the @Beta annotation in libraries.

In Spring 2016, based on Java developer feedback, we started a journey to simplify the Azure management libraries for Java. Our goal is to improve the developer experience by providing a higher-level, object-oriented API, optimized for readability and writability. We announced multiple previews of the libraries. During the preview period, early adopters provided us with valuable feedback and helped us prioritize features and Azure services to be supported. For example, we added support for asynchronous methods that enables developers to use reactive programming patterns. And, we also added support for Azure Service Bus.

Getting Started

Add the following dependency fragment to your Maven POM file to use the generally available version of the libraries:

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure</artifactId>
    <version>1.0.0</version>
</dependency>

Working with the Azure Management Libraries for Java

One Java statement to authenticate. One statement to create a virtual machine. One statement to modify an existing virtual network ... No more guessing about what is required vs. optional vs. non-modifiable.

Azure Authentication

One statement to authenticate and choose a subscription. The Azure class is the simplest entry point for creating and interacting with Azure resources.

Azure azure = Azure.authenticate(credFile).withDefaultSubscription();

Create a Virtual Machine

You can create a virtual machine instance by using the define() … create() method chain.

VirtualMachine linuxVM = azure.virtualMachines()
  .define(linuxVM1Name)
  .withRegion(Region.US_EAST)
  .withNewResourceGroup(rgName)
  .withNewPrimaryNetwork("10.0.0.0/28")
  .withPrimaryPrivateIpAddressDynamic()
  .withNewPrimaryPublicIpAddress(linuxVM1Pip)
  .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
  .withRootUsername(“tirekicker”)
  .withSsh(sshkey)
  .withNewDataDisk(100)
  .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
  .create();

Update a Virtual Machine

You can update a virtual machine instance by using an update() … apply() method chain.

linuxVM.update()
        .withNewDataDisk(20,  lun,  CachingTypes.READ_WRITE)
        .apply();

Create a Virtual Machine Scale Set

You can create a virtual machine scale set instance by using another define() … create() method chain.

VirtualMachineScaleSet vmScaleSet = azure.virtualMachineScaleSets()
  .define(vmssName)
  .withRegion(Region.US_EAST)
  .withExistingResourceGroup(rgName)
  .withSku(VirtualMachineScaleSetSkuTypes.STANDARD_D5_V2)
  .withExistingPrimaryNetworkSubnet(network, "subnet1")
  .withExistingPrimaryInternetFacingLoadBalancer(publicLoadBalancer)
  .withoutPrimaryInternalLoadBalancer()
  .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
  .withRootUsername("tirekicker")
  .withSsh(sshkey)
  .withNewDataDisk(100)
  .withNewDataDisk(100, 1, CachingTypes.READ_WRITE)
  .withNewDataDisk(100, 2, CachingTypes.READ_ONLY)
  .withCapacity(10)
  .create();

Create a Network Security Group

You can create a network security group instance by using another define() … create() method chain.

NetworkSecurityGroup frontEndNSG = azure.networkSecurityGroups().define(frontEndNSGName)
    .withRegion(Region.US_EAST)
    .withNewResourceGroup(rgName)
    .defineRule("ALLOW-SSH")
        .allowInbound()
        .fromAnyAddress()
        .fromAnyPort()
        .toAnyAddress()
        .toPort(22)
        .withProtocol(SecurityRuleProtocol.TCP)
        .withPriority(100)
        .withDescription("Allow SSH")
        .attach()
    .defineRule("ALLOW-HTTP")
        .allowInbound()
        .fromAnyAddress()
        .fromAnyPort()
        .toAnyAddress()
        .toPort(80)
        .withProtocol(SecurityRuleProtocol.TCP)
        .withPriority(101)
        .withDescription("Allow HTTP")
        .attach()
    .create();

Create a Web App

You can create a Web App instance by using another define() … create() method chain.

WebApp webApp = azure.webApps()
    .define(appName)
    .withRegion(Region.US_WEST)
    .withNewResourceGroup(rgName)
    .withNewWindowsPlan(PricingTier.STANDARD_S1)
    .create();

Create a SQL Database

You can create a SQL server instance by using another define() … create() method chain.

SqlServer sqlServer = azure.sqlServers().define(sqlServerName)
    .withRegion(Region.US_EAST)
    .withNewResourceGroup(rgName)
    .withAdministratorLogin("adminlogin123")
    .withAdministratorPassword("myS3cureP@ssword")
    .withNewFirewallRule("10.0.0.1")
    .withNewFirewallRule("10.2.0.1", "10.2.0.10")
    .create();

Then, you can create a SQL database instance by using another define() … create() method chain.

SqlDatabase database = sqlServer.databases().define("myNewDatabase")
    .create();

Sample Code

You can find plenty of sample code that illustrates management scenarios (69+ end-to-end scenarios) for Azure.

Service Management Scenario
Virtual Machines
Virtual Machines - parallel execution
Virtual Machine Scale Sets
Storage
Networking
Networking – DNS
Traffic Manager
Application Gateway
SQL Database
App Service – Web apps on Windows
App Service – Web apps on Linux
Functions
Service Bus
Resource Groups
Redis Cache
Key Vault
CDN
Batch

Start using Azure Management Libraries for Java today!

Start using these libraries today. It is easy to get started. You can run the samples above.
 
As always, we like to hear your feedback via comments on this blog or by opening issues in GitHub or via e-mail to Java@Microsoft.com.
 
Also. You can find plenty of additional info about Java on Azure at http://azure.com/java.