def post(self): res = {} try: # get the posted user data userdata = request.data # save to blob blob_file_name = self.partition_name + '.json' block_blob_service.create_blob_from_text(self.container, blob_file_name, userdata) #save to table task = Entity() task.PartitionKey = self.partition_name userModel = json.loads(userdata) task.RowKey = userModel['userName'] task.FirstName = userModel['firstName'] task.LastName = userModel['lastName'] task.EmailAddress = userModel['emailAddress'] task.CellNo = userModel['cellNo'] table_service.insert_entity(tablename, task) res = {'message': 'save successful'} except expression as identifier: res = {'message': 'save failed'} return jsonify(res)
def put(self): userModel = json.loads(request.data) userName = str(userModel['userName']) #save to table task = Entity() task.PartitionKey = 'f6dcfcfe-169e-4731-a589-2f8c6c75768a' #self.partition_name task.RowKey = userModel['userName'] task.FirstName = userModel['firstName'] task.LastName = userModel['lastName'] task.EmailAddress = userModel['emailAddress'] task.CellNo = userModel['cellNo'] table_service.update_entity(tablename, task, if_match='*')