You are writing a reusable ARM template that deploys a virtual machine to several environments. The template must meet the following requirements:
- The engineer who runs the deployment can choose the VM size at deployment time.
- Only
Standard_B2s,Standard_D2s_v3orStandard_D4s_v3is accepted as the VM size. - If the engineer does not specify a size,
Standard_B2sis used. - The administrator password is masked in deployment logs.
How should you define vmSize and adminPassword in the template?
Why
Making vmSize a parameter lets the engineer choose the size at deployment time. allowedValues limits the input to the approved sizes, and defaultValue supplies Standard_B2s when no size is given. Defining adminPassword as securestring masks the value in logs, which a plain string parameter does not.
- Not correct: vmSize: variable set to Standard_B2s; adminPassword: securestring parameter. Variables are values set inside the template. Only parameters can be customised during deployment.
- Not correct: vmSize: string parameter with defaultValue and allowedValues; adminPassword: string parameter. The string type is for ordinary text. Only securestring (or secureObject) is masked in logs.
- Correct: vmSize: string parameter with defaultValue and allowedValues; adminPassword: securestring parameter. A parameter can be chosen at deployment, allowedValues restricts it to the three sizes, defaultValue provides Standard_B2s, and securestring masks the password in logs.
- Not correct: vmSize: string parameter with allowedValues and no defaultValue; adminPassword: securestring parameter. Without a defaultValue, the parameter does not fall back to Standard_B2s when no size is supplied.
- Not correct: vmSize: string parameter with defaultValue and no allowedValues; adminPassword: securestring parameter. Without allowedValues, the choice is not restricted to the three approved sizes.