title: How to connect to a database using Active directory Login and MultiFactor Authentication (MFA)
body: <p>I have already configured my Azure SQL Server so that I am Server admin, my account also has MFA enabled. I was trying to follow <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-aad-authentication-configure?tabs=azure-powershell#using-an-azure-ad-identity-to-connect-from-a-client-application" rel="noreferrer">this documentation</a> but it doesn't mention anything about Active directory with MFA.</p>
  
  <p>I can use my account and MFA to sign into the server fine using SQL Management studio</p>
  
  <p>Initially I tried (based on the new <a href="https://docs.microsoft.com/en-gb/dotnet/api/system.data.sqlclient.sqlauthenticationmethod?view=netframework-4.8" rel="noreferrer">SqlAuthenticationMethod Enum</a>):</p>
  
  <pre><code>SqlConnection con = new SqlConnection("Server=tcp:myapp.database.windows.net;Database=CustomerDB;Authentication=Active Directory Interactive;Encrypt=True;UID=User@User.co.uk"))
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>'Cannot find an authentication provider for
    'ActiveDirectoryInteractive'.'</p>
  </blockquote>
  
  <p>I then saw <a href="https://docs.microsoft.com/en-us/azure/sql-database/active-directory-interactive-connect-azure-sql-db#c-code-example" rel="noreferrer">this about accessing SQL via an Azure application</a> But this is not what I want to do.</p>
  
  <p>This <a href="https://stackoverflow.com/questions/58440480/connect-to-azure-sql-in-python-with-mfa-active-directory-interactive-authenticat">SO question</a> talks about connecting without the provider and setting the <code>Driver</code> in the connection string</p>
  
  <pre><code>SqlConnection con = new SqlConnection("DRIVER={ODBC Driver 17 for SQL Server};Server=tcp:myapp.database.windows.net;Database=CustomerDB;Authentication=Active Directory Interactive;Encrypt=True;UID=User@User.co.uk"))
  </code></pre>
  
  <p>but I get the error:</p>
  
  <blockquote>
    <p>'Keyword not supported: 'driver'.'</p>
  </blockquote>
  
  <p>Is there anyway to write a connection string so that when it tries to connect the Microsoft authentication box pops up to walk the user through Multi factor authentication?</p>