azure-active-directoryazure-sql-databaseazure-powershellpaas

Azure SQL Database Active Directory password authentication using powershell


I am trying to login in Azure SQL active password authentication using cloudhsell below is the error I am facing mentioned in the screen shot.I am not able to understand is this the authentication issue or syntax issue in my script.

$cxn.open will open the connection but before that only I am facing issue.

After that I need to exectue the below commands

$cmd = New-Object System.Data.SqlClient.SqlCommand($query, $cxn)
$cmd.CommandTimeout = 120

$cmd.ExecuteNonQuery()
$cxn.Close()

Objective is to login to Azure SQL using active password auth and write some SQL query and close the connection.This thing I need to do in devops inline script task but it is falling in cloudshell itself.

Error - detail mentioned in the below diagram, please let me know how to correct it.

enter image description here

Kindly let me know is there any other script is there.


Solution

  • I'm not sure if this will fix all your issues, but there is a syntax error there. In your connection string you put authentication="Azure Active Directory"" that is a syntax error because your double quote actually ends the string... get rid of the "" around the azure active directory. like. authentication=Azure Active Directory"; that would at least get rid of the syntax error.