I'm setting up a SQL Server using CLI. It works as supposed to.
$Group = @("--resource-group", "groupy")
$Name = @("--name", "servy")
$User = @("--admin-user", "BigCahoona")
$Pass = @("--admin-password", "Abcde12345#¤%")
az sql server create $Group $Name $User $Pass
Recently, I've been advised that for practical reasons, I should use another password, one that contains parentheses. I replaced it as required, which led me to a surprising discovery: the parantheses are interpreted in a special way, on two levels which confuses me additionally.
This change: $Pass = @("--admin-password", "Abcde12345()")
results in a created resource but produces the error below. NB! Those are not commands I typed. It's just a printout that the computer gave after displaying the JSON of the created resource.
C:\source\dev>echo Failed to load python executable.
Failed to load python executable.
C:\source\dev>exit /b 1
This change: $Pass = @("--admin-password", "Abcde12345()()")
doesn't create jack, only producing the error below.
() was unexpected at this time.
C:\source\dev> "C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\..\python.exe" -IBm azure.cli
sql server create --resource-group groupy --name servy --admin-user BigCahoona --admin-password Abcde12345()()
I strongly suspect that the CLI somehow considers my new password as a function call or, possibly, a variable value to be rendered. What I'm stuck on, however, is how to resolve it (otherwise than picking a different set of characters). The consistent observation is that nothing is allowed to succeed the closing parenthesis and that some parameter is expected inside the parentheses.
I've found resources suggesting that should sourround or escape somehow, so I've tried apostrophes and quotes in different combinations as well as backslashes and dollar signs. Nothing of that helped. I'm certain that I've missed some alternative due to the mundane process of trial and horror.
These seems working (at least no error when I run, worth checking what's the final password in the server). It should be single quote + double quote
as illustrated here. Setting the value with double quotes inside single quotes (one for PowerShell, one for Command Prompt).
$Group = @("--resource-group", "rg-shared")
$Name = @("--name", "servy")
$User = @("--admin-user", "BigCahoona")
$Pass = @("--admin-password", '"Abcde12345()()"')
az sql server create $Group $Name $User $Pass
or
az sql server create --resource-group rg-shared `
--name servy `
--admin-user BigCahoona `
--admin-password '"Abcde12345()()"'