none
Error while storing JSON string in Azure Table

    Question

  • Hi,

    I am trying to store a JSON string in Azure Table. I am facing some errors while doing the same.

    The code snippet for storing JSON string in the table is as follows:

    private void UploadInParallelBatch(CloudTable table)
        {
            StringBuilder jsonStr = new StringBuilder();

            jsonStr.Append("[");

            for (int i = 0; i < 300; i++)
            {
                if (i != 0)
                {
                    jsonStr.Append(",{");
                }
                else {
                    jsonStr.Append("{");
                }

                jsonStr.Append("'name':'Vishal" + i.ToString() + "','country':'India','Address':'Mumbai','State':'Maharashtra','Pincode':'421202'");
                jsonStr.Append("}");
            }

            jsonStr.Append("]");

            EmpJsonEntity empJson = new EmpJsonEntity("3", "India");
            empJson.JsonData = jsonStr.ToString().Trim();
            empJson.Id = "3";
            empJson.Country = "India";

            //TableBatchOperation batchOperation = new TableBatchOperation();
            //batchOperation.Insert(empJson);

            //Label3.Text = "Start Time : {0} " + DateTime.Now;
            //table.ExecuteBatch(batchOperation);
            //Label4.Text = "End Time : {0} " + DateTime.Now;

            // Create the TableOperation that inserts the customer entity. 
            TableOperation insertOperation = TableOperation.Insert(empJson);

            // Execute the insert operation. 
            table.Execute(insertOperation);
        }


    What we are doing is we are creating JSON nodes in a loop. The loop currently has the count of 300. 

    For the count of 300, the code works fine. However when I exceed the count above 300, then I get the below error:

    “Additional information: The remote server returned an error: (400) Bad Request.”


    When we try to insert the JSON string using the storage explorer, it gets done without any issues.

    Any help on this would be appreciated.

    Regards, 
    Prakash
    Tuesday, January 10, 2017 5:41 AM

All replies

  • Hi,

    Thank you for contacting Microsoft forums. We are pleased to answer your query.

    We are checking on the query and will get back to you soon on this.I apologize for the inconvenience and appreciate your time and patience in this matter.

    Regard,
    Sumanth BM

    Tuesday, January 10, 2017 6:56 PM
    Moderator
  • Hello,

    Thank you for your time and patience!

    Entity property has a limit of 64KB, if you try to exceed that while appending to the JSON property.

    The extended error information in StorageException, following could be seen:

    {"odata.error":{"code":"PropertyValueTooLarge","message":{"lang":"en-US","value":"The property value exceeds the maximum allowed size (64KB). If the property value is a string, it is UTF-16 encoded and the maximum number of characters should be 32K or less.

    I hope that the reply will assist you in getting your query addressed. In case you require further assistance, please do reply to the thread as we are always available to your queries.


    Regards,
    Sumanth BM

    -----------------------------------------------------------------------------------------------------------------

    Kindly click "Mark as Answer" on the post that helps you, this can be beneficial to other community members reading the thread. And Vote as Helpful.

    Friday, January 13, 2017 7:46 PM
    Moderator