So I have an idea of what I am going to build,  I know that I want it to run on both Windows Phone 8 and Windows 8. The next step is to ponder about the backend that ties it all together. Now when it comes to applications there are so many ways to solve a problem some better than others, but the first thing that popped into my brain was Azure. One backend to rule them all Smile so basically now to think about what information I want to store and how its all going to work. I will put in a disclaimer here in that while I want to make a robust flexible storage mechanism, I am most likely going to make some short cuts due to the time line. Here are the entities I have identified:

 

User
LoginID Login ID from ACS
UserName Users Unique Name to improve anonymity
LastLocation The last reported location of the user
LastLocation Time The time of the last reported location
PictureURL The url on Azure storage,

 

 

Event
OwnerID Creator of the event
EventName Name of the event
EventDescription Description of the event and instructions for the event. This field will take urls etc if links are required.
Location The location of where the flash mob will take place
PictureURL Icon for the Mob
DateTime Date and Time of the mob

 

EventAttendees
UserID ID of the user Attending
EventID The event that they are attending
Timestamp When they accepted

 

UserFriends
UserID UserID of main user
UserID UserID of the friend
TimeStamp Date Friendship added

 

Please excuse my archaic db design this is simple enough for me to push out uber quickly and spurt out some stored procs to do the heavy lifting for me. Yes I could have also used Mobile services to do this all for me but that would have been too easy and this was a bit of a learning expedition.

Now for the fun part building it, all we need to support the following functions for the service:

1. Register a new user, here we will leverage a persons Windows Live ID to create a new user or to login to the system.

2. Add new event

3. Get list of events near you

4. Get friends events

5. Add Event

 

Building my data.

First things first to create a new Azure application and Database with some blob storage for photos and videos. To create the Azure Data storage was fairly simple once you have signed up for azure you click on the DB icon and create a new database. You specify a server and tada!!! Now to do some dev work, I am using Visual Studio 2012 for pretty much everything so I created a new Database project and connected it to the provided connection strings in the Server Explorer. Now one thing you need to remember is that you need to update the target platform to SQL Azure because if you don't and try to publish it shouts at you in a stern voice. 

One of the things you also need to do is allow access for the IP of the machine that you are doing the development with. Fairly simple just try to connect it will fail and tell you the IP address its using and just add that address to the allowed IP addresses. If you IP changes you can put a range in but I am paranoid so I am going to update the allowed list when I am developing.

Now you should be able to publish and connect to your db easily, I pretty much just added the table items and stored proc items and published them to SQL Azure and tada was pretty much done.

I will cover the wiring up in my next post.

Authentication

Next what I want to do is implement Access Control Service for Azure which will allow me to provide various mechanisms of logging in for a user. This turned our to be much simpler than I expected. Azure mobile services does the majority of the heavy lifting for you. So what I did was I went to Azure management console added a new Mobile service. As below:

Addmobile

Once the service is created then you can navigate to the quick start page and follow the instructions (see below). Ultra simple and took me about 10 minutes to get it up and running.

Addmobile

In summary Azure mobile services Rock!!!! I still have a ton of work to do in the next post I will go into the exposing the web service and consuming it with the Windows Store App and Windows Phone 8 apps and start creating the screens. I hope this helps.

 

Related Resources:

http://www.windowsazure.com/en-us/develop/net/how-to-guides/sql-database/

http://www.windowsazure.com/en-us/develop/net/how-to-guides/access-control/

http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-users-wp8/