Forum Discussion

stefanik's avatar
stefanik
Helper I
5 years ago
Solved

Set Log Analytics Workspace Credentials with SP and PowerBi API

Hi all,

i'm trying to set Anonymous access credentials for a Log Analytics Workspace gateway throught PowerBi API with a Service principal:

 

1) it is possible? I mean, i'm able to set it for Application insights or Sql Server credentials, but for Log Analytics no. I receive (from postman) an Unouthorized

 

this is the value for the API body:

 

{
  "credentialDetails": {
    "credentialType""Anonymous",
    "credentials""{\"credentialData\":\"\"}",
    "encryptedConnection""Encrypted",
    "encryptionAlgorithm""None",
    "privacyLevel""Organizational"
  }
}

 

and this is the error:

 

{
"error": {
"code": "DM_GWPipeline_Gateway_InvalidConnectionCredentials",
"pbi.error": {
"code": "DM_GWPipeline_Gateway_InvalidConnectionCredentials",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorCode",
"detail": {
"type": 1,
"value": "-2147467259"
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The credentials provided for the Web source are invalid. (Source at https://api.loganalytics.io/v1/workspaces/*********/query.)"
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2147467259"
}
},
{
"code": "Microsoft.Data.Mashup.CredentialError.DataSourceKind",
"detail": {
"type": 1,
"value": "Web"
}
},
{
"code": "Microsoft.Data.Mashup.CredentialError.DataSourcePath",
"detail": {
"type": 1,
"value": "https://api.loganalytics.io/v1/workspaces/*********/query"
}
},
{
"code": "Microsoft.Data.Mashup.CredentialError.Reason",
"detail": {
"type": 1,
"value": "AccessUnauthorized"
}
},
{
"code": "Microsoft.Data.Mashup.MashupSecurityException.DataSources",
"detail": {
"type": 1,
"value": "[{\"kind\":\"Web\",\"path\":\"https://api.loganalytics.io/v1/workspaces/*********/query\"}]"
}
},
{
"code": "Microsoft.Data.Mashup.MashupSecurityException.Reason",
"detail": {
"type": 1,
"value": "AccessUnauthorized"
}
}
],
"exceptionCulprit": 1
}
}
}

 

2) Needs the SP some specific grants against the workspace? I mean, actually it is the contributor of the workspace and i'm able to use it to publish the dataset to the service and for fill it with others types of credentials. The SP and Log Analytics Ws are in differnt subscriptions.

 

Actually i have only one table in the Pbix. In the table power query i ask for a token and call the Log Analytic Ws with the returned token.

 

In PowerBi Desktop sources i can see the token endpoint and the Log Analytic Ws endpoint (the same if i ask for gateways throught API with postman).

 

From PowerBi Desktop i'm able to set Anonymous access for the two, and all works well.

 

Thx

Stefanik

 

 

 

4 Replies