Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Created October 3, 2018 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasPe/54fb8863dcab0e20e18522ccd030a7fc to your computer and use it in GitHub Desktop.
Save ThomasPe/54fb8863dcab0e20e18522ccd030a7fc to your computer and use it in GitHub Desktop.
Update | Azure Functions + NodeJs + Table Storage
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemUpdate');
if (req.body) {
// TODO: Add some object validation logic
const item = req.body;
// Depending on how you want this to behave you can also use tableService.mergeEntity
tableService.replaceEntity(tableName, item, function (error, result, response) {
if (!error) {
context.res.status(202).json(result);
} else {
context.res.status(500).json({ error: error });
}
});
}
else {
context.res = {
status: 400,
body: "Please pass an item in the request body"
};
context.done();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment