Auth issue connecting to OMS with primary shared key

%3CLINGO-SUB%20id%3D%22lingo-sub-1431895%22%20slang%3D%22en-US%22%3EAuth%20issue%20connecting%20to%20OMS%20with%20primary%20shared%20key%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431895%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20are%20pushing%20our%20log%20data%20to%20OMS%20with%20primary%20shared%20key.%26nbsp%3B%20When%20we%20are%20trying%20to%20connect%20to%20the%20query%20in%20this%20workspace%20from%20Power%20BI%20through%20Web%20API%20option%20with%20the%20same%20primary%20key%2C%20PowerBI%20is%20complaining%20%22we%20couldn't%20authenticate%20with%20the%20credentials%22.%20I%20am%20also%20trying%20to%20connect%20from%20command%20line%20to%20investigate%2C%20got%20the%20same%20issue.%26nbsp%3B%20I%20am%20not%20sure%20why%20the%20same%20key%20can%20be%20used%20to%20write%20data%20to%20the%20workspace%2C%20but%20it%20can%20not%20be%20allowed%20to%20read.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ecurl%20-v%20-H%20%40%7B'x-api-key'%3D%20'%3CPRIMARY%20share%3D%22%22%20key%3D%22%22%3E'%7D%20%3CA%20href%3D%22https%3A%2F%2Fapi.loganalytics.io%2Fv1%2Four%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fapi.loganalytics.io%2Fv1%2F%3COMS%20workspace%3D%22%22%20id%3D%22%22%3E%3C%2FOMS%3E%3C%2FA%3E%2Fquery%3C%2FPRIMARY%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOur%20power%20BI%20query%20%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Elet%20AnalyticsQuery%20%3D%3CBR%20%2F%3Elet%20Source%20%3D%20Json.Document(Web.Contents(%22%3CA%20href%3D%22https%3A%2F%2Fapi.loganalytics.io%2Fv1%2Fworkspaces%2Fbe7e6d59-dd55-4431-94e4-5b164bf4c78a%2Fquery%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fapi.loganalytics.io%2Fv1%2Fworkspaces%2Fbe7e6d59-dd55-4431-94e4-5b164bf4c78a%2Fquery%3C%2FA%3E%22%2C%20%3CBR%20%2F%3E%5BQuery%3D%5B%23%22query%22%3D%22Expirables_CL%20%3CBR%20%2F%3E%22%2C%23%22x-ms-app%22%3D%22OmsAnalyticsPBI%22%2C%23%22timespan%22%3D%22P1D%22%2C%23%22prefer%22%3D%22ai.response-thinning%3Dtrue%22%5D%2CTimeout%3D%23duration(0%2C0%2C4%2C0)%2C%20ApiKeyName%3D%22X-API-key%22%5D))%2C%3CBR%20%2F%3ETypeMap%20%3D%20%23table(%3CBR%20%2F%3E%7B%20%22AnalyticsTypes%22%2C%20%22Type%22%20%7D%2C%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%7B%20%22string%22%2C%20Text.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22int%22%2C%20Int32.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22long%22%2C%20Int64.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22real%22%2C%20Double.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22timespan%22%2C%20Duration.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22datetime%22%2C%20DateTimeZone.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22bool%22%2C%20Logical.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22guid%22%2C%20Text.Type%20%7D%2C%3CBR%20%2F%3E%7B%20%22dynamic%22%2C%20Text.Type%20%7D%3CBR%20%2F%3E%7D)%2C%3CBR%20%2F%3EDataTable%20%3D%20Source%5Btables%5D%7B0%7D%2C%3CBR%20%2F%3EColumns%20%3D%20Table.FromRecords(DataTable%5Bcolumns%5D)%2C%3CBR%20%2F%3EColumnsWithType%20%3D%20Table.Join(Columns%2C%20%7B%22type%22%7D%2C%20TypeMap%20%2C%20%7B%22AnalyticsTypes%22%7D)%2C%3CBR%20%2F%3ERows%20%3D%20Table.FromRows(DataTable%5Brows%5D%2C%20Columns%5Bname%5D)%2C%20%3CBR%20%2F%3ETable%20%3D%20Table.TransformColumnTypes(Rows%2C%20Table.ToList(ColumnsWithType%2C%20(c)%20%3D%26gt%3B%20%7B%20c%7B0%7D%2C%20c%7B3%7D%7D))%3CBR%20%2F%3Ein%3CBR%20%2F%3ETable%3CBR%20%2F%3Ein%20AnalyticsQuery%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1431895%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Hello, 

We are pushing our log data to OMS with primary shared key.  When we are trying to connect to the query in this workspace from Power BI through Web API option with the same primary key, PowerBI is complaining "we couldn't authenticate with the credentials". I am also trying to connect from command line to investigate, got the same issue.  I am not sure why the same key can be used to write data to the workspace, but it can not be allowed to read. 

 

curl -v -H @{'x-api-key'= '<Primary share key>'} https://api.loganalytics.io/v1/<OMS workspace ID>/query

 

Our power BI query :

 

let AnalyticsQuery =
let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/be7e6d59-dd55-4431-94e4-5b164bf4c78a/query",
[Query=[#"query"="Expirables_CL
",#"x-ms-app"="OmsAnalyticsPBI",#"timespan"="P1D",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0), ApiKeyName="X-API-key"])),
TypeMap = #table(
{ "AnalyticsTypes", "Type" },
{
{ "string", Text.Type },
{ "int", Int32.Type },
{ "long", Int64.Type },
{ "real", Double.Type },
{ "timespan", Duration.Type },
{ "datetime", DateTimeZone.Type },
{ "bool", Logical.Type },
{ "guid", Text.Type },
{ "dynamic", Text.Type }
}),
DataTable = Source[tables]{0},
Columns = Table.FromRecords(DataTable[columns]),
ColumnsWithType = Table.Join(Columns, {"type"}, TypeMap , {"AnalyticsTypes"}),
Rows = Table.FromRows(DataTable[rows], Columns[name]),
Table = Table.TransformColumnTypes(Rows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{3}}))
in
Table
in AnalyticsQuery

1 Reply

Hi @hiumingw,
I am not clear on how you are approaching this.

Log Analytics indeed uses an app key for writing data into a workspace, however, AFAIK, Power BI authenticates with Azure to gain access to data.

See the attached Power BI documentation:https://docs.microsoft.com/en-us/power-bi/admin/service-admin-power-bi-security

 

Can you try and authenticate as a user who has access to the workspace in Power BI and let me know how it goes?

If I misunderstood your question or missed something in what you are trying to do - please let me know.

Hope this reply is helpful!

R