Forum Discussion

Nick_BI's avatar
Nick_BI
New Member
8 years ago
Solved

Multi Tenant Embedded

Hi all,    I was looking to see if this is possible, and if so, what steps would be needed to implement. I can't seem to find the correct information I need. We are using App Owns Data.    We hav...
  • v-ljerr-msft's avatar
    8 years ago

    Hi Nick_BI,

     

    Here is a good article in which a solution for data source connectivity and multi-tenancy of data is mentioned. Could you go to check if it helps in your scenario? :smileyhappy:

    For ISV applications (SaaS applications, etc), the separation of data is also concerns. The data of the company A will be different from the one of company B.

     

    In such a case, you can set and change the connection string or credentials using rest api.

     

    First you can get the data source id and gateway id by the following HTTP request.  (In this example, we assume that the type of data source is SQL Server.)
    Note that the following “id” in HTTP response is the data source id.

    GET https://api.powerbi.com/v1.0/myorg/groups/a4781858-f3ef-47c2-80a9-fa14845c833b/datasets/44a12ee1-8da7-4383-a2cf-89129ef6e1a7/Default.GetBoundGatewayDataSources
    Accept: application/json
    Authorization: Bearer eyJ0eXAiOi...
    HTTP/1.1 200 OK
    Content-Type: application/json; odata.metadata=minimal
    
    {
      "@odata.context": "http://df-app-scus-redirect.analysis.windows.net/v1.0/myorg/groups/a4781858-f3ef-47c2-80a9-fa14845c833b/$metadata#gatewayDatasources",
      "value": [
        {
          "id": "2a0bca27-a496-450c-80e0-05790ad8875f",
          "gatewayId": "d52ba684-afa8-484d-b5d5-790842b6ab9f",
          "datasourceType": "Sql",
          "connectionDetails": "{"server":"server01.database.windows.net","database":"db01"}"
        }
      ]
    }

    Using gateway id and data source id, you can set (or change) the credential of this data source as follows.

    PATCH https://api.powerbi.com/v1.0/myorg/gateways/d52ba684-afa8-484d-b5d5-790842b6ab9f/datasources/2a0bca27-a496-450c-80e0-05790ad8875f
    Accept: application/json
    Authorization: Bearer eyJ0eXAiOi...
    Content-Type: application/json; charset=utf-8
    
    {
      "credentialType": "Basic",
      "basicCredentials": {
        "username": "demouser",
        "password": "pass@word1"
      }
    }
    HTTP/1.1 200 OK

    The following changes the connection string for the data source via rest api. (The data source id is also changed when you change the connection string.)
    That is, you can import Power BI file and set the different connection string for each customer’s tenant.

    POST https://api.powerbi.com/v1.0/myorg/groups/a4781858-f3ef-47c2-80a9-fa14845c833b/datasets/44a12ee1-8da7-4383-a2cf-89129ef6e1a7/Default.SetAllConnections
    Accept: application/json
    Authorization: Bearer eyJ0eXAiOi...
    Content-Type: application/json; charset=utf-8
    
    {
      "connectionString": "data source=tsmatsuz-server2.database.windows.net;initial catalog=db02;persist security info=True;encrypt=True;trustservercertificate=False"
    }
    HTTP/1.1 200 OK


     

    Regards