Code Monkey home page Code Monkey logo

nodered-azure-storage-table's Introduction

node-red-contrib-azure-table-storage

node-red-contrib-azure-table-storage is a Node-RED node that allows you to work with Azure Table Storage. You can do all CRUD into Table Storage.

It contains one Node-RED cloud node: Azure Table Storage

Azure Table Storage

Node-Red node to connect to Azure Table Storage

This node allows you to do CRUD into Azure Table Storage. It has the following payload format:

To save entity

{ 
  "tableName": "name",
  "action": "I", 
  "partitionKey": "part1", 
  "rowKey": "row1", 
  "data": 
        {
          "Column": "Value"
        }
}
  • If you send data as JSON, the node will save each key as a column.

To read entity

{ 
  "tableName": "name",
  "action": "R", 
  "partitionKey": "part1", 
  "rowKey": "row1"
}

To delete entity

{ 
  "tableName": "name",
  "action": "D", 
  "partitionKey": "part1", 
  "rowKey": "row1"
}

To update entity

{ 
  "tableName": "name",
  "action": "U", 
  "partitionKey": "part1", 
  "rowKey": "row1", 
  "data": 
        {
          "Column": "Value"
        }
}

To query entity

{
  "tableName": "name", 
  "action": "Q", 
  "selectdata": "columnName", 
  "fromcolumn": "from", 
  "where": "where"
}

 
### To delete table

{ "tableName": "name", "action": "DT" }



## Installation

npm install -g node-red-contrib-azure-table-storage

How to Use

Node-RED Setup

Follow the instructions here to get Node-RED setup locally.

Working with Azure Table Storage node

  1. Open Node-RED, usually: http://127.0.0.1:1880

  2. Go to Hamburger Menu -> Import -> Clipboard

  3. Paste the following code into the "Import nodes" dialog

    [{"id":"95f88979.995298","type":"debug","z":"5e92f737.c60d68","name":"Log","active":true,"console":"false","complete":"true","x":843,"y":325,"wires":[]},{"id":"89d5f94e.906ea8","type":"Table Storage","z":"5e92f737.c60d68","name":"Azure Table Storage","x":645,"y":325,"wires":[["95f88979.995298"]]},{"id":"3429d17b.1ea3ce","type":"inject","z":"5e92f737.c60d68","name":"Payload","topic":"","payload":"{    \"tableName\": \"name\",   \"action\": \"I\",    \"partitionKey\": \"part2\",    \"rowKey\": \"row1\",    \"data\":          {           \"Column\": \"Value\"         } }","payloadType":"json","repeat":"","crontab":"","once":false,"x":424,"y":325,"wires":[["89d5f94e.906ea8"]]}]
    
  4. Double-click the Payload node

  5. Enter your desired payload, following the instructions, into the Payload field and click Done. Check "Inject once at start?" to insert data when you click Deploy.

  6. Double-click the Azure Table Storage node, enter your Storage Account Name and Storage Account Key and click Done.

  7. Click Deploy

  8. Click the square button on the left side of the Register Payload node.

  9. Click on the debug tab to your right and you'll see the device's primary and secondary keys.

References

You can read more about Azure Storage here.

nodered-azure-storage-table's People

Watchers

 avatar  avatar  avatar  avatar

nodered-azure-storage-table's Issues

Azure storage table error

Hi ,
I have been trying to query/ read data from Azure table storage ,and I faced error saying "Error: Credentials must be provided when creating a service client." and "Error: ENOENT: no such file or directory, open 'D:\TESTCSV.txt'"
my flow look like this:
[{"id":"95f88979.995298","type":"debug","z":"12849566.e1536b","name":"Log","active":true,"console":"false","complete":"true","x":610,"y":360,"wires":[]},{"id":"89d5f94e.906ea8","type":"Table Storage","z":"12849566.e1536b","name":"Azure Table Storage","x":412,"y":360,"wires":[["95f88979.995298"]]},{"id":"3429d17b.1ea3ce","type":"inject","z":"12849566.e1536b","name":"Payload","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"{"tableName":"myTable2","action":"R","partitionKey":"ABC123","rowKey":"10"}","payloadType":"json","x":191,"y":360,"wires":[["89d5f94e.906ea8"]]}]

Any suggestion pls.
Thanks
Wit

Storage error

I'm trying to read a CSV file and send over the data line by line to Azure Table Storage. I've made the data unique using the time stamp adding a variable per message. However if I send to lines of data or two messages. Only the second one comes across and the first one throws an error:

This is message one:

{"tableName":"name","action":"I","partitionKey":"part2","rowKey":"1476649418331","data":{"Column1":"Row1C1","Column2":"Row1C2","Column3":"Row1C3"}}

Returning:

16-10-2016 22:23:39Azure Table Storage
msg : string [163]
Error while trying to save data:StorageError: The specified entity already exists. RequestId:cedf2110-0002-007f-4eeb-275e5e000000 Time:2016-10-16T20:23:40.3597774Z

This is message two:

{"tableName":"name","action":"I","partitionKey":"part2","rowKey":"1476649418332","data":{"Column1":"Row2C1","Column2":"Row2C2","Column3":"Row2C3"}}

Returning:

16-10-2016 22:23:39Log
msg : string [11]
data saved.

This is my node-red flow:

[{"id":"9a96640e.8ac6a8","type":"tab","label":"Flow 1"},{"id":"79f08138.3591e","type":"debug","z":"9a96640e.8ac6a8","name":"","active":true,"console":"false","complete":"payload","x":724.5,"y":119,"wires":[]},{"id":"6ba900e3.b8c68","type":"function","z":"9a96640e.8ac6a8","name":"dynamic","func":"msg.topic = msg.payload; \nreturn msg;","outputs":1,"noerr":0,"x":163.5,"y":192,"wires":[["e9ba66a6.2609f8"]]},{"id":"881bed10.69e5","type":"function","z":"9a96640e.8ac6a8","name":"merge","func":"if (!context.value) {\n  context.value = 0;\n}\ncontext.value +=1;\n\n\n\nvar RowKey = String(msg.topic + context.value);\nvar Data = msg.payload;\n\nmsg.payload = {\"tableName\": \"name\", \"action\": \"I\", \"partitionKey\": \"part2\", \"rowKey\": RowKey, \"data\": Data};\n/*msg.payload = {\"tableName\": \"name\", \"action\": \"I\", \"partitionKey\": \"part2\", \"rowKey\": \"row13\", \"data\": {\"Column\": \"Value13\"}};*/\nreturn msg;","outputs":1,"noerr":0,"x":404,"y":166,"wires":[["180d09fa.2000c6"]]},{"id":"180d09fa.2000c6","type":"json","z":"9a96640e.8ac6a8","name":"","x":543,"y":210,"wires":[["79f08138.3591e","8b1be5eb.5dcbc8"]]},{"id":"8b1be5eb.5dcbc8","type":"Table Storage","z":"9a96640e.8ac6a8","name":"Azure Table Storage","x":766.5,"y":209,"wires":[["fe41d516.3e8208"]]},{"id":"fe41d516.3e8208","type":"debug","z":"9a96640e.8ac6a8","name":"Log","active":true,"console":"false","complete":"true","x":794.5,"y":403,"wires":[]},{"id":"7deb1c15.482474","type":"inject","z":"9a96640e.8ac6a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":76,"y":306,"wires":[["6ba900e3.b8c68"]]},{"id":"17a020b6.e0f95f","type":"csv","z":"9a96640e.8ac6a8","name":"CSV parser","sep":"\\t","hdrin":true,"hdrout":true,"multi":"one","ret":"\\n","temp":"A,B,C,D","x":464,"y":305,"wires":[["1dc33972.1e6177","881bed10.69e5"]]},{"id":"e9ba66a6.2609f8","type":"file in","z":"9a96640e.8ac6a8","name":"File Reader","filename":"D:\\TESTCSV.txt","format":"utf8","x":264,"y":305,"wires":[["17a020b6.e0f95f"]]},{"id":"1dc33972.1e6177","type":"debug","z":"9a96640e.8ac6a8","name":"","active":false,"console":"false","complete":"false","x":443,"y":405,"wires":[]}]

Documentation is not same in github and npm

In "To save entity" section
in npm => If you send data as JSON, the node will convert to String and save into Table Storage in a column named "data".
in github => If you send data as JSON, the node will save each key as a column.

please update github readme file.

node variable is overwritten while creating multiple nodes

In the code, the node variable is global so that when you create several nodes in your flow, each node overrides this variable and the flow does not work as expected:

line 8: var node = null;
line 43(for e.g.): node.send('data saved.'); - this line will not work well when there are 2 nodes of 'Azure-Storage-Table' in the flow

Let me know what do you think?

npm and GitHub versions not in sync and differ!

I installed this library using npm - the standard way for all NodeJS / Node RED installations.
Unfortunately, you get version 0.1.4 there, which is not the latest compared to this GitHub version. AND, most problematic: it is massively broken and crashes Node RED when trying to read data.
Now, version 0.1.4 is NOT present in this repository.

Could you please clean up the versions and make it a little bit more consistent so that bugs can be tracked in one place? Thanks!

Simply does not work. No "I" or "U" action completes.

I am trying to do just as told in the documentation - storing an entity in a table.

I use this msg object:

msg.payload = {
  "tableName": "newtable", 
  "action": "I", 
  "partitionKey": "part1", 
  "rowKey": "row1", 
  "data": "test"  
};

The Azure node just says "Sending" and that's it. No more, no less.

The table was created when I did this the first time, but no entity was stored.

Trying to read using "R" action fails, too. Unless I enter the exact same data manually using Visual Studio Cloud Explorer. Then reading works fine - but again, no "I" or "U" actions work properly.

Why?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.