I have an Azure DB, from which I need to retrieve data with a PHP script,
Problem is that this database is only accessible with "Azure Active Directory - Universal With MFA"
Currently I am able to connect to it only with Microsoft SQL Server Management Studio
I realize that even if I was able to automate the login process, I would still not be able to automate the MFA. It might be possible for me to authenticate once over the phone, and leave the application running in background for further queries.
But I think I found a better solution, it seems that I can write an Azure application inside of azure and access it from an external API. This way I may not need to do MFA
Problem is, I am not an Azure or a web developer. So I would like to know if this is even possible before starting to do my research.
Can I bypass Active Directory Azure with MFA access by writing an internal Azure App and accessing it with PHP from the server?
My current code, which will not work for MFA, is below:
<?php
$serverName = "******.database.windows.net";
$connectionInfo = array( "Database"=>"********");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
echo "Unable to connect.</br>";
die( print_r( sqlsrv_errors(), true));
}
$tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
echo "Error in executing query.</br>";
die( print_r( sqlsrv_errors(), true));
}
$row = sqlsrv_fetch_array($stmt);
echo "User login: ".$row[0]."</br>";
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>