Hello @djoshi ,
you want to compare each incoming IoT Hub message with the previous message.
Azure Functions are stateless so you need some kind of 'state' (the last message seen) so you can compare it.
Table Storage and Redis cache are both valid solutions to be combined with Azure Functions although I personally prefer the Azure Storage tables binding.
Are you aware this can also be done using Azure Stream Analytics? Check out the LAG functionality as seen in this blog post.
----------
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. By doing so, all community members who have a similar issue will benefit. Your contribution is highly appreciated.