Hello Smriti, Smriti,
When you are using Self hosted ubuntu agent, can you please confirm if your agent has access to the private endpoint?
If it doesn't have access, please configure your agent to use a Vnet and a private endpoint for databricks. Then this will allows your self hosted aganet to communicate with databricks privately.
Once you have configured your agent to use Vnet and private endpoint, please modify your PS script to use the private endpoint instead of the public url.
I hope this helps.