Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Created October 3, 2018 11:07
Show Gist options
  • Save ThomasPe/232923f1e22870c7629643dafdd7bd8c to your computer and use it in GitHub Desktop.
Save ThomasPe/232923f1e22870c7629643dafdd7bd8c to your computer and use it in GitHub Desktop.
Delete | 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 ItemDelete');
const id = req.query.id;
if (id) {
// create a temporary object with PartitionKey & RowKey of the item which should be deleted
var item = { PartitionKey: 'Partition', RowKey: id };
tableService.deleteEntity(tableName, item, function (error, result, response) {
if (!error) {
context.res.status(204).send();
}
else {
context.res.status(500).json({error : error});
}
});
}
else {
// item to delete can't be found since no ID was passed
context.res.status(404).send();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment