Forum Discussion

Kadeabdul's avatar
Kadeabdul
Copper Contributor
Jul 17, 2023

error while overriding 'Password2' parameter because of 'SyntaxError

 

Hello, I have been getting this error while trying to deploy my SQL server. The template is getting the pwd from a key vault. Before deploying the db., I retrieved all KV, and I don't know why I am still getting this error.

 

The password has backslash in it, and I escape by using double backslash: xxxxx\**** => xxxxx\\**** .

 

There was an error while overriding 'Password2' parameter because of 'SyntaxError: Unexpected number in JSON at position 8', make sure it follows JavaScript Object Notation (JSON)

1 Reply

  • Seems you need to take care of the following

     

    • Backslashes in JSON must be escaped twice if you're embedding them in a string inside a JSON object.
    • If you're using a deployment command or script (like Azure CLI or PowerShell), the escaping rules may differ depending on the shell.

     

    If you're manually overriding parameters using a JSON file or inline JSON, the password should look like this:

    "Password2": {
      "reference": {
        "keyVault": {
          "id": "/subscriptions/.../resourceGroups/.../providers/Microsoft.KeyVault/vaults/yourVault"
        },
        "secretName": "yourSecretName"
      }
    }

     

    • \\ becomes \\\\ in JSON because each backslash must be escaped.
    • If you're using a command-line tool, you may need additional escaping depending on the shell (e.g., PowerShell vs Bash).

Resources