Windows front-end developers have enough on their plates simply migrating from Windows 32 desktop and Web apps...
The cost of teaching teams new back-end coding skills for user authentication and authorization with Microsoft Accounts (formerly Live IDs) could be the straw the breaks the camel's back. Add to that messaging with Windows Notification Services (WNS), email and SMS as well as structured storage with Windows Azure SQL Databases (WASDB) and targeting Windows 8 and Azure: Microsoft's legacy escape route, and it all becomes a bit much.
To ease .NET developers into this brave new world of multiple devices ranging from Win32 legacy laptops to touchscreen tablets and smartphones, Microsoft's Windows Azure team released a Windows Azure Mobile Services (WAMS) Preview. The initial release supports Windows Store apps (formerly Windows 8 applications) only; Microsoft promises support for iOS and Android devices soon.
The release consists of the following:
- A Mobile Services option added to the new HTML Windows Azure Management Portal generates the back-end database, authentication/authorization, notification and server-side scripting services automatically.
- An open-source WAMS Client SDK Preview with an Apache 2.0 license is downloadable from GitHub; the SDK requires Windows 8 RTM and Visual Studio 2012 RTM.
- A sample doto application demonstrates WAMS multi-tenant features and is also available from GitHub. This sample is in addition to the tutorial walkthroughs offered from the Mobile Services Developer pages and the OakLeaf Systems blog.
- A Store menu add-in to Visual Studio 2012's Project menu accelerates app registration with and deployment to the Windows Store.
- A form opened in Visual Studio 2012 can obtain a developer license for Windows 8, which is required for creating Windows Store apps.
WAMS eliminates the need to handcraft the more than a thousand lines of XAML and C# required to implement and configure Windows Azure SQL Database (WASDB), as well as corresponding Access Control and Service Bus notification components for clients and device-agnostic mobile back ends. The RESTful back end uses OData's new JSON Light payload option to support multiple front-end operating systems with minimum data overhead. WAMS's Dynamic Schema feature auto-generates WASDB table schemas and relationships so front-end designers don't need database design expertise.
Expanding the WAMS device and feature repertoire
Scott Guthrie, Microsoft corporate VP in charge of Windows Azure development, announced the following device support and features in a blog post:
- iOS support, which enables companies to connect iPhone and iPad apps to Mobile Services
- Facebook, Twitter and Google authentication support with Mobile Services
- Blob, Table, Queue and Service Bus support from within Mobile Services
- The ability to send email from Mobile Services (in partnership with SendGrid)
- The ability to send SMS messages from Mobile Services (in partnership with Twilio)
- The capability to deploy mobile services in the West U.S. region.
Starting out with Data Services
Before you can test drive WAMS, you'll at least need a Microsoft Account (a.k.a., Live ID) and a Windows Azure trial subscription. Next, request access to the WAMS Preview from the Windows Azure Management Portal by clicking the Account tab, Preview Features link and then the Mobile Services section's "Try It Now" button.
You'll receive an email message in a day or two instructing you how to add a Mobile Services item to the portal's navigation pane. You can create up to 10 free Mobile Services during the preview period.
Clicking the +New button, selecting Mobile Services and clicking Create opens a form to use an existing Windows Azure SQL Database or to create a new one. The sample ToDo app, which is based on the WASM Developer Center's three "Getting Started …" examples, captures and stores task data in a simple TodoItem table with id (bigint, idenitity), text (nvarchar(max)), and complete (bit) columns.
The Dynamic Schemas feature automatically adds userId (nvarchar(max)) and channel (nvarchar(max)) columns for authorization and notifications when incorporating those features later. The service generates all XAML and C# code required to display the app's main form when you press F5 to build and run it in Visual Studio 2012 (see Figure 1).
Figure 1. Use the Dynamic Schemas feature to add channels and columns for authorizations and notifications.
To avoid unexpected behaviors, use the same Microsoft Account that you used for your trial or paid subscription to request admission to the WAMS Preview and to log into Windows 8 when testing the initial client app with Visual Studio 2012.
Adding user authentication and authorization with server permissions and client scripts
WAMS takes advantage of the Live SDK for Windows and Windows Phone to provide single sign-on (SSO) authentication with the Microsoft account you use to log into Windows 8. On my blog, I describe how to register the app with Windows Push Notifications & Live Connect services by creating a Package.appxmanifest file in Visual Studio 2012. Use the Live SDK for iOS and Live SDK for Android when the WAMS team extends its reach to Android devices. You can also enable authentication with the new Facebook, Google and Twitter identity providers.
WAMS adds a simple form to the Management Portal that lets developers set server-side permissions to authorize users to access the TodoItem table (see Figure 2).
Figure 2. The Table Permissions form for the TodoItem table lets developers choose the level of user authentication to read, insert, update and delete operations.
Adding a reference to Live SDK, using statements for Microsoft.Live and Windows.UI.Popups namespaces, and 23 lines of C# code brings up a Let This App Access Your Info? pop-up window. This form enables users to give or refuse app permissions to sign the user in automatically and access the user's name, gender, display picture, contacts and friends. If the user accepts access, a logon message opens.
Figure 3. Server-side script editors simplify the addition of a single line of code to pass userId values for authorization of operations on the TodoItem table.
Delivering push notifications
WAMS and the LiveID SDK also enable devices to push a notification to the user upon inserting a new row in the TodoItems table. My blog entry describes how to add a Windows.Networking.PushNotifications; as well as a statement and code to declare and deliver a value to a public static CurrentChannel variable to the client code. Steps 1-4 and 1-5 add a new DataMember property named channel and code to the ButtonSave_Click event handler for a total of eight lines of C# code. Then, you use the Management Portal to register the app's Security ID (SID) in the Push form as one of the Windows Application Credentials (see Figure 4).
Figure 4. Mobile Services needs the Client Secret and Package SID values to identify the client that requests access to the database tables.
Figure 5. The final push notifications test might show multiple notification tiles for one or more TodoItems entry.
Registering an app with the Windows Store
Microsoft is determined to make the Windows Store competitive with Apple's App Store, hopefully without the draconian vetting process, as well as with Google Play. My blog post covers how I dressed up the Oakleaf ToDo app's UI with custom bitmap files of varying sizes (see Figures 6 and 7). I also detail the entire submission process to the Windows Store.
Figure 6. This is the standard 150 x 150 px logo tile; the wide logo is a 300 x 150 px tile.
Figure 7. App searches and notifications use a 50 x 50 px logo tile.
The Windows Store was the sole means of deploying apps that launch from start page tiles when Windows 8 became generally available. I've submitted an updated version of the OakLeaf ToDo app for Windows Store registration. If it passes muster, you should be able to find it with a search on OakLeaf in early November. The registration queue grew lengthy in late October because of app developers' rush to meet the scheduled RTM of Windows 8 in late October 2012.
Roger Jennings is a data-oriented .NET developer and writer, a Windows Azure MVP, principal consultant at OakLeaf Systems and curator of the OakLeaf Systems blog. He's also the author of more than 30 books on the Windows Azure Platform, Microsoft operating systems (Windows NT and 2000 Server), databases (SQL Azure, SQL Server and Access), .NET data access, Web services and InfoPath 2003. His books have more than 1.25 million English copies in print and have been translated into more than 20 languages.