RVP

Getting Started with Web Sites on Windows Azure

On April 24, 2013, in Azure, by admin

Creating a new website has never been easier.  With just a few clicks in Windows Azure you can have a new website up and running, and then with just a few more you can create a brand new WordPress blog.  If you haven’t guessed by now this site is running WordPress on Windows Azure.  I am going to run through how to set up a WordPress blog and to set up the DNS in order to point your domain to it.

Setting up the Site

First, log into your Azure Management Portal and click the add button at the bottom of the screen.  From there, click Computer -> Web Site -> From Gallery, which will open up a new window.  If you want to just create a simple site you would choose quick create or custom rather than from gallery.

Create New Website

Once you click on From Gallery, a new window will come up, and then select the WordPress option and click next.  The next page will have you create a new URL and database and also select what region you want that housed in.  Accept the EULA for MySQL and click create.

Once your site is up and running you can navigate to it and go through the “Famous five minute WordPress installation process.”

newsite

Setting up a custom URL

If you want to add a custom URL to your new WordPress site, you must scale your site from a free model to a shared model.  In order to do that you must first buy a domain name from your friendly neighborhood domain registrar.  I use GoDaddy, but there are many other options out there.  Once you have that purchased,  log back into the Azure management portal and navigate to the dashboard for your site.  Then click on the scale tab, select shared, and click save.

Next, move over to the configure tab.  You should see a button for managing domains.  Click that and a pop up comes up that tells you exactly what you need to do if you read all the fine print.  At the bottom of the window you should see the IP address that you need for your A records. Copy that address and navigate over to your domain registrar and add your A record.

manageDomains

That record takes few hours to update and a day at most.  Once your A record propagates, go back to your Azure management portal and add the domain to the list.  Azure will verify that the A record exists before allowing you to continue.  That will take care of the base URL ex. rivercityprogrammer.com.  If you want to put the www in front you must add the awverify.www and www CNAME records to your DNS zone.  And again, wait for the zone to propagate. Then go back to the management portal and add the full www domain to the domain list.  After that you are good to go.

Summary

  • Using Azure allows you to quickly create websites
  • Combine Azure websites with the WordPress installation and you can be up and running in minutes
  • Adding a custom domain to your site may take a few hours for all the records to propagate, but it is very easy to set up.
Tagged with:  
RVP

Azure Table Storage: Taking Your Data to the Cloud

On April 11, 2013, in Azure, by admin

Azure provides a whole host of options to store your data. The most common one that everyone knows and loves is Azure SQL. But there are other options available such as table storage or blob storage. For now we are just going to focus on the table storage.

What is Table Storage?

Table storage is the Azure NoSQL offering. For those not familiar with NoSQL it is not the same as a traditional relational database. There is no relationship between different elements. I’ve heard it described as kind of like excel. None of the rows are really related to each other in any hard and fast manner, and each row can look very different from every other row. I think that is an excellent explanation.

Why Table Storage?

Simplicity. Sometimes you just need an easy way to store some data, and a full-fledged RDMS is just too much. You can put whatever you want in Azure table storage without any worry that it doesn’t really fit in a table.

How to use it

The first step would to create you storage container in Azure management portal. By selecting New -> Data Services -> Storage -> Quick Create and then enter the name for you storage account. Below you can see I created an account named ‘tothecloud’

Add new storage account

We will need one other thing from the Azure management studio and that is an access key. Think of your storage account name (tothecloud) and the access key as username and password to get at your storage account. Once your storage account is created and you click on the account to go to the dashboard, at the bottom you should see a button to manage access keys. If you click on that button you will get a screen that looks like the following

Manage Access Keys

Normally you would not share these with the world, but by the time you read this I will have deleted and or regenerated the keys. Both of these keys are available to use can be used interchangeably. They give you two in case the first one gets compromised you can substitute the new one, and then regenerate the compromised one. They really don’t recommend regenerating both at the same time so that there is no down time.

And that is pretty much all you have to do from the portal. From here we are going to be switching to our C# code.
First let’s look how to put a record in table storage and then we’ll look at how to get things out.

Adding to table storage

  StorageCredentials creds = new StorageCredentials("tothecloud", "<your storage account key>");
  CloudStorageAccount account  = new CloudStorageAccount(creds, false);

  CloudTableClient tableClient = account.CreateCloudTableClient();
 
  CloudTable table = tableClient.GetTableReference("people");
  table.CreateIfNotExists();
 
  Person p = new Person {
     PersonId = 1,
     Name = "tom",
     Age = 28,
     PartitionKey = "people",
     RowKey = "1"
  };
 
   TableOperation insertOp = TableOperation.Insert(p);
   table.Execute(insertOp);

In this example we are adding to our table storage account a Person object. Our person object isn’t anything fancy except that it implements the ITableEntity interface. Which requires, among other things, PartitionKey and RowKey which are needed by Table storage to find the object you put in there. This must be a unique pair. You cannot have duplicates or Azure Table storage will throw an error. Now let’s take a quick walk through the code.

We start off by declaring some credentials using our storage account name, and our account key that we copied earlier. We then take those creds and create a new CloudStorageAccount, the second parameter denotes whether or not we want to use https. We then, using our account, create a cloud table client, and then get a reference to our table named people. If the table doesn’t exist we go ahead create it. After defining our person object, we create a table operation for the insert and execute it against the table. Very simple. I didn’t define any schema at all in my table storage container.

Now that we have something in there, how do we get it out?

Selecting From Table Storage

   StorageCredentials creds = new StorageCredentials("tothecloud", "<your storage account key>");
   CloudStorageAccount account = new CloudStorageAccount(creds, false);
   CloudTableClient tableClient = account.CreateCloudTableClient();

   CloudTable table = tableClient.GetTableReference("people");
   table.CreateIfNotExists();

   TableQuery<Person> query = new TableQuery<Person>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "people")); 

   IEnumerable<Person> results = table.ExecuteQuery(query);

Just as in the first example we get our credentials, account, and table. After that things get a little interesting. We are creating a TableQuery based on person, and you can use whatever property of person that you want. In this case I want to get everything from the people table. So I’m taking everything where the PartitionKey equals people. After I have my query, I run that against my table and get back an enumerable list of People. From there you can do work with the set as you normally would.

Limitations

As with any solution Azure table storage does have some limitations. This isn’t a full fledged relational database. You can relate items in your container, however there is no hard link. So if you need real foreign keys, then you may want to look at SQL Azure. Along that same line there are no indexes, so some queries can take some time to complete when you have a lot of data in a partition.

Another limitation is that the objects that you are uploading into Azure Table storage have to be flat. You can have an object of simple types, but you cannot have complex types as a property of your object. So in my example above if I had another class named Address. I could not use that inside my person object. So everything has to be flat, which is a bit different from other NoSQL options.

So just like any technology make sure you weigh your pros and cons.

Summary

  • Azure Table Storage is the Azure NoSQL option for cloud storage
  • Azure Table storage is a fast and easy way to get storage for your application
  • There are no foreign keys or indexes in table storage
  • All objects must be flat
  • You can get all the Azure dlls from nuget
  • You can sign up for a Windows Azure account by clicking the link on the right!

There are other APIs available for a lot of other languages other than .Net out there that will allow you to take advantage of Azure table storage and all it has to offer. Many of these APIs simply wrap the REST table storage interface.

This post is also posted at TCSC.com

Tagged with:  
RVP

I am speaking at the Microsoft Visions Conference

On February 25, 2013, in Azure, HTML5, Speaking, by admin

Mark your calendars now for the Microsoft Visions Conference scheduled on February 20, 2013.

I will be giving a presentation on HTML5 and Azure and how you can leverage the Azure platform to quickly build your HTML5 website using Azure table storage.

There is something for everyone, whether you are a developer, business analyst, or even an executive. This event will be held at the Microsoft office in in Glen Allen, VA.

The Microsoft Visions Conference is sponsored by TCSC, go ahead and register today!

Tagged with: