For Those Building New Apps in the Cloud

Azure Cloud on Ulitzer

Subscribe to Azure Cloud on Ulitzer: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Azure Cloud on Ulitzer: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Azure Authors: Yeshim Deniz, Elizabeth White, Pat Romanski, Zakia Bouachraoui, Nick Basinger

Related Topics: Ubuntu Linux Journal, SEO Journal, Azure Cloud on Ulitzer

Blog Feed Post

Azure CLI Day 31 – mobile data read

bash-azure

In my last post (http://thinkfirstcodelater.com/blog/?p=3297) I mentioned that I would use my next post, that’s this one, to show you how to delete a table associated with a Windows Azure Mobile Service. However, I then realized that there are two things I want to show you how to do prior to deleting a table. The first of which is how to read data from a table using the Windows Azure cross platform command line tools. I’ll use this post to show you how to do exactly that.

Once again, just a reminder that I’m using the command line tools on a MacBook Air with OSX (Mountain Lion) installed, and I’m using Google Chrome as my default browser. However, the experience should be identical on Windows and Linux as well.

Open an instance of your command line (Terminal, Bash, Command Prompt, etc.) and type the following:

azure mobile data read -h

Screen Shot 2013-10-11 at 9.09.26 AM

The mobile data read command is the command to use to view data in a table. As you can see there are several options and parameters you can use to define the data that gets displayed.

Options:

  • -k, –skip, skips the first specified number of rows
  • -t, –top, returns the first specified number of rows
  • -l, –list, displays the results in list format

Parameters:

  • servicename, the name of the mobile service containing the table you want to read data from (required)
  • table, the name of the table you want to read data from (required)
  • query, the query you want to execute (not required)
  • Let’s start using the command to simply read data from a table. Enter the following into your CLI, substituting where appropriate:

    azure mobile data read “[YOUR MOBILE SERVICE NAME]” “[YOUR TABLE NAME]“

    In my case I entered the following:

    azure mobile data read “zumo-00005″ “Movie”

    Screen Shot 2013-10-11 at 9.18.44 AM

    As you can see from the above screenshot, the data is returned in a nice table. If you’d prefer to see the data in a list format, enter the following:

    azure mobile data read -l “[YOUR MOBILE SERVICE NAME]” “[YOUR TABLE NAME]“

    I entered the following:

    azure mobile data read -l ‘zumo-00005′ ‘Movie’

    Screen Shot 2013-10-11 at 9.21.43 AM

    You can also have the data formatted as json using the standard –json option by using the following:

    azure mobile data read –json “[YOUR MOBILE SERVICE NAME]” “[YOUR TABLE NAME]“

    I entered the following:

    azure mobile data read –json ‘zumo-00005′ ‘Movie’

    Screen Shot 2013-10-11 at 9.22.35 AM

    If you want to just return the first record you can use the -t or –top option like this:

    azure mobile data read –top 1 “[YOUR MOBILE SERVICE NAME]” “[YOUR TABLE NAME]“

    I used:

    azure mobile data read –top 1 ‘zumo-00005′ ‘Movie’

    Screen Shot 2013-10-11 at 9.43.16 AM

    If you want to return the last record you could use the -s or –skip option like this:

    azure mobile data read –skip 4 –top 1 “[YOUR MOBILE SERVICE NAME]” “[YOUR TABLE NAME]“

    I used:

    azure mobile data read –skip 4 –top 1 ‘zumo-00005′ ‘Movie’

    Screen Shot 2013-10-11 at 9.45.17 AM

    That’s it for now. In my next post I’ll show you how to truncate the data in a table.

    Did you know you can try Windows Azure for free for 30 days? Just go to http://aka.ms/thecloud and sign up.

    Read the original blog entry...

    More Stories By Adam Grocholski

    Hey there! My name is Adam Grocholski, and I'm a Technical Evangelist at Microsoft where I spend time focusing on Windows, Windows Phone, and Windows Azure. I live in the frozen tundra of Minnesota and run thinkfirstcodelater.com. You can also follow me on twitter at @codel8r.