Extension and version:
serviceconnector-passwordless v2.0.3
What is the command being used:
az webapp connection create postgres-flexible
What is the error:
cli.azext_serviceconnector_passwordless._credential_free: Fail to connect to postgresql. invalid dsn: missing "=" after "Team" in connection info string
Why is this happening:
The logged in service principal is named "Some Team Pipeline SPN", because the user name is not properly quoted when passed as part of the connection string in _credential_free.py at line 830, when it tries to connect using conn = psycopg2.connect(conn_string) at line 798, it does not know how to parse the connection string.
Reproduction Steps:
Run: az login --service-principal --username "$azlogin" --password "$clientDeploySecret" --tenant "$tenantId" where azlogin is the client id of a service principal with the username "Some Team Pipeline" or equivalent. The important part is the spaces
Observe the error: cli.azure.cli.core.azclierror: Fail to connect to postgresql. invalid dsn: missing "=" after "Team" in connection info string
Go to the _credential_free.py located at /root/.azure/cliextensions/serviceconnector-passwordless/azext_serviceconnector_passwordless/_credential_free.py and modify the get_connection_string function to wrap the username in singlequotes. IE: conn_string = "host={} user='{}' dbname=postgres password={} sslmode=require".format(self.host, self.admin_username, password)
Repeat steps 1 and 2
Observe that the connection was created without errors
Extension and version: serviceconnector-passwordless v2.0.3
What is the command being used: az webapp connection create postgres-flexible
What is the error: cli.azext_serviceconnector_passwordless._credential_free: Fail to connect to postgresql. invalid dsn: missing "=" after "Team" in connection info string
Why is this happening: The logged in service principal is named "Some Team Pipeline SPN", because the user name is not properly quoted when passed as part of the connection string in
_credential_free.py
at line 830, when it tries to connect usingconn = psycopg2.connect(conn_string)
at line 798, it does not know how to parse the connection string.Reproduction Steps:
az login --service-principal --username "$azlogin" --password "$clientDeploySecret" --tenant "$tenantId"
where azlogin is the client id of a service principal with the username "Some Team Pipeline" or equivalent. The important part is the spacescli.azure.cli.core.azclierror: Fail to connect to postgresql. invalid dsn: missing "=" after "Team" in connection info string
/root/.azure/cliextensions/serviceconnector-passwordless/azext_serviceconnector_passwordless/_credential_free.py
and modify theget_connection_string
function to wrap the username in singlequotes. IE:conn_string = "host={} user='{}' dbname=postgres password={} sslmode=require".format(self.host, self.admin_username, password)