Basically, for this type of error, we used to adding or updating NSG rules will take some time to reflect the changes. Also, you can try rebooting the VM instance and it will start working. It is strange but it works.
I hope this will help.
Want to become an Azure expert? Join Azure Certification now!!
Want to know more about Azure? Watch this video on Azure Administrator Training Course | AZ-103 Training: