InfoQ

News

Python Has Wrapped Itself Around Windows Azure

Posted by Abel Avram on Nov 13, 2008

Community
.NET,
Architecture
Topics
Cloud Computing
Tags
Python ,
Microsoft

Sriram Krishnan, a Microsoft Program Manager, has written a Python wrapper for Windows Azure Data Storage. Python is one of the languages supported by Windows Azure.

According to Microsoft's Azure web site, Python is one of the tools and languages to be supported by Windows Azure:

Windows Azure is an open platform that will support both Microsoft and non-Microsoft languages and environments. Windows Azure welcomes third party tools and languages such as Eclipse, Ruby, PHP, and Python. ...

Millions of developers worldwide already use the .NET Framework and the Visual Studio development environment. Utilize those same skills to create cloud-enabled applications that can be written, tested, and deployed all from Visual Studio. In the near future developers will be able to deploy applications written on RubyOn Rails and Python as well.

Sriram has written a Windows Azure data storage wrapper in Python and has placed the code on GitHub. Storing/retrieving data is done as in the following example:

conn = WAStorageConnection(DEVSTORE_HOST, DEVSTORE_ACCOUNT, DEVSTORE_SECRET_KEY)
    for (container_name,etag, last_modified ) in  conn.list_containers():
        print container_name
        print etag
        print last_modified
    conn.create_container("testcontainer", False)
    conn.put_blob("testcontainer","test","Hello World!" )
    print conn.get_blob("testcontainer", "test")

Signing-in is done as in the next example:

def _get_auth_header(self, http_method, path, data, headers):
   # As documented at http://msdn.microsoft.com/en-us/library/dd179428.aspx
   string_to_sign =""

#First element is the method
   string_to_sign += http_method + NEW_LINE

   #Second is the optional content MD5
   string_to_sign += NEW_LINE

   #content type - this should have been initialized atleast to a blank value
   if headers.has_key("content-type"):
    string_to_sign += headers["content-type"]
   string_to_sign += NEW_LINE

   # date - we don't need to add header here since the special date storage header
   # always exists in our implementation
   string_to_sign += NEW_LINE

   # Construct canonicalized storage headers.
   # TODO: Note that this doesn't implement parts of the spec -
   # combining header fields with same name,
   # unfolding long lines and trimming white spaces around the colon
   ms_headers =[header_key for header_key in headers.keys()
   if header_key.startswith(PREFIX_STORAGE_HEADER)]
   ms_headers.sort()
   for header_key in ms_headers:
    string_to_sign += "%s:%s%s" % (header_key, headers[header_key], NEW_LINE)

   # Add canonicalized resource
   string_to_sign += "/" + self.account_name + path
   utf8_string_to_sign = unicode(string_to_sign).encode("utf-8")
   hmac_digest = hmac.new(self.secret_key,
    utf8_string_to_sign,
    hashlib.sha256).digest()
   return base64.encodestring(hmac_digest).strip()

It looks like Microsoft's plans with Windows Azure surpass Google's offering. Currently, Google's App Engine is supporting just Phyton, but there are plans to support more languages in the future, according to Google.

 

Thanks! by Sriram Krishnan Posted Nov 15, 2008 3:24 AM
  1. Back to top

    Thanks!

    Nov 15, 2008 3:24 AM by Sriram Krishnan

    Thanks for the post. To clarify, the second bit of the code is *inside* the client library. Normal users don't need to see it or write anything like it. I posted it to illustrate how signing can be done for users planning on writing client libraries for other languages.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.