Power BI has a set of existing connectors which you can find them in Get Data
section of Power BI (or Power Query).However, this list is not including all types
of data sources.Power BI recently introduced a feature called Custom Data
Connector. These Data Connectors allow you to create new data sources, or customize
and extend an existing source. Your custom connector will appear in the list of Get
Data in Power BI, similar to other connectors.
1. Install Power Query SDK on Visual studio, Open Visual studio-->tools--
>Extensions and updates-->power Query SDK
After installing the SDK, then you should be able to create a project of type Data
Connector.
Once created, Data Connector project has a simple structure. It has some list of
files with below extensions,
<connector name>.pq file
<connector name>.query.pqcfile
combination of these two files(pq and query.pq) generates the custom connector’s
script which contians the code and metadata of the script and connection to the
data source
resources.resx: Resource file.
M Query is the Coding language for custom connector.
https://github.com/microsoft/DataConnectors--To get sample codes for ODBC
connectors and others-->once download and extart folder you could see sample folder
here.
Note: This is development folder from GIT Hub. Everytime GITHub team is updating
with new sample connector code.
Open Visual studio-->New project-->Select "data connector project"-->Give the new
connector name & location of your GitHub connector code file
(C:\Users\sri\Downloads\DataConnectors-master\DataConnectors-
master\samples\HelloWorld)
Once click ok-->both pqc and pq files should be open-->If you need to develop code,
you can-->Build(build solution)-->Once you build the project you can see new file
in samples/hello world/hello world/hello world/bin/debug/file name.mez file
4. create a Microsoftpower BI desktop\custom connectors directory in My documents
folder
5. Finally copy the extension file(.mez) into the directory.
6. Enable custom connector preview feature in power BI desktop(FIle-->option and
settings-->options-->custom data connector
7. Retart power Bi desktop
8. Up on restart, you can find the hello world customer connector in get data menu
in power bi desktop.
Note, to load extensions during development, you will need to lower the security
level for extensions in Power BI Desktop to enable loading unsigned/uncertified
connectors.
Go to File | Options and settings | Options
Go the Security tab
Under Data Extensions, select Allow any extension to load without warning or
validation
Restart Power BI Desktop
=================================================================================
Development of Microsoft Power BI Custom Connectors that work both on the Power BI
Desktop and the Power BI Service:
We can develop Power BI Custom Connectors for the following data sources:
Web.Contents---an extension for a REST API would make use of the Web.Contents
function to make HTTP requests.
OData.Feed----OData.Feed is for Url access,OData is an open data access protocol to
provide access to a data source on a website.
Odbc.DataSource
AdoDotNet.DataSource
OleDb.DataSource
Example:
TripPinImpl = (url as text) =>
let
source=OData.Feed("Url address")
in
Source
TripPinImpl = (url as text) =>
let
source = Web.Contents(url, [ Headers = DefaultRequestHeaders ]),
json = Json.Document(source)
in
json;
Using Authentications such as All custom connectors must support atleast one form
of authentication
Implict(Anonymous) --no authentication required
windows
API Key --A password without username
Username/Password,
OAuth 2.0 --only feasible with custom connector
Authentication = [
OAuth = [
StartLogin = StartLogin,
FinishLogin = FinishLogin,
Refresh = Refresh,
Logout = Logout
],
Key = [],
UsernamePassword = [],
Windows = [],
Implicit = []
]
The developed Custom Connector will be able to work and be refreshed on the Power
BI Service using a Power BI Gateway
===================================================================================
===================================================================================
=
===================================================================================
================
About code and its important funtions and Paramemters:
Custom connector code is categorizes in 3 parts.
//Data connector logic---In this we have shared ConnectorName.Contents function
which will return the input result set for Power BI when connecting to this
connector.
// Data Source Kind description---Source Authentication
// Data Source UI publishing description---Publish the connector output data into
power BI. We have two functions here <connector name>.Publish, <connector
name>.Icons
A shared function (TripPin.Feed) that sets the parameter type to Uri.Type
Uri.type results in drop down box in the credential dialog. The user can select the
level of URL to apply the credential.
Which M Functions Are Only Available To Custom Data Connectors?
CryptoAlgorithm.Type ,CryptoAlgorithm.SHA1 ,CryptoAlgorithm.SHA256
,Crypto.CreateHmac ,Crypto.CreateHash ,Web.SignForOAuth1 ,OAuth1.Type
,OAuth1.HMACSHA1 ,OAuth1.RSASHA1 ,Extension.Module ,Extension.CurrentCredential
,Extension.CurrentApplication ,Extension.CredentialError ,Extension.LoadString
,Extension.Contents ,Credential.AccessDenied ,Credential.AccessForbidden
,Credential.EncryptionNotSupported ,Credential.NativeQueryPermission
,Error.Unexpected ,Uri.Type ,Binary.End ,Action.Type ,Action.Sequence
,Action.Return ,Action.Try ,Action.DoNothing ,ValueAction.Replace
,ValueAction.NativeStatement ,TableAction.InsertRows ,TableAction.UpdateRows
,TableAction.DeleteRows ,WebAction.Request ,Delta.Since