How to solve this issue?
Issue: The target machine has denied access to this connection. If you require access, please grant access to your account on the target machine, or check your system settings.
I tried to create azure virtual machine by using bastion connection by disabling the public ports. I am getting the OS image screenshot in boot diagnostics but i am unable to connect using bastion it is showing the error in image? Thank you!

This error occurs due to multiple reasons like if the user account trying to connect do not have the required permissions to access the machine.
Make sure to assign the user
Reader roleon the virtual machine, the NIC with the private IP of the virtual machine. refer this MSDocIn my case when I added NSG inbound rule 3389 configured to allow bastion its connected:
In vm -> run command ->
SetRDPPort-> RunNow bastion connected successfully:
References:
Quickstart: Deploy Bastion with default settings - Azure Bastion | Microsoft Learn
https://learn.microsoft.com/en-us/azure/bastion/bastion-nsg