Hier heb ik eindelijk antwoord op gevonden. Als iemand hier nog steeds op zoek is naar een antwoord, dan is het
Dit is momenteel niet mogelijk met Power shell in azure functions.
Ik moest dit doen met .net core.
sleutel hier is om Microsoft.Data.SqlClient . te gebruiken package.System.Data.SqlClient ondersteunt geen Active Directory-wachtwoordverificatie.
Gebruik dit Microsoft.Data.SqlClient-pakket en bingo!
code komt hier:
using Microsoft.Data.SqlClient;
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
string userName = "[email protected]";
string password = "password";
builder.ConnectionString = "Server=tcp:" + server + ",1433;Database=" + database + ";Authentication=Active Directory Password;UID=" + userName + ";PWD=" + password + ";Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";
using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
{
connection.Open();
string query = "CREATE USER YourUser WITH PASSWORD = 'JRxuerCc(q'"
SqlCommand cmd = new SqlCommand(query, connection);
cmd.CommandTimeout = 120;
cmd.ExecuteNonQuery();
connection.Close();
}