locked
Storing JSON in Windows Azure Tables RRS feed

  • Question

  • Hello,

    I am currently writing entities to Windows Azure Tables. I have an entity (I'm using Node.js) that looks like this:

    var entityGenerator = azure.TableUtilities.entityGenerator;
    var myOrder = {
      PartitionKey: entityGenerator.String("Orders"),
      RowKey: entityGenerator.String(guid.v1()),
      CustomerId: entityGenerator.Int32(1),
      Description: entityGenerator.String("some description"),
      OrderCategories: /* want to insert a JavaScript array here, i.e. ['sports', 'men'] */ ,
      OrderDetails: /* want to insert a JSON object here, i.e. { id:1, name:'something', items:['item 1', 'item 2'] */,
    };

    I can't figure out what the recommended way is to put this information in the database. Can somebody please tell me how to store a JavaScript array and a JSON object in a WIndows Azure table? Even if I have to encode it, that's fine. I would just like to know how.

    Thursday, July 24, 2014 11:20 AM

Answers

All replies

  • Greetings!

    Understanding your requirement, found few web-links which could be helpful.

    An Introduction to Windows Azure Table Storage

    https://www.simple-talk.com/cloud/cloud-data/an-introduction-to-windows-azure-table-storage/

    Storing JSON in Windows Azure Tables

    http://blogs.msdn.com/b/windowsazurestorage/archive/2013/12/05/windows-azure-tables-introducing-json.aspx

    How to Use the Table Service from Node.js

    http://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-table-storage/

    Windows Azure Tables: Introducing JSON

    http://blogs.msdn.com/b/windowsazurestorage/archive/2013/12/05/windows-azure-tables-introducing-json.aspx

    Thanks,

    Arvind

    ___________________________

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Thursday, July 24, 2014 8:14 PM
  • Thank you for your response. However, those articles do not actually show how to store a JSON object in a Windows Azure Table or a JavaScript object in a Windows Azure table.
    Thursday, July 24, 2014 11:13 PM
  • None of these actually contain an example of how to attach a JSON entity to a JavaScript object for Azure Table Storage.
    Saturday, July 26, 2014 9:37 PM
  • Agreed. There are few and poor examples out there on how to use Azure Table Storage from Node.js. Forcing the dev to JSON.stringify() is *acceptable*, I guess, but it's too complicated. 

    All I want is to be able to create my objects in my app and not deal with all this too-complicated EntityGenerator effort. I don't want all that storage-level concern being visible/polluting my actual app objects. OK fine, make 2 methods to transform your own objects into Azure Table Storage objects that are suitable just for ATS. That's a flaw in the API - making the dev jump hoops just to fit into the API, and adding code and complexity. 

    It's as if my objects should not be *my* objects, but rather the object in the app needs to conform to the needs of the Table Storage API. So the solution is that we have to iterate through all the properties and convert them?

    So basically now I've got to go make a method to loop through all properties and call `entGen.String()` on each?

    Seems a shame isn't there a simple way to attach the required properties `PartitionKey` and `RowKey`as was in **previous versions of the API**. 

    Perhaps I'm missing something, but it's not obvious. There is a dearth of good *usable* examples on the web, MSDN forums, StackOverflow, and GitHub.

    Saturday, July 26, 2014 9:54 PM