@Pranav Kumar Kazipeta As suggested by Sam, you can use Azure Bastion. However we do not have any sample code to use Bastion to ssh into VM.
Currently Bastion only allows an interactive session from Azure Portal.
Azure Bastion is a growing PAAS offering and it is adding features depending on the feedback you provide. Feel free to suggest the feedback with these channels :
You can upvote a similar Feedback for Bastion here : https://feedback.azure.com/d365community/idea/f9fc5a9d-f225-ec11-b6e6-000d3a4f06a4
or create a new one with all your details here : https://feedback.azure.com/
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.