I have never failed to get a code sent to my phone or my alternate email address. Have you verified that your recovery information for your MS account is correct? Correct phone #? Alternate email address? If you set this info correctly when you established your MS account it should still work unless someone has hacked your account and changed the information. If you are unable to login to your account on the MS site, it's a good indication this may have happened. Hopefully, that is not the case.
Copied directly from Microsoft:
Reset your password when two-step verification is turned on
If you forget your password when you have two-step verification turned on for your account, you can reset your password as long as we have two ways to contact you, like one of the alternate contact email addresses or phone numbers that you used when you turned on two-step verification.
Depending on what security info you have added to your account, this requirement might mean entering a security code from your authenticator app and entering a security code that was emailed to your backup email account.
To reset your password, follow the steps in
How to reset your Microsoft account password. Instead of receiving one security code to verify your identity, though, you'll receive two.
If you're looking for info about changing, removing, or updating the alternate email address or phone number where you get security codes, follow the steps in either
Security info & verification codes or
Replace your Microsoft account security in