What is the command to publish using SqlPackage.exe (DACPAC) using AAD MFA authentication?

1.7k views Asked by At

What is the command to publish using SqlPackage.exe using Azure Active Directory Multi-Factor Authentication authentication?

I tried

/ua /tid:<TenantId Guid>

but it does not work and gives error

Login failed for user ''.

I don't know how to specify the username '[email protected]'. /TargetUser is only for SQL Auth.

Link to doc https://learn.microsoft.com/en-us/sql/tools/sqlpackage?view=sql-server-ver15

1

There are 1 answers

3
Xavier John On BEST ANSWER

I had to download the MSI version of the SQL Package.exe from here https://learn.microsoft.com/en-us/sql/tools/sqlpackage-download?view=sql-server-ver15

You will find the sqlpackage.exe located here

C:\Program Files\Microsoft SQL Server\150\DAC\bin

Then the following command line works.

sqlpackage.exe /Action:Publish /tsn:"<YourSQL.database.windows.net>" /sf:C:\DB\bin\Debug\YourDB.dacpac /tdn:<YourDatabase> /ua /tid:<Guid>

It should popup a UI to get the credentials. When I used the .net Core version, it did not popup the UI for credentials.