dbup-cli icon indicating copy to clipboard operation
dbup-cli copied to clipboard

Built dbup-cli.exe behaves differently to dotnet tool with az

Open huesie opened this issue 1 year ago • 0 comments

Running dbup-cli.exe (in WSL2 or in Windows PowerShell) returns this error:

$ dbup-cli.exe status
Parameters: Connection String: RunAs=Developer;DeveloperTool=AzureCli,
Resource: https://database.windows.net/, Authority: .
Exception Message: Tried to get token using Azure CLI. Access token could not be acquired.
'az' is not recognized as an internal or external command, operable program or batch file.

But running the dotnet tool with SDK 6.0 works fine:

$ dbup status
Database upgrade is required.
You have 1 more scripts to execute.

Things I've tried:

  1. Ran sudo dbup-cli.exe (and in PowerShell Admin prompt) - doesn't change behaviour.
  2. Setting AzureCLIPath (MSDN_link) and setting envvar etc. - nothing changes behaviour.
  3. Installed az cli in WSL2 and tried to set AzureCLIPath - nothing changes behaviour.
  4. Installed dotnet 6 SDK and installed dbup cli with dotnet tool install --global dbup-cli and using dbup - works perfectly: gets the token from az cli and connects.

Contents of .env file to specifically use AzureCli to get token and ignore the other 3 providers:

AzureServicesAuthConnectionString=RunAs=Developer;DeveloperTool=AzureCli

Contents of dbup.yml:

dbUp:
  version: 1                    # should be 1
  provider: AzureSql            # DB provider: AzureSql - suppports token auth
  connectionString: Server=tcp:MYAZURESQLSERVER.database.windows.net,1433;Database=MYDBNAME;Encrypt=true;

  scripts:
    -   folder:                 000-test-scripts-always/       # absolute or relative to folder with *.sql files
        subFolders:             no                             # yes / no (default)
        order:                  000                            # script group order, default 100
        runAlways:              yes                            # yes / no (default)

A single .sql file 000-test-scripts-always/000-test.sql:

select original_login() as original_login;
go

What is the issue?

  1. I get different behaviour with the pre-built dbup-cli.exe being unable to find az whereas running dbup tool under dotnet 6.0 sdk works as expected - what I can try next please?
  2. Can I trigger additional logging when running dbup-cli.exe to help diagnose this please?

huesie avatar Sep 27 '24 07:09 huesie