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 37 – mobile script download

bash-azure

In my previous post (http://thinkfirstcodelater.com/blog/?p=3359) I showed you how to use the Windows Azure cross platform command line tools to list the scripts associated with a Windows Azure Mobile Service. In this post I’ll show you how to use that information to download a script associated with a 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 script download -h

Screen Shot 2013-10-14 at 7.55.51 PM

As you can see the azure mobile script download command can be used to download a script from a Windows Azure Mobile Service. In our case, we’ll download the script associated with a schedule job. There are a few parameters/options to provide to the command:

  • servicename, the name of the service that contains the script to be downloaded
  • scriptname, the name of the script to download
  • -f, –file, the local file to save the script to
  • -o, –override, override an existing file if one exists
  • -c, –console, write the script to the console instead of a file

We’ll start by writing the script to the console. Enter the following enter your CLI, substituting where appropriate:

azure mobile script download -c ‘[YOUR MOBILE SERVICE NAME]‘ ‘[YOUR SCRIPT NAME]‘

If you don’t know the name of the script associated with your mobile service’s scheduled job, please refer to my previous post (http://thinkfirstcodelater.com/blog/?p=3359). It should be in the format of scheduler/[job name]

In my case I entered the following:

azure mobile script download -c ‘zumo-00005′ ‘scheduler/myFirstJob’

Screen Shot 2013-10-14 at 8.03.00 PM

This simply writes the contents of the script to the console window. To download the script to a local file enter the following, once again substituting where appropriate:

azure mobile script download -f ‘[YOUR LOCAL FILE PATH]‘ -o ‘[YOUR MOBILE SERVICE NAME]‘ ‘[YOUR SCRIPT NAME]‘

I used the following:

azure mobile script download -f ‘/Users/adam/Code/zumo-00005/scheduler/myFirstJob.js’ -o ‘zumo-00005′ ‘scheduler/myFirstJob’

Screen Shot 2013-10-14 at 8.07.19 PM

Notice I gave the file a .js extension. This is because Windows Azure Mobile Services uses Node.js for server side scripts. You should now be able to navigate to the downloaded file on your local file system and open it using your favorite JavaScript editor (mine happens to be Sublime Text).

Screen Shot 2013-10-14 at 8.08.28 PM

That’s it for now. In my next post I’ll show you how to modify the script and upload the new version to 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.