Hello @Athira Gopinath(UST,IN) ,
welcome to this moderated Azure community forum.
Being able to determine if a device is connected or not is a valid question.
The IoT Hub provides device lifecycle events like connect and disconnect that you can route to some storage or stream.
Be aware this is not a live message, the IoT Hub will provide it per 1 or a few minutes.
You can also check the metrics collector of Azure IoT Edge. This provides information about how old the last batch of data is.
Personally, I always add this custom heartbeat module which sends a message once every x seconds/minutes and provides a counter and a local date time. This way, I know how many times the module is restarted (probably indicting the shutdown of an edge device) and that local time can be compared with the iot hub enqueue time as an indication of connectivity delays.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.