Azure Data Explorer: LightIngest Managed Identity Authentication Issue

01725609 105 Reputation points
2025-10-03T09:43:00.3466667+00:00

Hi all

Hoping somebody could help me out here.

We currently are trying to run LightIngest in a containerapp job in order to ingest massive amounts of data into adx, and do this with extra control mechanisms.

however, the authentication via managed identity seems to fail constantly (the ingestion part)

the visual below shows all permissions that have been assigned to the managed identity

User's image

However, for some reason i'm still getting the following error

Ingestion with Managed_Identity '' to database '*****'* is not allowed by policy.

My lightIngest command is like this

LightIngest "https://{ingesturi};Fed=true" -managedIdentity:"{clientId}" -connectToStorageWithManagedIdentity:"{clientId}" -ingestWithManagedIdentity:"{clientId}" -sourcePath:"commpletepath;managed_identity={objectid}" -database:"databasename" -table:"tablename" -format:"csv" -pattern:"*" -ingestionMappingRef:"mappingname" -ignoreFirstRow:True -tag:"" -creationTimePattern:"/'yyyy/MM/dd'/" -dontWait:True -interactive:False -listOnly:False

I've put the even put the managed identity policy at a cluster and database level, but I keep getting the same error.

Am i missing something? I cannot seem to locate the issue. the command works perfectly when running locally using storage account key or azure cli, so it has to do with the MI authentication

Thank you

Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pratyush Vashistha 5,125 Reputation points Microsoft External Staff Moderator
    2025-10-08T09:35:47.32+00:00

    Hello 01725609,

    Thank you for posting your question on the Microsoft Q&A portal and for providing the detailed architecture diagram. It is very helpful for understanding your setup.

    I understand you are facing an "Ingestion not allowed by policy" error when using LightIngest with a User-Assigned Managed Identity in an Azure Container App, despite having configured the necessary permissions as shown in your diagram.

    The error message Ingestion with Managed_Identity '' to database ... is not allowed by policy is a strong indicator of the root cause. The empty single quotes ('') suggest that the Azure Data Explorer (ADX) ingestion service is not receiving the identity's ID. This typically happens when the authentication token is not correctly requested or presented by the client application (LightIngest).

    Based on your diagram and command, the permissions appear to be correctly set. The issue is most likely in the LightIngest command itself, specifically the connection string used to authenticate with ADX.

    The most reliable way to authenticate with ADX using a managed identity is to specify the ADX cluster's resource ID in the connection string. This ensures the Kusto client library requests a token for the correct audience.

    • Action: Modify the connection string to include the mi_res_id parameter.
    • Find your ADX Cluster Resource ID: You can find this on the Properties page of your ADX cluster in the Azure portal. It will look like this: /subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.Kusto/clusters/{cluster-name}

    Your new connection string should be: "https://{ingest-cluster-uri};Fed=true;mi_res_id={your-adx-cluster-resource-id}"

    When running in an Azure environment like a Container App where the managed identity is already assigned, you often don't need to specify the identity's client ID in multiple command-line flags. The environment and the mi_res_id in the connection string provide enough context.

    • Action: Try simplifying your command by removing the explicit -managedIdentity, -connectToStorageWithManagedIdentity, and -ingestWithManagedIdentity flags. The tool should automatically pick up the assigned identity.
    • The -sourcePath argument must still contain the managed_identity={objectid} parameter, as this is used by the ADX service on the backend to access storage.

    Here is a revised version of your command:

    # Ensure you replace the placeholders with your actual values
    $ingestUri = "https_ingestion_uri_of_your_cluster"
    $adxResourceId = "/subscriptions/.../resourceGroups/.../providers/Microsoft.Kusto/clusters/..."
    $miObjectId = "object_id_of_your_managed_identity"
    $sourcePath = "https://youraccount.blob.core.windows.net/yourcontainer;managed_identity=" + $miObjectId
    LightIngest "$ingestUri;Fed=true;mi_res_id=$adxResourceId" `
      -sourcePath:$sourcePath `
      -database:"databasename" `
      -table:"tablename" `
      -format:"csv" `
      -pattern:"*" `
      -ingestionMappingRef:"mappingname"
    

    Your diagram indicates you have set the "ADX Managed Identity Policy". It is crucial to ensure the Object ID in this policy exactly matches the Object ID (also known as Principal ID) of your user-assigned managed identity.

    • Action: Run the following command in your ADX database to double-check the policy.
    .show database YourDatabaseName policy managed_identity
    
    • Confirm that the ObjectId in the output matches the Object ID of your identity and that AllowedUsages includes NativeIngestion.
        .alter-merge database YourDatabaseName policy managed_identity ```json
        [
            {
                "ObjectId": "your-managed-identity-object-id",
                "AllowedUsages": "NativeIngestion"
            }
        ]
        ```*
        
      

    To help us further if the issue persists, could you please confirm the following?

    1. In your -sourcePath argument, are you using the Object (Principal) ID of the Managed Identity for the {objectid} placeholder, or are you using the Client ID? The Object ID is required here.
    2. Could you share the output of the .show database YourDatabaseName policy managed_identity command (with the Object ID redacted if necessary)?

    References

    I hope these steps help you resolve the authentication issue. Please let us know how it goes.

    Please "Accept as Answer" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    Thanks

    Pratyush


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.