microsoft / SQLServerPSModule

This repo is the home of SQL Server PowerShell Module development.
MIT License
45 stars 1 forks source link

Support all credential types for Add-SqlAzureAuthenticationContext #81

Closed sejagada closed 3 hours ago

sejagada commented 3 weeks ago

Currently, Add-SqlAzureAuthenticationContext supports only interactive browser login. We would be supporting all credential types supported by DefaultAzureCredential - EnvironmentCredential WorkloadIdentityCredential ManagedIdentityCredential SharedTokenCacheCredential VisualStudioCredential VisualStudioCodeCredential AzureCliCredential AzurePowerShellCredential AzureDeveloperCliCredential InteractiveBrowserCredential

Example 1: Add-SqlAzureAuthenticationContext -DefaultAzureCredential This command acquires token using the following credential types, if enabled, will be tried, in order: EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, SharedTokenCacheCredential, VisualStudioCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential, InteractiveBrowserCredential.

Example 2: Users will have option to exclude a credential type. For instance, if users do not want to include VisualStudioCredential & AzureDeveloperCliCredential while using DefaultAzureCredential, they can specify the cmdlet parameters as below.

Add-SqlAzureAuthenticationContext -DefaultAzureCredential -ExcludeCredentials VisualStudioCredential, AzureDeveloperCliCredential

Example 3: Users cannot exclude all the credential types. Specifying all exclude credential options would result in an exception - "Add-SqlAzureAuthenticationContext: At least one credential type must be allowed when using the -DefaultAzureCredential parameter."

Add-SqlAzureAuthenticationContext -DefaultAzureCredential -ExcludeCredentials EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, SharedTokenCacheCredential, VisualStudioCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential, InteractiveBrowserCredential

Matteo-T commented 3 hours ago

Fixed in v22.3.0