You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reports: '"SQL 2017.coverage.xml";"SQL DB.coverage.xml"'# REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
35
+
targetdir: 'coverage'# REQUIRED # The directory where the generated report should be saved.
sourcedirs: '$(Build.SourcesDirectory)'# Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information.
38
+
verbosity: 'Info'# The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
39
+
tag: '$(build.buildnumber)_#$(build.buildid)_$(Build.SourceBranchName)'# Optional tag or build version.
Copy file name to clipboardExpand all lines: README.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,60 @@ We will be implementing as many command line switches and behaviors as possible
20
20
- Some behaviors that were kept to maintain compatibility with `OSQL` may be changed, such as alignment of column headers for some data types.
21
21
- All commands must fit on one line, even `EXIT`. Interactive mode will not check for open parentheses or quotes for commands and prompt for successive lines. The native sqlcmd allows the query run by `EXIT(query)` to span multiple lines.
22
22
23
+
### Azure Active Directory Authentication
24
+
25
+
This version of sqlcmd supports a broader range of AAD authentication models, based on the [azidentity package](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity).
26
+
27
+
#### Command line
28
+
29
+
To use AAD auth, you can use one of two command line switches
30
+
31
+
`-G` is (mostly) compatible with its usage in the prior version of sqlcmd. If a user name and password are provided, it will authenticate using AAD Password authentication. If a user name is provided it will use AAD Interactive authentication which may display a web browser. If no user name or password is provided, it will use a DefaultAzureCredential which attempts to authenticate through a variety of mechanisms.
32
+
33
+
`--authentication-method=` can be used to specify one of the following authentication types.
34
+
35
+
`ActiveDirectoryDefault`
36
+
37
+
- For an overview of the types of authentication this mode will use, see (<https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/azidentity#defaultazurecredential>).
38
+
- Choose this method if your database automation scripts are intended to run in both local development environments and in a production deployment in Azure. You'll be able to use a client secret or an Azure CLI login on your development environment and a managed identity or client secret on your production deployment without changing the script.
39
+
- Setting environment variables AZURE_TENANT_ID, and AZURE_CLIENT_ID are necessary for DefaultAzureCredential to begin checking the environment configuration and look for one of the following additional environment variables in order to authenticate:
40
+
41
+
- Setting environment variable AZURE_CLIENT_SECRET configures the DefaultAzureCredential to choose ClientSecretCredential.
42
+
- Setting environment variable AZURE_CLIENT_CERTIFICATE_PATH configures the DefaultAzureCredential to choose ClientCertificateCredential if AZURE_CLIENT_SECRET is not set.
43
+
- Setting environment variable AZURE_USERNAME configures the DefaultAzureCredential to choose UsernamePasswordCredential if AZURE_CLIENT_SECRET and AZURE_CLIENT_CERTIFICATE_PATH are not set.
44
+
45
+
`ActiveDirectoryIntegrated`
46
+
47
+
This method is currently not implemented and will fall back to `ActiveDirectoryDefault`
48
+
49
+
`ActiveDirectoryPassword`
50
+
51
+
This method will authenticate using a user name and password. It will not work if MFA is required.
52
+
You provide the user name and password using the usual command line switches or SQLCMD environment variables.
53
+
Set `AZURE_TENANT_ID` environment variable to the tenant id of the server if not using the default tenant of the user.
54
+
55
+
`ActiveDirectoryInteractive`
56
+
57
+
This method will launch a web browser to authenticate the user.
58
+
Set `AZURE_TENANT_ID` environment variable to the tenant id of the server if not using the default.
59
+
60
+
`ActiveDirectoryManagedIdentity`
61
+
62
+
Use this method when running sqlcmd on an Azure VM that has either a system-assigned or user-assigned managed identity. If using a user-assigned managed identity, set the user name to the ID of the managed identity. If using a system-assigned identity, leave user name empty.
63
+
64
+
`ActiveDirectoryServicePrincipal`
65
+
66
+
This method authenticates the provided user name as a service principal id and the password as the client secret for the service principal. Set `AZURE_TENANT_ID` environment variable to the tenant id of the service principal.
67
+
68
+
### Environment variables for AAD auth
69
+
70
+
Some settings for AAD auth do not have command line inputs, and some environment variables are consumed directly by the `azidentity` package used by `sqlcmd`.
71
+
These environment variables can be set to configure some aspects of AAD auth and to bypass default behaviors. In addition to the variables listed above, the following are sqlcmd-specific and apply to multiple methods.
72
+
73
+
`SQLCMDAZURERESOURCE` - defines the URL of the Azure SQL database resource in the Azure cloud where the database resides. By default, `sqlcmd` attempts to match the DNS suffix of the server name with one of the well known Azure cloud DNS suffixes. If no match is found it uses `https://database.windows.net`.
74
+
75
+
`SQLCMDCLIENTID` - set this to the identifier of an application registered in your AAD which is authorized to authenticate to Azure SQL Database. Applies to `ActiveDirectoryInteractive` and `ActiveDirectoryPassword` methods.
Copy file name to clipboardExpand all lines: cmd/sqlcmd/main.go
+40-5Lines changed: 40 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ type SQLCmdArguments struct {
20
20
// Whether to trust the server certificate on an encrypted connection
21
21
TrustServerCertificatebool`short:"C" help:"Implicitly trust the server certificate without validation."`
22
22
DatabaseNamestring`short:"d" help:"This option sets the sqlcmd scripting variable SQLCMDDBNAME. This parameter specifies the initial database. The default is your login's default-database property. If the database does not exist, an error message is generated and sqlcmd exits."`
23
-
UseTrustedConnectionbool`short:"E" xor:"uid" help:"Uses a trusted connection instead of using a user name and password to sign in to SQL Server, ignoring any any environment variables that define user name and password."`
23
+
UseTrustedConnectionbool`short:"E" xor:"uid, auth" help:"Uses a trusted connection instead of using a user name and password to sign in to SQL Server, ignoring any any environment variables that define user name and password."`
24
24
UserNamestring`short:"U" xor:"uid" help:"The login name or contained database user name. For contained database users, you must provide the database name option"`
25
25
// Files from which to read query text
26
26
InputFile []string`short:"i" xor:"input1, input2" type:"existingFile" help:"Identifies one or more files that contain batches of SQL statements. If one or more files do not exist, sqlcmd will exit. Mutually exclusive with -Q/-q."`
@@ -31,7 +31,10 @@ type SQLCmdArguments struct {
31
31
Querystring`short:"Q" xor:"input2" help:"Executes a query when sqlcmd starts and then immediately exits sqlcmd. Multiple-semicolon-delimited queries can be executed."`
32
32
Serverstring`short:"S" help:"[tcp:]server[\\instance_name][,port]Specifies the instance of SQL Server to which to connect. It sets the sqlcmd scripting variable SQLCMDSERVER."`
33
33
// Disable syscommands with a warning
34
-
DisableCmdAndWarnbool`short:"X" xor:"syscmd" help:"Disables commands that might compromise system security. Sqlcmd issues a warning and continues."`
34
+
DisableCmdAndWarnbool`short:"X" xor:"syscmd" help:"Disables commands that might compromise system security. Sqlcmd issues a warning and continues."`
35
+
// AuthenticationMethod is new for go-sqlcmd
36
+
AuthenticationMethodstring`xor:"auth" help:"Specifies the SQL authentication method to use to connect to Azure SQL Database. One of:ActiveDirectoryDefault,ActiveDirectoryIntegrated,ActiveDirectoryPassword,ActiveDirectoryInteractive,ActiveDirectoryManagedIdentity,ActiveDirectoryServicePrincipal,SqlPassword"`
37
+
UseAadbool`short:"G" xor:"auth" help:"Tells sqlcmd to use Active Directory authentication. If no user name is provided, authentication method ActiveDirectoryDefault is used. If a password is provided, ActiveDirectoryPassword is used. Otherwise ActiveDirectoryInteractive is used."`
35
38
DisableVariableSubstitutionbool`short:"x" help:"Causes sqlcmd to ignore scripting variables. This parameter is useful when a script contains many INSERT statements that may contain strings that have the same format as regular variables, such as $(variable_name)."`
36
39
Variablesmap[string]string`short:"v" help:"Creates a sqlcmd scripting variable that can be used in a sqlcmd script. Enclose the value in quotation marks if the value contains spaces. You can specify multiple var=values values. If there are errors in any of the values specified, sqlcmd generates an error message and then exits"`
0 commit comments