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 have over 100 clients, each with their own database. I have created a report using one of our dev sites databases as the data source. I am looking to create a copy for each of the clients' databases (all tables are the same across databases and the report) and embed them. I am trying to avoid having to manually change the database connection for each client, as that's very time consuming. Is it best to have a separate workspace for each client? Any info is greatly appreciated.

 

Thanks!

  Nick

  • 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

5 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Microsoft Employee

    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

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is currently still a subject on how to implement multitenancy.

      The above solution doesn't really seem realistic, for every call to a report, api call to change datasource, while report being used by X clients, each having numerous users.

    • joegei's avatar
      joegei
      New Member

      What if I want a Multi Tenant Solution with Streaming Data. Then I don't have a PBIX file which contains all the reports and dashboards.

      So far we've come to a solution of re-creating the dashboard/report in every workspace. This may work for 10 or so customers, but when we're looking at 50 or more, this is not a practical solution. 

       

      Is there another way to support multi tenancy with streaming data?