go-sqlcmd icon indicating copy to clipboard operation
go-sqlcmd copied to clipboard

Add support for Azure CLI authentication

Open maskati opened this issue 1 year ago • 8 comments

Related to #449 which concerned sqlcmd AAD authentication in an interactive shell terminal using device code authentication. This issue deals with AAD authentication in a non-interactive script.

My scenario is that I am running sqlcmd in a GitHub Action workflow on a self-hosted runner with managed identity, but with the actions workflow authenticating against Azure using GitHub OpenID Connect with a different AAD identity (not the same managed identity). This relies on the GitHub federated authentication context being sourced from Azure CLI (through the azure/login action), even though the runner itself has a managed identity for other purposes (runner provisioning Key Vault access etc.).

The current sqlcmd authentication implementation does not support using Azure CLI in scenarios when there is also a managed identity in the execution context, as it seems there is no way to "force" DefaultAzureCredential to use Azure CLI authentication if a managed identity exists.

Consider sqlcmd support for --authentication-method of AzureCli.

maskati avatar Aug 16 '23 12:08 maskati