visual-studio-codepowerbi-datasource

Power Query SDK "Hello world" fails with "CredentialMissing"


Trying to create a custom data connector for Power BI. Installed Visual Studio Code and imported the Power Query SDK extension. Created a new project which I called FirstConnector which creates a Hello World. Changed nothing. Ran it and it failed immediately.

I run the file FirstConnector.query.pq:

// Use this file to write queries to test your data connector
let
    result = FirstConnector.Contents()
in
    result

It calls the function in the file FirstConnector.pq:

// This file contains your Data Connector logic
[Version = "1.0.0"]
section FirstConnector;

[DataSource.Kind="FirstConnector", Publish="FirstConnector.Publish"]
shared FirstConnector.Contents = (optional message as text) =>
    let
        _message = if (message <> null) then message else "(no message)",
        a = "Hello from FirstConnector: " & _message
    in
        a;

// Data Source Kind description
FirstConnector = [
    Authentication = [
        // Key = [],
        // UsernamePassword = [],
        // Windows = [],
        Anonymous = []
    ]
];

// Data Source UI publishing description
FirstConnector.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = FirstConnector.Icons,
    SourceTypeImage = FirstConnector.Icons
];

FirstConnector.Icons = [
    Icon16 = { Extension.Contents("FirstConnector16.png"), Extension.Contents("FirstConnector20.png"), Extension.Contents("FirstConnector24.png"), Extension.Contents("FirstConnector32.png") },
    Icon32 = { Extension.Contents("FirstConnector32.png"), Extension.Contents("FirstConnector40.png"), Extension.Contents("FirstConnector48.png"), Extension.Contents("FirstConnector64.png") }
];

Here are the execution messages:

enter image description here enter image description here enter image description here


Solution

  • You have to set the credentials for the query. In the Primary Side Bar on the left of VS Code you should have the 'POWER QUERY SDK' group and from this list you can select 'Set Credential'

    Power Query SDK

    When you click this item it will open the command pallet and you can follow the prompts. The only credential option you will have is anonymous.

    NB: If you can't see the Power Query SDK menu item then double check you have installed the SDK (which you would have done considering you have the default example created) or right click on any of the other menu items and make sure there is a tick next to Power Query SDK.