Version 1 AzMS Tables use an auto-incremented integer field as the primary key which is more compact than the GUID string used in version 2 AzMS tables.. The Azure Portal generates Version 2 tables which can be inefficient for resource limited embedded devices. This blog covers how to generate version 1 AzMS tables.


CEJSON : The Project Codeplex site

This blog is a rework of the ArdJSON version for Arduino devices

Ardjson: https://ardjson.codeplex.com    

Previous Blog on this topic: Ardjson-Part 9: Azure Mobile Services Table id options


Version One of Azure Mobile Services Tables

The string-GUID id field was an update to AzMS. The first version used an auto-generated integer id but these tables are not available through the Azure Portal. Also, the System Property fields are not available with these tables. CEJSON uses a version 1 AzMS table, telemetry2.

 

You can create a Version One table using the Microsoft Cross-platform Command Line Tools:

  • Download and install the Windows version from:  Microsoft Cross-platform Command Line Tools Windows installer.
  • First set up your Azure credentials:
  • From an Admin  command prompt  enter:
  • azure account download
  • Login with  the same account credential you us to login to the Azure Portal.
  • A browser will open
  • Save the file  when prompted without spaces in the path (ie. Change the filename to have no spaces etc.. or use double quotes around the path in the next step).
  • From the same command prompt:
azure account import [path to .publishsettings file]
  • Then run the following command:
azure mobile table create --integerId [servicename] [tablename]

Note that the servicename isn’t the service URL but the name you gave the service, the first part of the URL.

Security: Delete the downloaded file when done and encrypt the ..azure folder in your user folder.

Further details with respect to the Cross-platform Tools.: http://tinyurl.com/ng864o5

 

An example:

Prompt>azure account download
info:    Executing command account download
info:    Launching browser to http://go.microsoft.com/fwlink/?LinkId=254432
help:    Save the downloaded file, then execute the command
help:      account import <file>
info:    account download command OK

Prompt>azure account import  c:\azure\credentials.publishsetting
info:    Executing command account import
info:    account import command OK

Prompt>azure mobile table create --integerId sportronicsdj telemetry2
info:    Executing command mobile table create
+ Creating table
info:    mobile table create command OK

Prompt>

 

The auto-generated id field is an SQL BigInt:

telemetry2
 
Browse Script Columns Permissions

id  sensor       value
1   Temperature1 562 
2   Temperature2 134 
3   Humidty1      67 
4   Humidty2      78 
5   Temperature1 926 

If downloaded as a JSon Response string the id would be interpreted as an integer requiring only only 2 bytes, compared to the 36 byte GUID string!

 

Conclusion

For CEJSON Mobile Services tables, create them as Version one tables to save on storage. This gives an integer id which also is useable with chronology sorts and searches. Note also, that if a random record is deleted its id isn’t recycled until all larger ids have been removed.

The drawback is that a date field would need to be added and added to the POST requiring a RTC on the Arduino device*. Alternatively, a post date can be auto-generated the AzMS POST script for the table as discussed in the previous blog in this series. This is what is done with CEJSON telemetry2 table.


A Reference for this content is: “New tables in Azure Mobile Services: string id, system properties and optimistic concurrency”, Carlos Figueira MSDN blog


Next: Ardjson-Part9b: Azure Mobile Services Scripts