Skip to content

sqlcmd panics when using MSI on App Service #502

Description

@ardoric

Running the following command

sqlcmd -d AdventureWorks2023 -S soulnorth.database.windows.net -Q "select count(*) from SalesLT.Product" --authentication-method=ActiveDirectoryManagedIdentity
gets me the following error on App Service:

sqlcmd.exe -d AdventureWorks2023 -S soulnorth.database.windows.net -Q "select count(*) from SalesLT.Product" --authentication-method=ActiveDirectoryManagedIdentity
panic: Unable to get user name

goroutine 1 [running]:
github.com/microsoft/go-sqlcmd/pkg/sqlcmd.(*Sqlcmd).ConnectDb(0xc0002cc3c0, 0x0?, 0x1?)
	D:/a/1/s/pkg/sqlcmd/sqlcmd.go:299 +0xc65
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.run(0xc000006760, 0x1c01080)
	D:/a/1/s/cmd/sqlcmd/sqlcmd.go:761 +0x6e9
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.Execute.func2(0xc000644300?, {0xc000101ce0?, 0x7?, 0x8?})
	D:/a/1/s/cmd/sqlcmd/sqlcmd.go:242 +0x3ce
github.com/spf13/cobra.(*Command).execute(0xc000644300, {0xc000642680, 0x7, 0x8})
	C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc000644300)
	C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.Execute({0x15dba18, 0x6})
	D:/a/1/s/cmd/sqlcmd/sqlcmd.go:265 +0x1a5
main.main()
	D:/a/1/s/cmd/modern/main.go:52 +0x21f

This seems to happen at a stage after the connection has been established (after sql.OpenDB() has been executed successfully) and the code is just trying to fill out some variables.

In this case it seems to fail after osuser.Current() fails (probably due to sandboxing restrictions on App Services?).

Same command works on a similarly configured VM.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions