Welcome!

Think first. Code later.

Adam Grocholski

Subscribe to Adam Grocholski: eMailAlertsEmail Alerts
Get Adam Grocholski via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


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

Blog Feed Post

Azure CLI Day 32 – mobile data truncate

bash-azure

In my last post (http://thinkfirstcodelater.com/blog/?p=3310) I showed you how to read data from a table associated with your Windows Azure Mobile Service using the cross platform command line tools. In this post I’ll show you how to use those tools to truncate, or delete all of the data, from a table associated with your Windows Azure Mobile Service.

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 truncate -h

Screen Shot 2013-10-12 at 9.35.19 AM

As you can see from the above screenshot the azure mobile data truncate command is the command to use when you want to delete all of the data from a table. For this particular command there are three parameters/options to know about:

  • servicename, the name of the service containing the table you want to truncate
  • tablename, the name of the table you want to truncate
  • -q, –quiet, whether or not you want to prompt for confirmation prior to truncating the table

Before we truncate a table, let’s use the azure mobile table list command to get a list of all the tables associated with our mobile service. Enter the following int your CLI, substituting where appropriate

azure mobile table list ‘[YOUR MOBILE SERVICE NAME]‘

I entered the following:

azure mobile table list ‘zumo-00005′

Screen Shot 2013-10-12 at 10.18.07 AM

As you can see, my particular mobile service has three tables. For this exercise, I’ll truncate the GenreMovie table. Enter the following into your CLI, once again substituting where appropriate:

azure mobile data truncate -q ‘[YOUR MOBILE SERVICE NAME]‘ ‘[YOUR TABLE NAME]‘

I entered the following:

azure mobile data truncate -q ‘zumo-00005′ ‘GenreMovie’

Screen Shot 2013-10-12 at 10.21.50 AM

Notice I used the -q option to suppress confirmation of the operation. You can verify the success of the truncation operation by entering the following int your CLI, substituting where appropriate

azure mobile table list ‘[YOUR MOBILE SERVICE NAME]‘

I entered the following:

azure mobile table list ‘zumo-00005′

Screen Shot 2013-10-12 at 10.23.14 AM

Notice the GenreMovie table now contains 0 rows.

That’s it for now. In the next post I’ll show you how to delete a table from your Windows Azure Mobile Service.

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.