InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Python Has Wrapped Itself Around Windows Azure

Posted by Abel Avram on Nov 13, 2008

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
Cloud Computing ,
.NET ,
Architecture
Tags
PaaS ,
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
  1. Back to top

    Thanks!

    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

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?