Introduction
I’m sure by now you have heard of Windows Azure. Now before we get started learning about it, let’s take a look at the definition:
The Windows Azure Platform[2] is a Microsoft cloud platform used to build, host and scale web applications through Microsoft datacenters. Windows Azure Platform is thus classified as platform as a service and forms part of Microsoft's cloud computing strategy, along with their software as a service offering, Microsoft Online Services.
(information taken from WikiPedia)
So in other words, think of cloud computing. I always believe that the best way to learn something is to jump straight into it and fill the gaps as you go. So let’s begin. In this article, I am going to show you how to get started working with Windows Phone 7 and Azure. We are going to download the tools and create a new project starting from File->New Project. After that we will set up our users and add some data with our Windows Phone 7 Emulator.
Watch the video tutorial | Download the slides | Download the source code
Getting Started
The first thing to do is to head over to http://www.microsoft.com/windowsazure/getstarted/ and download the Web Platform Installer 3.0.
Once it is downloaded then you will want to run it and download the Windows Azure Tools for Microsoft Visual Studio 2010 Platform v1.4 as shown below.
Once it is installed, verify it is installed properly by running the setup again. You should see (Installed) next to the version number as shown below :
Now that we have the SDK installed, head over to http://watoolkitwp7.codeplex.com/ and download the Windows Azure Toolkit for Windows Phone 7 by clicking the Download button shown below:
Once that is complete, you will have a new file named WAZToolkitForWP7.Setup.exe. Double click the file to begin installation.
Note: By default it extracts the file to C:\WAZToolkitForWP7. It does not leave anything in your system registry file or make changes to your Windows directory.
After it finishes installing, you will have the following file structure:
Let’s talk about each folder and the contents of it before continuing:
Binaries – Contain the following reference assemblies.
- AspProviders.dll: ASP.NET Providers (Membership, Roles, Profile and Session State Store) for Windows Azure Tables.
- System.Data.Services.Client.dll: Modified version of the OData client library for Windows Phone 7 http://odata.codeplex.com/.
- WindowsPhoneCloud.StorageClient.dll: Azure Storage client library for Windows Phone 7.
Docs – Contains the Readme for the toolkit, with “Getting started information as well as troubleshooting tips/tricks.
Samples – Contains VB and C# Sample Solutions for Windows Phone 7 Azure Applications.
Setup – Contains several templates (.VSIX) that we are going to install in the next step.
Readme.html – Forwards to the documentation found in the “Docs” folder.
Setup.cmd – Runs the following command for us to begin installing the .VSIX project templates and checking to make sure that our computer contains the necessary files to begin developing our own Windows Phone 7 with Azure Applications.
For reference only that command is listed here: @START .\setup\DependencyChecker\ConfigurationWizard.exe .\setup\Dependencies.dep
Let’s go ahead and begin with double clicking on the Setup.cmd file.
Once launched, click Next
then Next again.
It will detect any required software and attempt to download it.
Now it will attempt to install the necessary Windows Phone 7 Cloud Application project templates. Hit install and continue until it is complete.
At this point, we are ready to begin working with Windows Phone 7 and Azure.
Go ahead and load Visual Studio 2010 and select File –> New Project.
At this point, we are going to select “Cloud” then select “Windows Phone 7 Cloud Application”. Let’s give this project a name of “WP7CloudAppSLShow” and select OK.
Note: You may notice that now we have 2 additional “Cloud” templates available. These were installed when we ran the Setup.cmd earlier.
You will now notice that we have an option to enter our Azure login information or use the storage emulator. Since I assume you are starting from scratch, let’s select “Use Storage Emulator” and hit “OK” as shown below.
Note: I had an error my first time running this template. If this happens to you then simply close Visual Studio 2010 and restart it.
If you look inside of Solution Explorer, then you will see 3 projects are created.
WP7CloudAppSLShow – This project specifies to start the Windows Azure storage emulator when running or debugging the Windows Azure Project. It also contains the Roles that you may be familiar with in a standard Azure project.
WP7CloudAppSLShow.Phone – This project is simply a Windows Phone 7 project that will launch the emulator when you run the project.
WP7CloudAppSLShow.Services – This project is simply the web project that contains a valid cert file.
At this point, lets go ahead and run the project. You will notice that the storage emulator and Windows Phone 7 emulator are started.
The Windows Azure Emulator shown below.
The Windows Phone 7 Emulator Shown below:
We will now see Internet Explorer (or whatever browser is set to your default) launched and letting you know “There is a problem with this website’s security certificate.
The reason this dialog is displaying is because the certificate inside the current project has not been signed. In an actual application, you would want a signed certificate.
Go ahead and select “Continue to this website (not recommended)” and you will see our application running.
At this point, let’s switch back over to our Windows Phone 7 Application and click on the WA Toolkit WP7.
The first thing we are going to want to do after launching the application is install the certificate by touching the “Install Certificate” as shown below.
Now that we have the certificate installed, we won’t have any problems working with Azure in this project.
Let’s go ahead and register from inside the Windows Phone 7 Application.
After we are registered, let’s login with the account we just created.
You will notice right off the bat this is a pivot application and you do not have permission to use the tables. This helps secure the application by forcing the user to assign rights.
Let’s go ahead and switch back to our application running in Internet Explorer to fix this. Once inside Internet Explorer, select Log On and enter the Administrator username and password. This information will be displayed on the screen to help you remember what it is.
Once you are logged in, you can click on “User Permissions” then make sure you have a checkbox placed on the users Tables and Blobs as shown below.
Now you can switch back over to your Windows Phone 7 project and log out and log back in. You will now see that you no longer have the message displayed at the bottom of the screen and can create tables, sample data and even blobs now.
Let’s go ahead and create some sample data now by clicking the + located below, entering some data and hitting save.
We can see that this data will be saved if we log out and log back into the application.
We can also switch back over to Internet Explorer and see the new SampleData Table that was created appear.
Conclusion
As you can see, this was very simple to accomplish and we did not have to write any code behind to get a fully working cloud application with Windows Phone 7. If you want to test this without using the Emulator, then you can get a free trial subscription here. I have also found several 30-day no credit card required trials available on the web as well. I encourage you to explore the Visual Studio 2010 project that was created to learn more about Windows Azure and Windows Phone 7.
Michael Crump is an MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.
He shares his findings in his personal blog: http://michaelcrump.net and he also tweets at:@mbcrump