Add-SqlAzureAuthenticationContext

Performs authentication to Azure and acquires an authentication token.

语法

DefaultAzureCredential Public

Add-SqlAzureAuthenticationContext
    [[-ExcludeCredential] <CredentialType[]>]
    [-DefaultAzureCredential]
    [<CommonParameters>]

DefaultAzureCredential Private

Add-SqlAzureAuthenticationContext
    [[-ExcludeCredential] <CredentialType[]>]
    [-ActiveDirectoryAuthority] <String>
    [-AzureKeyVaultResourceId] <String>
    [[-AzureManagedHsmResourceId] <String>]
    [-DefaultAzureCredential]
    [<CommonParameters>]

Interactive Public

Add-SqlAzureAuthenticationContext
    [-Interactive]
    [<CommonParameters>]

Interactive Private

Add-SqlAzureAuthenticationContext
    [-ActiveDirectoryAuthority] <String>
    [-AzureKeyVaultResourceId] <String>
    [[-AzureManagedHsmResourceId] <String>]
    [-Interactive]
    [<CommonParameters>]

ClientIdSecret Public

Add-SqlAzureAuthenticationContext
    [-ClientID] <String>
    [-Secret] <String>
    [-Tenant] <String>
    [<CommonParameters>]

ClientIdSecret Private

Add-SqlAzureAuthenticationContext
    [-ClientID] <String>
    [-Secret] <String>
    [-Tenant] <String>
    [-ActiveDirectoryAuthority] <String>
    [-AzureKeyVaultResourceId] <String>
    [[-AzureManagedHsmResourceId] <String>]
    [<CommonParameters>]

ClientIdCertificate Public

Add-SqlAzureAuthenticationContext
    [-ClientID] <String>
    [-CertificateThumbprint] <String>
    [-Tenant] <String>
    [<CommonParameters>]

ClientIdCertificate Private

Add-SqlAzureAuthenticationContext
    [-ClientID] <String>
    [-CertificateThumbprint] <String>
    [-Tenant] <String>
    [-ActiveDirectoryAuthority] <String>
    [-AzureKeyVaultResourceId] <String>
    [[-AzureManagedHsmResourceId] <String>]
    [<CommonParameters>]

说明

The Add-SqlAzureAuthenticationContext cmdlet authenticates the specified principal account to Azure Resource Manager. Use this cmdlet with other cmdlets that interact with Azure resources, such as Azure Key Vault.

Module requirements: version 21+ on PowerShell 5.1; version 22+ on PowerShell 7.x.

示例

Example 1: Prompt a user for credentials to authenticate a user to Azure Resource Manager

Add-SqlAzureAuthenticationContext -Interactive

This command prompts a user for a username and a password and then authenticates the user to Azure Resource Manager.

Example 2: Authenticate a user to Azure Resource Manager

Add-SqlAzureAuthenticationContext -ClientID '00001111-aaaa-2222-bbbb-3333cccc4444' -Secret '[Placeholder]' -Tenant '11112222-bbbb-3333-cccc-4444dddd5555'

This command performs authentication of the application principal with the specified client ID, which has been defined in the specified tenant, to Azure Resource Manager.

Example 3: Use DefaultAzureCredential to authenticate a user to Azure Resource Manager

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 4: Use DefaultAzureCredential but exclude few credential types to authenticate a user to Azure Resource Manager

Add-SqlAzureAuthenticationContext -DefaultAzureCredential `
   -ExcludeCredentials EnvironmentCredential, AzureDeveloperCliCredential

This command acquires token using the following credential types, if enabled, will be tried, in order: WorkloadIdentityCredential, ManagedIdentityCredential, SharedTokenCacheCredential, VisualStudioCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, InteractiveBrowserCredential. NOTE that EnvironmentCredential, AzureDeveloperCliCredential are excluded from the above types.

参数

-ActiveDirectoryAuthority

Specifies the base authority for Azure Active Directory authentication. Same value as the ActiveDirectoryAuthority property from the Azure PowerShell Environment object.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

DefaultAzureCredential Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
Interactive Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AzureKeyVaultResourceId

Specifies the resource ID for Azure Key Vault services. Same value as the AzureKeyVaultServiceEndpointResourceId property from the Azure PowerShell Environment object.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

DefaultAzureCredential Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
Interactive Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-AzureManagedHsmResourceId

Specifies the resource ID for the Azure Managed HSM service. Use this parameter to override the default value https://managedhsm.azure.net when your managed HSM resource is in an Azure instance other than the Azure public cloud.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

DefaultAzureCredential Private
Position:2
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
Interactive Private
Position:2
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:2
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:2
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-CertificateThumbprint

Specifies thumbprint to be used to identify the certificate to use. The cmdlet will search both CurrentUser and LocalMachine certificate stores.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ClientIdCertificate Public
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ClientID

Specifies the application client ID.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ClientIdSecret Public
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Public
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DefaultAzureCredential

Indicates that this cmdlet uses DefaultAzureCredential for acquiring token. The following credential types, if enabled, will be tried, in order:

  • EnvironmentCredential
  • WorkloadIdentityCredential
  • ManagedIdentityCredential
  • SharedTokenCacheCredential
  • VisualStudioCredential
  • VisualStudioCodeCredential
  • AzureCliCredential
  • AzurePowerShellCredential
  • AzureDeveloperCliCredential
  • InteractiveBrowserCredential

Refer to DefaultAzureCredential Class for more information on each credential type.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

DefaultAzureCredential Public
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DefaultAzureCredential Private
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ExcludeCredential

Indicates that DefaultAzureCredential should exclude the list of credential types specified while acquiring a token.

参数属性

类型:

CredentialType[]

默认值:None
接受的值:EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, SharedTokenCacheCredential, VisualStudioCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential, InteractiveBrowserCredential
支持通配符:False
不显示:False

参数集

DefaultAzureCredential Public
Position:1
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
DefaultAzureCredential Private
Position:1
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Interactive

Indicates that this cmdlet prompts the user for credentials.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

Interactive Public
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
Interactive Private
Position:0
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Secret

Specifies the application secret.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ClientIdSecret Public
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Tenant

Specifies a tenant in Azure.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ClientIdSecret Public
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdSecret Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Public
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
ClientIdCertificate Private
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输出

System.Object