DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Programming Azure Blobs With Java

Programming Azure Blobs With Java

Check out how to use the Azure SDK with Java to store your content in the Cloud.

Bruno Terkaly user avatar by
Bruno Terkaly
·
Mar. 10, 16 · Cloud Zone · Tutorial
Like (3)
Save
Tweet
4.82K Views

Join the DZone community and get the full member experience.

Join For Free

I’m producing a series of blog posts that highlights the work I’ve done with an O’Reilly media video course. I will produce several posts a week to support this course, as seen below.

http://bit.ly/bruno-does-linux-data-java

smallslide0

The course is targeted towards developers who want to write Java applications on Linux and host those applications in Azure.

These applications talk to today’s top data stores, including:

  • Azure Tables
  • Azure Blobs
  • Azure Queues
  • SQL Server
  • SQL Database
  • MySQL
  • PostGres
  • DocumentDB
  • MongoDB
  • Cassandra
  • Redis

Using Java to Connect to Azure Blobs

  • Reading and writing blobs is easy with the Azure SDK
  • You will need to:
    • Provision a storage account
    • Reference a container
    • Write code for the blob operations (upload, delete, download, etc)

smallslide001

Slide 1 – Overview

You Can Find the Java Storage SDK

  • You can compile your own jar from the latest sources

smallslide002

Slide 2 – Finding the SDK

The Github Repo With the Java SDK

  • Source code is available
  • We will compile our own Jar file

smallslide003

Slide 3 – Github

Git Clone

  • Downloading the Azure Java Storage SDK

smallslide004

Slide 4 – Downloading the SDK to local dev computer

Maven Compile

  • You will need to install and run Maven
  • Explained in course at top of this post

smallslide014

Slide 5 – Compiling the .java to .class

Using the Jar Utility to Create a JAR File

  • Creating a jar file from all the class files
  • Review
    • Download sources
    • Compile sources
    • Create jar file
    • Add jar file to Eclipse project (future module)

smallslide005

Slide 6 – Creating jar file

Viewing Jar File

  • You can now see the jar file created
  • You may want to copy it to an easier location
    • Like c:\azure-storage-java

smallslide007

Slide 7 – Viewing the jar file

Moved Jar File to New Location

  • Don’t want it too deeply buried

smallslide008

Slide 8 – New jar file location

Creating a New Java Project in Eclipse

  • Obviously, I assume you’ve installed Eclipse
  • Issue a File/New/Java Project

smallslide009

Slide 9 – Installing Eclipse

Filling Out the Connection String

  • We have added BlobManager.java
  • You need to go to the portal to fill out the rest
  • Notice the import statements for the Azure Java Storage SDK

smallslide010

Slide 10 – Adding BlobManager.java

The Azure Portal

  • Notice we have:
    • Storage Account Name
    • Primary Key
  • We will need to paste this into our code

smallslide011

Slide 11 – Azure Portal

Storage Connection String

  • Notice on line 11 and 12 we have storage account name and primary account key pasted
  • Next we will go to try {} block on line 16

smallslide012

Slide 12 – Finished connection string

Connecting to Storage Account

  • Using CloudStorageAccount and CloudBlobClient objects
  • Lines 16 and 17

smallslide013

Slide 13 – Code to connect

Make Sure You Have the azurestorage.jar Properly Referenced

  • It is part of project properties
  • After adding the azurestorage.jar file to project you need to make sure it is part of the Java Build Path.

smallslide015

Slide 14 – Java build Path

azure Java (programming language) Database JAR (file format)

Published at DZone with permission of Bruno Terkaly, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Modernize Legacy Code in Production: Rebuild Your Airplane Midflight Without Crashing
  • Why Is Software Integration Important for Business?
  • Synchronization Methods for Many-To-Many Associations
  • Don't Underestimate Documentation

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo