Menu Home

Backup Azure Mobile Service Database Script with Azure Command Line Tools

If you have worked with the Azure Mobile Services, you have probably used the data features as it’s one of the main selling points, if not you should give it a try.

One thing that pretty quickly gets dirty is writing the code for the insert, read, delete and update scripts directly in the portal. Also what happens if you accidentally overwrites some good working scripts? With all the github and tfs integration Azure offers for web sites, surely there must be a better way to manage your mobile service scripts than relying on the portal interface. And of course there is, all the mobile service scripts can be uploaded and downloaded directly from the command prompt, when the Windows Azure Command-Line Tools are installed.

When the tools are installed and you have imported the publishing setting you will be able to execute the following from the command line to see all you mobile service scripts:
azure mobile script list "NAME_OF_MOBILE_SERVICE"
Where “NAME_OF_MOBILE_SERVICE” is replaced by the name of your mobile service.

If you want to download a specific script, e.g. for safe keeping, you simply use:
azure mobile script download "NAME_OF_MOBILE_SERVICE" table/TABLENAME.insert
Where TABLENAME is replaced with the name of your table, and .insert could be replaced by .delete, .read, or .update.

When uploading a script use the same syntax as for downloading but replace download with upload.

The command line tools are handy for managing other things as well, for a list of all the commands, type:
azure mobile
or visit the documentation at https://npmjs.org/package/azure-cli.

Categories: Software Windows Azure

Tagged as:

Simon J.K. Pedersen

Leave a Reply

Your email address will not be published. Required fields are marked *