Yavor Georgiev

Yavor is a PM at Snowflake working on developer experience. Previously at Docker, Auth0, Hulu, and Microsoft Azure.

Episode I: Working with typed and untyped data in the Mobile Services Android client

04 March 2013

To celebrate the Mobile Services Android launch, I’ve decided to put together a blog series over the next week to highlight some of the cool new features in our Android SDK. Here is the list of subjects I plan to cover:

Today, let’s focus on the data access aspect of the client, which lets us work with server entities in a typed or untyped way. Let’s start with a simple class that we want to store in a server-side table. We’re naming our class and properties to resemble the serialized JSON, we will cover how to customize the mapping between the properties and the serialized representation in a later post.

public class droid {
    public int id;
    public String name;
    public Float weight;
    public Integer numberOfLegs;
    public Integer numberOfWheels;
}

Note that a phantom menace lurks here: the class needs to contain a property called Id, ID, or id which will be populated by the server when it stores the entity.

To store instances of the class inside Mobile Services, we first need to create our Mobile Service in the Azure portal and then create a table called droid. Capitalization is important here. We then use the URL and application key provided in the portal to instantiate the MobileServiceClient.

MobileServiceClient client = new MobileServiceClient(
    "https://droid.azure-mobile.net/",
    "RrBQdeuaScZCIUsDSNnHPUyKowDDdW89",
    this);

The third parameter we pass here is the Activity or Service where the client is instantiated. We use that reference to grab the application context, which we use to store the installation ID for this application and also to display our authentication UI dialog.

Now we need to get a reference to the table object so we can insert data into it. Let’s look at the different overloads of the getTable method. 

public class MobileServiceClient {
    public MobileServiceJsonTable getTable(String name);
    public <E> MobileServiceTable<E> getTable(String name, Class<E> clazz);
    public <E> MobileServiceTable<E> getTable(Class<E> clazz);
}

The first overload is for working with our untyped JSON-based programming model, we will discuss that in a second. The second overload lets you work with a table if its name is different from the type name. The last overload assumes the class name and the table name are the same; this is the simplest one and that’s what we’ll use here.

MobileServiceTable<droid> table = client.getTable(droid.class);

We can then instantiate a new instance of the droid class and insert it into our server-side table.

~~~ java droid r2d2 = new droid(); r2d2.name = “R2D2”; r2d2.numberOfLegs = 0; r2d2.numberOfWheels = 2; r2d2.weight = 432.21f;

Read More

Ski weather app with the new Mobile Services scheduler

21 December 2012

Update: Corrected the server script code snippet.
Update 2:The example below will unfortunately no longer work due to Twitter API changes… I need to update it. In the mean time, our official documentation shows a very similar scenario, so check that out.

As Scott announced earlier today, Mobile Services is celebrating the holiday season by bringing you some cool new features, including the ability to execute scheduled jobs (or “cron jobs”). 

"Windows Azure Mobile Services now supports the ability to easily schedule background jobs (aka CRON jobs) that execute on a pre-set timer interval, and which can run independently of a device accessing the service (ensuring that you don’t block or slow-down any requests from your users).  This job scheduler functionality allows you to perform a variety of useful scenarios without having to create or manage a separate VM."

Some of the scenarios you can enable with it include:

  • Periodically purging old/duplicate data from your tables.
  • Periodically querying and aggregating data from external web service (tweets, RSS entries, location information) and cache it in your tables for subsequent use.
  • Periodically processing/resizing images submitted by users of your service.
  • Scheduling the sending of push notifications or SMS messages to your customers to ensure they arrive at the right time of the day.

Here I want to give a more detailed demonstration of the feature and celebrate another winter tradition: skiing. Let’s walk through a simple scenario where we will use a scheduled job to aggregate and analyze tweets related to ski conditions near Seattle. The source code is available here.

Finished SeattleSkiBuddy app screenshot

Let’s assume we already have a mobile service called skibuddy. We can navigate to the new Scheduler tab in the Windows Azure portal to create a scheduled job. 

Scheduler tab in Azure portal

Let’s go ahead and create a job called getUpdates. We will use the default interval of 15 minutes that is already selected in the dialog.

Create new scheduled job dialog

Once the job is created we will now see it in the summary view. You will note that the job starts off as disabled, so let’s click the job name to add our script.

Scheduler tab in Azure portal

On the job details page, we see information about our job and also we also have an opportunity to change the schedule. For now let’s leave everything as-is and navigate over to the Script tab.

Scheduled job detail page

Here we see the script editor window that has been pre-populated with a default empty script.

Scheduled job detail page with empty script

Let’s replace the default script with the following one.

~~~ javascript var updatesTable = tables.getTable(‘updates’); var request = require(‘request’);

Read More

Italy WPC 2012 slides and demos

28 November 2012

I had a great time in Milan, covering how to write lightweight apps on Azure. We showed how to write a mobile game using Azure Mobile Services and how to write a more involved Node.js app using Azure Websites.

Here are links to the demos I showed:

  • alinefour - Mobile Services game for Windows 8, using push notifications
  • tasklist - a Node.js website with a lot of different features including table and blob storage, authentication against Facebook, and live chat between users.

Hope you find this useful!

Read More

Speaking at WPC 2012

08 November 2012

I’m very excited to be speaking at the upcoming WPC conference (@wpc_2012) in Milan on November 20-22. My first session is an overview of the Windows Azure SDK and I’m co-presenting that session with Francesco Diaz (@francedit), who introduced me to the conference and made it possible for me to attend. In my second talk, I will focus on writing lightweight apps on Azure using Node.js and Mobile Services. Here are the two abstracts, also you can check the agenda page for more information. I’m excited about my talks and looking forward to making new friends in Italy!


CI3009 - Windows Azure SDK : Present and Future

Windows Azure SDK and the tools offer a great option for developers to work with different languages in the same platform. Join our session to see .NET, PHP, Java, Python, Node.js working together in Windows Azure. Understand how the SDK is evolving and see the roadmap of the platform.

Level: 300
Track: Cloud & Integration
Speakers: Francesco Diaz Yavor Georgiev


CI3018 - Catching up to startups: Lightweight app hosting in Windows Azure

You think Heroku or Parse offer the easiest and fastest way to get started with an app in the cloud? Think again… Windows Azure has added some exciting new features that make it as fast and agile as its most hip competitors. Come learn how to host Node applications in Azure websites and virtual machines using only a text editor and some command-line tools… even from a Mac. We will also show how to develop a backend for your Azure mobile app in minutes, whether you are using Windows 8, Windows Phone 8, or even IOS. This session will be full of great open-source technologies and will also give you a peek at the team’s plans going forward.

Level: 300
Track: Cloud & Integration
Speakers: Yavor Georgiev

Read More

Azure log streaming prototype

07 November 2012

I’ve created a small prototype of how streaming logs in Azure could work.

Debugging a running app in the cloud is one of the harder aspects of Azure websites, since you cannot directly connect to the VM where the app is running and look at the logs in real time. Azure already lets you download the logs over HTTP or FTP, but getting all the entries and having to manually diff them makes them impractical for development-time debugging. The ideal experience you want is to be able to directly stream the console output down to a local console window, so you can easily see the entries as they are happening. Heorku and other cloud hosters already allow you to do this, and now you can enable similar functionality on Azure as well!

Check out the video for a walkthrough, than dive into the project straight on GitHub.

Read More