Skip to main content

Posts tagged with 'Azure'

Using Azure blob storage

March 06, 2014 mgroves 0 Comments
Tags: azure blob csharp

Even though I've been using Windows Azure for quite some time, a lot of the functionality is unexplored territory to me.

Recently, I took a look at Azure Blob Storage, and I was surprised by how simple it was.

Blob storage is simply a way to store stuff (mainly files). That's about the long and short of it. Here's how to get started:

  1. Create a new storage service: on your dashboard, click "+ NEW", then Data Services, then Storage. Pick a URL subdomain, region, and subscription. There you go.
  2. In that service, create one or more containers. This is basically an organizational structure, kinda like a folder. Containers can be public or private.
  3. Put stuff in the container. Each item of "stuff" in this container is called a blob, and each of these items have their own URL.

I don't know of a way to directly upload blobs right from the Azure control panel (yet), but it's very simple to do with some C#. Just add Windows Azure Storage to your project with NuGet (Install-Package WindowsAzure.Storage).

You'll need to create a "connection string" to your storage service. The connection string is just:

DefaultEndpointsProtocol=https;AccountName=yourServiceName;AccountKey=yourAccountKey

Where yourServiceName is whatever your named your service. yourAccountKey can be grabbed right from your Azure Dashboard. Click on the service name and then click "Manage Access Keys" at the bottom of the screen. Copy "Primary Access Key" and paste it in there.

Now you're ready to write some C#. Here's a simple class that I wrote that lets you check for existence of a blob (by name), upload a new blob given a name and a stream (from a file uploaded to a web site, for instance), and a way to delete a blob (again, by name).

It's really that simple. Once you upload some files, go back to your Azure Dashboard and take a peek in the container. You'll see all the blobs there, as well as URIs to get to them.

It's so easy, that I've already moved the images for this site (Cross Cutting Concerns) over to Azure Storage (previously I was storing them off-site with traditional hosting).

Windows Azure dashboard blob container

Some drawbacks that I've noticed, and how I dealt with them:

  • You can get a List of blobs using WindowsAzure.Storage, but you can't really get a total count (at least not without iterating through the whole list). So if you are building a tool to manage these blobs, you may need to store some metadata (like name, uri) in a local database or something (which is what I did for this site). I believe there are already a bunch of tools out there to access containers/blobs that you can use as well: you don't have to build your own.
  • There's no "transaction" or "rollback" when doing blob transactions. You'll need to handle that case yourself. In my case, if something goes wrong with other parts of the "transaction", I'll use DeleteIfExists to remove the blob. Not the most elegant, but it works.

 

WordPress on Windows Azure

March 03, 2014 mgroves 0 Comments
Tags: wordpress azure

My esteemed colleague Mark Greenway and I will be doing a presentation on using WordPress in Windows Azure as part of the Microsoft MVP Mentor program. This presentation was prepared for college-aged students in the MVP Mentor program, but anyone is welcome to join!

If you are new to either Azure or to WordPress, then I promise that you'll learn something.

The session will be on Wednesday, March 5th, 2014, at 7pm eastern time. See more details on Facebook.

3XA2DVTTV89G

My friend Mark Greenway introduced me to Brandoo WordPress recently. I had never heard of it, so I thought I would share with you.

I've heard of WordPress, of course. I taught a class where all the labs used WordPress on Azure for three semesters at Capital University. Brandoo WordPress is a branch of WordPress that is designed with Windows Azure in mind. It uses a Microsoft SQL/Azure SQL database instead of MySQL. And, best of all, it's available in the Windows Azure gallery for an easy install.

Brandoo WordPress in the Azure Gallery

Why would you want to use Brandoo instead of plain WordPress? On Azure, MySQL is available through ClearDb. Although my experience with plain WordPress and ClearDb has been pretty good, Azure SQL is a first-class citizen of Azure, with built-in scaling and tooling right through the Azure dashboard.

It does appear as though the Brandoo installation through the Azure gallery is a slightly older release of WordPress. But since WordPress has a self-updating feature built in, that's not really much of an issue.

So, if you use Azure and WordPress, consider giving Brandoo a shot.

Welcome to another "Weekly Concerns". This is a post-a-week series of interesting links, relevant to programming and programmers. You can check out previous Weekly Concerns posts in the archive.

It's Seth Petry-Johnson's birthday this weekend. That doesn't really tie into this week's Weekly Concerns, but I guess you could check out Seth's blog! It will also be David Giard's birthday as well: you should check out his excellent Technology and Friends podcast/TV show. Episode 144 is particularly good.

If you have an interesting link that you'd like to see in Weekly Concerns, leave a comment or contact me.

With my expanded focus, I decided to bring back my weekly link collection under the "Weekly Concerns" banner. Once again, this is just an excuse to avoid the work of having to write a real post.

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter