| external help file | PowerShellKusto.dll-Help.xml |
|---|---|
| Module Name | PowerShellKusto |
| online version | https://github.com/santisq/PowerShellKusto/blob/main/docs/en-US/Connect-Kusto.md |
| schema | 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
X509Certificate2or Thumbprint - Secret
- User and Application Access Token
Connect-Kusto https://myCluster.zone.kusto.windows.netUsing 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 @connectKustoSplatNote
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 @connectKustoSplatConnect-AzAccount
$token = Get-AzAccessToken -ResourceUrl https://api.kusto.windows.net -AsSecureString
$connectKustoSplat = @{
Cluster = 'https://myCluster.zone.kusto.windows.net'
AccessToken = $token.Token
}
Connect-Kusto @connectKustoSplatThis 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: FalseType: String
Parameter Sets: ClientCredential, Certificate, CertificateThumbprint
Aliases: TenantId
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAn 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: FalseThis 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: FalseConnects 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: FalseThe 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: FalseUses 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: FalseThe 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: FalseType: Guid
Parameter Sets: Identity
Aliases: ApplicationId
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe 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: FalseThe 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: FalsePerforms 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: FalseSpecifies 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: FalseSpecifies 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: FalseThis cmdlet supports the common parameters. For more information, see about_CommonParameters.
This cmdlet produces no output.