2

I am writing an Android application which leverages the Microsoft Azure cloud for

  • Page blobs (Blob service)
  • Relational Database tables (SQL Azure)
  • Queues

Everything looked great, however I've hit a pretty solid looking technical brick wall which may prevent our use of AZURE; namely, The Microsoft Java Azure SDK use of JAXB.

  1. JAXB not provided by Android (and is very large if you want to bundle it)
  2. The Dalvik VM is not capable of executing the reflective calls in JAXB
  3. Cannot be compiled into dex as JAXB uses javax package structure, working around with --core-library almost certainly guarantees failure further down the line.

Other Azure Java SDK maven dependencies which also define classes in the protected javax package structure:

  • javax.xml.bind jaxb-api
  • javax.inject javax.inject
  • com.sun.jersey jersey-core
  • stax stax-api
  • javax.activation activation
  • javax.mail mail

It seems to me that effectively this prevents the use of Azure services to back an Android application (for me) as writing my own android friendly API for interrogating Azure is beyond the scope of this project.

Has anyone had experience with consuming Azure services on Android through some other mechanism?

il_guru
  • 8,383
  • 2
  • 42
  • 51
Syntax
  • 2,155
  • 2
  • 23
  • 34

3 Answers3

3

I would suggest hiding most of the azure specific functionality behind a RESTful web service hosted on a Azure WebRole (using WCF). Here is a tutorial that covers setting up Azure to provide a basic RESTful webservice. Your Android client can then use HTTP/JSON/XML to communicate with Azure in a standards compliant manner.

Your goal would be to have the web service communicate with the backend Azure components, rather than the Android client communicate with them directly, something like:

Android -> Azure RESTful WebRole -> Blob, SQL DB, Queue, Worker Role

Although in some cases you may want your Android client to communicate directly with the Blob storage (via the Blob REST interface)

Android -> Blob
&
Android -> Azure RESTful WebRole -> Blob, SQL DB, Queue, Worker Role

If the WebRole is too expensive you can replace it with a cheaper RESTful Azure website as covered in this tutorial.

Something else to consider with your intended approach of communicating directly with the backend Azure components is that your Android client will need to store your Azure account key, which is essentially the same as handing your account password to people using your Android client... ie a bad idea.

Rob
  • 4,733
  • 3
  • 32
  • 29
  • Your comment around the account key is particularly helpful, I had intended to obfuscate it alongside the Android in-app billing public key however you are correct the security implications of leaking the Azure account key is far worse. – Syntax Nov 23 '12 at 05:15
  • After looking at your suggestions this definitely looks like a good way to solve the SDK problem and also increases security significantly by moving my account key into server side code (rather than obfuscating it on the Client). Thank you Rob. – Syntax Nov 23 '12 at 07:37
0

1) Microsoft doesn't use JAXB. Java servers and clients use JAXB to use SOAP web services.

One alternative is to try different SOAP libraries. For example:

2) Another, perhaps better approach, might be to invoke Azure with REST instead of SOAP:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • The Microsoft Azure Java SDK has a direct dependency on JAXB - https://github.com/WindowsAzure/azure-sdk-for-java/blob/master/microsoft-azure-api/pom.xml – Syntax Nov 22 '12 at 07:16
  • Apologies, it is the jaxb-api element that the SDK depends on which is only around 100kb in size. – Syntax Nov 22 '12 at 07:46
  • Looks like they may be using JAXB for the reasons discussed here: http://176.34.122.30/blog/2009/01/12/rest-web-services-with-jaxb-jax-rs-and-sun-jersey/ – Syntax Nov 22 '12 at 10:56
  • 1
    Look - Microsoft doesn't exactly have a strong commitment to support a competing language (Java vs. C#) on a competing Platform (Android vs. Windows Phone). But it doesn't matter. Azure is based on *WEB SERVICES*. And the whole *POINT* of "web services" is to be language- and platform-agnostic! So if you don't like the Microsoft-provided library, explore alternatives. And if you want everything wrapped up in a neat little package for you ... then use C# and Visual Studio. IMHO... – paulsm4 Nov 22 '12 at 20:33
  • Thanks for your opinion. I think MS would actually have many reasons to support the use of their Azure platform everywhere. Microsoft makes their money on Azure's use, the more users they have the more money they make. Personally so that I can maximize the performance of my product and minimize the upfront and ongoing cost I would ideally like my Azure Java SDK to work 'out of the box' on Android, as obviously that allows me to focus on things that are more domain specific. – Syntax Nov 23 '12 at 00:42
  • Look dude, don't babble about"maximizing performance of my product and minimize ongoing cost...". The fact is, apparently the SOAP version of the Microsoft SDK doesn't work for you. Fine. You have alternatives. Like REST (instead of SOAP). Or using different, 3rd party Java SOAP libraries. Or, probably ideal, using *other, different* Microsoft tools to talk to Azure (like MSVS and C#). Just stop wishing for Unicorns and Fairies ... or for an all-Microsoft, all-Java solution. IMHO... – paulsm4 Nov 23 '12 at 01:38
  • Relax, there is no need to be rude. I'm not babbling, those are genuine concerns; I don't want to write and maintain code that I don't have to. The Microsoft Java Azure SDK is not SOAP based, it is REST based, which leaves me wondering how to make sense of your most of your comments. Establishing my options was part of asking this question, Rob's suggestion above is a good example of this as his comments highlighted a security oversight in my approach which renders the Java SDK's dependencies a non-issue for the Android layer of the application. – Syntax Nov 23 '12 at 07:35
0

Currently, Windows Azure SDK for Java does not support Android. But since it is open source, you can pretty much do it yourself if you want. The source code is at

https://github.com/WindowsAzure/azure-sdk-for-java

Albert Cheng
  • 657
  • 6
  • 17
  • Windows Azure has recently announced the Mobile services feature of Azure (still a preview). This should greatly simplify this for any developers looking to leverage Azure for their Mobile applications. I suggest this as a good place to start for most small to medium scale applications. – Syntax Mar 19 '13 at 06:56