external help file | Module Name | online version | schema |
---|---|---|---|
PowerShellKusto.dll-Help.xml |
PowerShellKusto |
2.0.0 |
Establishes a connection to a Kusto service endpoint.
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
[-Authority <String>]
[-UserId <String>]
[<CommonParameters>]
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
-Authority <String>
-ClientSecretCredential <PSCredential>
[<CommonParameters>]
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
-Authority <String>
-ClientId <Guid>
-Certificate <X509Certificate2>
[-UseTrustedIssuer]
[<CommonParameters>]
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
-Authority <String>
-ClientId <Guid>
-Thumbprint <String>
[<CommonParameters>]
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
[-Identity]
[-ClientId <Guid>]
[<CommonParameters>]
Connect-Kusto
-Cluster <Uri>
[[-Database] <String>]
[-AccessToken <SecureString>]
[-TokenType <String>]
[<CommonParameters>]
The Connect-Kusto
cmdlet is the main entry point for the cmdlets in this module and it's used to establish a connection with your Azure Data Explorer Cluster.
The available authentication methods are:
- User prompt
- System or User Managed Identity
- Certificate via
X509Certificate2
or Thumbprint - Secret
- User and Application Access Token
Connect-Kusto https://myCluster.zone.kusto.windows.net
Using this method the cmdlets in this module will prompt for authentication.
$connectKustoSplat = @{
Cluster = 'https://myCluster.zone.kusto.windows.net'
Authority = 'myTenantId or Primary Domain'
ClientSecretCredential = [pscredential]::new(
'myClientId',
(ConvertTo-SecureString mySecret -AsPlainText))
}
Connect-Kusto @connectKustoSplat
Note
For demo purposes, this example uses a hardcoded secret.
Ideally, you should get your credential object via Key Vault or Get-Credential
Connect-Kusto https://myCluster.zone.kusto.windows.net -Identity
$connectKustoSplat = @{
Identity = $true
ClientId = '697183e1-a4b0-457a-aa71-9a6e3df5f029'
Cluster = 'https://myCluster.zone.kusto.windows.net'
}
Connect-Kusto @connectKustoSplat
$connectKustoSplat = @{
Certificate = Get-ChildItem Cert:\CurrentUser\My\$myCertThumbprint
ClientId = '697183e1-a4b0-457a-aa71-9a6e3df5f029'
Cluster = 'https://myCluster.zone.kusto.windows.net'
Authority = 'myTenantId or Primary Domain'
}
Connect-Kusto @connectKustoSplat
$connectKustoSplat = @{
Thumbprint = $myCertThumbprint
ClientId = '697183e1-a4b0-457a-aa71-9a6e3df5f029'
Cluster = 'https://myCluster.zone.kusto.windows.net'
Authority = 'myTenantId or Primary Domain'
}
Connect-Kusto @connectKustoSplat
Connect-AzAccount
$token = Get-AzAccessToken -ResourceUrl https://api.kusto.windows.net -AsSecureString
$connectKustoSplat = @{
Cluster = 'https://myCluster.zone.kusto.windows.net'
AccessToken = $token.Token
}
Connect-Kusto @connectKustoSplat
This example demonstrates how to request an Access Token on behalf of a User to the https://api.kusto.windows.net
API.
For simplicity, this example uses Get-AzAccessToken
however the use of Az.Accounts
Module isn't mandatory. See Get an access token for more details.
The Tenant Id or Primary Domain where your Azure Data Explorer Cluster is located.
Type: String
Parameter Sets: UserPrompt
Aliases: TenantId
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: ClientCredential, Certificate, CertificateThumbprint
Aliases: TenantId
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
An X.509 certificate supplied during invocation.
Type: X509Certificate2
Parameter Sets: Certificate
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This non mandatory parameter determines which Database in your Cluster will be targetted on queries and ingestion.
Tip
The Invoke-*
and Set-*
cmdlets also offer supplying this value if it wasn't provided during connection.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Connects using a System or User Managed Identity.
Type: SwitchParameter
Parameter Sets: Identity
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The thumbprint of your certificate. The Certificate will be retrieved from the current user's certificate store.
Type: String
Parameter Sets: CertificateThumbprint
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Uses Trusted Issuer feature of Entra ID.
Type: SwitchParameter
Parameter Sets: Certificate
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The Client Id of your Application.
Type: Guid
Parameter Sets: Certificate, CertificateThumbprint
Aliases: ApplicationId
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: Guid
Parameter Sets: Identity
Aliases: ApplicationId
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The PSCredential object provides the application ID and client secret for service principal credentials.
Type: PSCredential
Parameter Sets: ClientCredential
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The Azure Data Explorer Url to connect to.
Type: Uri
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Performs user authentication with the indicated user name.
Type: String
Parameter Sets: UserPrompt
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies an Application or User bearer token.
Note
Access tokens do timeout and you'll have to handle their refresh.
Type: SecureString
Parameter Sets: ApplicationToken
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies if the bearer token is requested on behalf of a User
or Application
.
Type: String
Parameter Sets: AccessToken
Aliases:
Accepted values: User, Application
Required: False
Position: Named
Default value: User
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters. For more information, see about_CommonParameters.
This cmdlet produces no output.