dataplat / Invoke-SqlCmd2

PowerShell module containing Invoke-SqlCmd2
MIT License
68 stars 35 forks source link

Azure Functions Managed Identity: Keyword not supported: 'authentication' #32

Open Szeraax opened 1 year ago

Szeraax commented 1 year ago

When using a AZ Function MI, you need to use a connection string like: Server=a.database.windows.net; Authentication=Active Directory Managed Identity; Database=a but I get the error from AZ: Keyword not supported: 'authentication'.

Supposedly the fix is to use Microsoft.Data.SqlClient instead of System.Data.SqlClient. https://gist.github.com/MartinHBA/86c6014175758a07b09fa7bb76ba8e27

Perhaps Invoke-SqlCmd2 should detect if it has the Authentcation in the connection string and use MS.Data.Sql instead? Dunno.

More info: https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/

Shame that for lightweight query access, I have to revert to users and password. Or use dbatools.