Auth issue connecting to OMS with primary shared key



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>'}<OMS workspace ID>/query


Our power BI query :


let AnalyticsQuery =
let Source = Json.Document(Web.Contents("",
",#"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 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:


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!