I have a VM in the cloud (Azure), which will be hosting my production
database. Is it safe to have port 22 open for my SSH connection?
No, it is not safe.
While I'm not sure why you'd need this in the first place, this allows for anyone on the public Internet to connect to your database. Even if you have certificate-based, multi-factor authentication in place it is still not safe. There is no need to needlessly expose your database. You should configure a bastion host (or Azure equivalent), or ideally a VPN connection to your network for management and allow port 22 between those two servers.
it also has a public IP address, is this safe too?
It's safe for some servers, but not your production database. The reasons for this are the same as exposing port 22 because the concept is the same regardless of port exposed when it's your production database you're talking about.
The overall idea here is to create a secure architecture -- the best way to do that is limiting interaction with your database. Especially direct access. See multi-tiered architecture. That's the Google Image Search for it since pictures explain it much better than text. But here's the Wiki on it.
If this is for a personal project, ask away and experiment. If you leave port 22 open to the world I guarantee you'll have people trying to break into your system in <24hrs, but you can always restore to a snapshot or tear it down and build a new VM entirely.
If this is for a true production database for a company and you are tasked with building out the architecture, you need to hire a consultant. I don't say that as an insult, but there are a thousand ways this can go wrong and it would be best to hire an expert.