Using Windows Azure Blob Storage to Store Windows Phone App Data

Introduction

Windows® Azure™ Blob storage service is a key and value store of unstructured data that can be accessed from anywhere in the world via HTTP or HTTPS. The term "blob" is commonly understood to mean "Binary Large OBject." An Azure Storage Account can contain one or more Containers, which are created and named by the user to hold Blobs. It functions like file storage in the cloud. This simple data structure makes blob storage very powerful where files such as images, audios, videos, PDFs, documents, etc. are not only stored very economically but also highly scalable. A single storage account can store hundreds of TBs of blob data. Many of Azure’s customers store hundreds of petabytes. Microsoft SkyDrive - re-launched now as “OneDrive” uses blob storage.

4. Specify a unique name, location and replication for your storage. Replication means – Azure constantly maintains healthy replicas of your data, but it comes at an added cost. So if you do not want your data geo-replicated, you can disable geo-replication. This is called Locally Redundant Storage, and is a 23% to 34% discounted price over geo-replicated storage.

4. Give a proper name to the mobile service and select a new or existing database instance:

Create a Mobile Service

5. Mobile service uses Azure SQL Database, so when you create a mobile service a new database will be created. You can create a new database or use any existing one. In this demo, I am going to create a new database along with its server.

Specify Database Settings

6. In this way a new mobile service with the name “ProfileMobileSvc” will be created.

7. Create the required tables in this new “ProfileMobileSvc_Db” database: Open mobile service “ProfileMobileSvc”, go to Data tab, and select “Add a table” to add “UserProfile” as new table. Add columns: Name, Email, Phone, PictureBlobContainerName, PictureName, PictureBlobUrl, SasQueryString.

Use Server Scripts to Alter the Behavior of “UserProfile” Table Insert

You can register “Server Scripts” in a Mobile Service to perform many operations on data being inserted and updated, including validation and data modification. Create a blob container and blob URL stored in Azure SQL database table column.

You can follow these steps to modify insert and read behavior:

1. Go to newly created “ProfileMobileSvc”.

2. Click on “Data” tab and open “UserProfile” table.

3. For this illustration, you need to customize the default insert behavior by using following scripts:

11. Click save; it will save the user profile and store the blob into the blob container.

12. Verify the blob URL in the Azure SQL table.

Conclusion

In this illustration, I have explained how you can leverage “Azure Mobile Services” to store blob data of Windows Phone 8 applications in Azure blob Storage. You can use this technique to store large amounts of unstructured blob data in Azure, which is readily accessible and more economical.