Injustice - Developers Among Us (SciFiDevCon 2024)
Azure and Ruby - Cam Stevenson
1. The New Open Azure & Ruby
November 27, 2012 Lightning Talk
cam@glacetouch.com
Cam Stevenson github: camstevenson
2. The New Open Azure
• Still supports the original Microsoft flavored technologies
• Still has the basic services you’d expect
• Blob storage, tables, queues, etc.
• Now expanded with a decidedly open source set of capabilities
• Pre-packaged Linux virtual machines
• Developer toolkits for node.js, Java, PHP, Python as well as .Net
• Sadly, no Microsoft supplied toolkit for Ruby
3. Azure with Ruby
• There isn’t a Microsoft supplied toolkit for Ruby, but there is an Open
Source one:
• https://github.com/johnnyhalife/waz-storage
• Lets you work with Azure blobs, queues and tables
4. An Example (upload to blob storage)
require 'waz-blobs’
if WAZ::Storage::Base.establish_connection!(:account_name => 'ottawaruby',
:access_key => 'G+gohTOyuXi7DBFQmTmZuxIX2nrZGJLE6KLxTK5GkS/c1kytMgIUiZsMSe9VnLBQ0+vxLVhljhvsHIo6nLhTyw==')
# get a reference to the "root" container, create it if it doesn't exist
container = WAZ::Blobs::Container.find('$root')
if !container
WAZ::Blobs::Container.create('$root')
container = WAZ::Blobs::Container.find('$root')
end
# set public access on this container
container.public_access = WAZ::Blobs::BlobSecurity::Blob
# upload a file, supplying mime type
file_path = 'ottawaruby.html'
upload_file = File.open(file_path, "rb", :encoding => "BINARY")
container.store('ottawaruby.html', upload_file.read, 'text/html')
upload_file.close
end
5. Some tips…
- $root is the root container of a blob storage account
- The stock waz-storage implementation doesn’t support this – my patched one at
https://github.com/camstevenson/waz-storage
- Blob storage doesn’t support a default document (foo.com -> foo.com/index.html). You can work around this
with a 301 redirect
- Azure VMs persist to their backing virtual hard disks (VHDs), so they don’t disappear when you shut down,
only when you delete them
- Added bonus: you can move VHDs between local machines with Hyper-V and Azure
- Aside from the “commodity” services, MS has been adding new, really useful capabilities such as Azure Mobile
Services
- Marc Gagne @ Microsoft is happy to be contacted with Azure questions, etc: marc.gagne@microsoft.com