Hello @Jukka Holmen ,
Azure VM blocks outgoing port 25 connections on public IPs in order to avoid our public IPs getting misused and getting blacklisted by Anti-spam solutions. Yes you are completely correct. We recommend to use services like Sendgrid for the same. Please check the recommended method of sending email from azure VMs. In case you are getting any issue with inbound port 25 on Azure VM with public IP , please check the firewall services on the VM (windows/linux) along with allowing the same on NSGs. If not then you can contact Microsoft support for helping you troubleshoot the same. I understand you are tying to send outgoing traffic from the VM however I just shared the related information as it may be helpful to other readers as well.
Hope this clarifies your query. Please check the related article and I believe you will be able to find out the details on using the SMTP port on Azure VM. If the information provided in this post is helpful , please do accept this as answer so that the relevancy of this answer improves and its useful to others with similar query within the community .
Thank you.