I have finally find a solution for the given issue. I will recommend you to use powershell with Az module to process the commands. Make sure you have installed the Az module in your powershell in order to perform the bash commands.
First identify the app id for your registered application in the azure.
Once you have the app id for me i faced an error where i was not able to read or access the certificate from Azure key vault because of error - "Caller is not authorized to perform action on resource.\r\nIf role assignments, deny assignments or role definitions were changed recently, please observe propagation time.
To properly access the Key vault i would recommend to provide role based access on the app id for Key Vault Administrator and Key Vault Certificates Officer.
Over here as your application is trying to access the key vault from your custom program you will have to provide role based access on the Service Principal. For more information please refer to -
https://learn.microsoft.com/en-us/azure/databricks/admin/users-groups/service-principals
So consider your app needs an active Service principal and provide the access of required role to the given service principal.
Commands to see and apply the role for your service principal is as follows-
az ad sp show --id [app-id]**
If it fails with Service Principal not found then create it with
az ad sp create --id [app-id]
Once you have an active sp in your tenant then next step is to assign the role
az role assignment create --assignee app-id/client-id --role "Key Vault Certificates Officer" --scope /subscriptions/[subscription-id]/resourcegroups/[resourcegroupname]/providers/Microsoft.KeyVault/vaults/[vault-name]
az role assignment create --assignee app-id/client-id --role "Key Vault Administrator" --scope /subscriptions/[subscription-id]/resourcegroups/[resourcegroupname]/providers/Microsoft.KeyVault/vaults/[vault-name]
If you have system managed identity enabled by default for Virtual Machine on azure then also add that app-id similarly with the command.
Once you do this please wait 15-20 minutes approximately for the assignment of roles properly and test like sending emails after this, I did this for setting up certification based authentication for our Oauth2 setup.