Whether you're using Azure CLI or, more specifically, Azure SDK to create a Virtual Machine, you may want to validate the given credentials before sending a request to create the VM. Otherwise, it could cost to send a full request with invalid data.
To do so, you can use this RegEx to validate your password before trying to create the VM.
This regex matches only when all the following are true:
password must contain 1 number (0-9) password must contain 1 uppercase letters password must contain 1 lowercase letters password must contain 1 non-alpha numeric number password is 12-123 characters with no space
Refer to this link to check the official documentation.