locked
How to retrieve query details from Azure Log Analytics using 2 web activities in ADF RRS feed

  • Question

  • Hi All,

    I have enabled all the Diagnostic Settings of my ADF and in Log Analytics workspace i am able to query all the required tables.

    Now i want to get the Log Analytics query output in ADF pipeline.

    For this i have created a Service Principal with Log Analytics API Data.Read permission and have also created a Secret for this SP.

    I have also added this Service Principal in my Log Analytics Workspace with Log Analytics Reader role permission.

    I am able to get the required query output when i am using Web Activity to get the OAuth Token and then Copy Activity with RestService DataSet to create a file in blob.

    But instead of using Copy Activity i want to use Web Activity to retrieve the required data.

    In the 1st Web Activity i have provided the following info:

    URL - https://login.microsoft.com/tenantid/oauth2/token

    Method - POST

    Headers - Content-Type : application/x-www-form-urlencoded

    Body - grant_type=client_credentials&client_id=ClientIdOfMySP&resource=https://api.loganalytics.io/&client_secret=ClientSecretOfMySP

    My 1st web activity with all this information is running successfully and i am receiving the token.

    My 2nd web activity is as follows:

    URL - https://api.loganalytics.io/v1/workspaces/MyWorkSpaceId/query

    Method - POST

    Headers - 1) Authorization :  @concat(string(activity('Web1').output.token_type),'',string(activity('Web1').output.access_token))

    2) X-Api-Key : ClientSecretOfMySP

    3) Content-Type : application/json

    Body - {"query":"ADFPipelineRun"}

    The input provided to the 2nd activity is as follows:

    I am getting the following error when running this pipeline:

    I also tried providing contributor and owner access to the service principal on my log analytics workspace, but still getting the same error. 


    Monday, May 11, 2020 10:38 AM

All replies

  • Hello PriyaJha , 

    I suggest you to please try with postman/curl to query the log analytics data and then implement the same in ADF . 


    Thanks Himanshu
    ================
    If you think my answer helped you , please click "mark as answer " , this will be help other community members to get to the resolution faster
    Alone, we can do so little; together, we can do so much

    Tuesday, May 12, 2020 6:31 PM
  • Hello , 

    Just reaching out and checking if the postman/curl call worked for you ?


    Thanks Himanshu
    ================
    If you think my answer helped you , please click "mark as answer " , this will be help other community members to get to the resolution faster
    Alone, we can do so little; together, we can do so much

    Thursday, May 14, 2020 1:23 AM
  • Hello , 

    We have not heard back from you  . If you have a resolution please do share it here with the community , so that others can benefit from it .


    Thanks Himanshu
    ================
    If you think my answer helped you , please click "mark as answer " , this will be help other community members to get to the resolution faster
    Alone, we can do so little; together, we can do so much

    Monday, May 18, 2020 3:49 PM
  • HI Himanshu

    Thanks for your reply and sorry for late reply.

    Till now i have not explored Postman/curl call or tried any other method for this issue. 

    As soon as i would work on it, would update the progress here.

    Friday, May 22, 2020 9:37 AM