Regular Expressions 101

Community Patterns

Azure Virtual Machine password validation


Regular Expression
ECMAScript (JavaScript)



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.

Ricardo S M Serradas Twitter Medium

Submitted by qho - 5 years ago