<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set Service Principal s Dataset Owner in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/845019#M21380</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100012"&gt;@Jayendran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read the documentation and turns out the -Body parameter (sometimes called the content) is now required for POST operations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the invoke method looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post -Body ""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 14:34:29 GMT</pubDate>
    <dc:creator>dom99</dc:creator>
    <dc:date>2019-11-13T14:34:29Z</dc:date>
    <item>
      <title>Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/843862#M21369</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if someone can help me. I need to set an existing dataset to be owned by a service principal but cant seem to manage it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the two options I can see are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Manually set it - cant do this because setting manually assigns the dataset ownership as the logged in user, but you cant log in to the service as a service principal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. use the powershell API - same problem here, there doesnt seem to be an option to set who owns it, it just picks up the logged in user and I dont know how to log in via the API as a service principal. Found a take over script example here&amp;nbsp;&lt;A href="https://github.com/Azure-Samples/powerbi-powershell/blob/master/takeover-dataset.ps1" target="_blank" rel="noopener"&gt;https://github.com/Azure-Samples/powerbi-powershell/blob/master/takeover-dataset.ps1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 15:57:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/843862#M21369</guid>
      <dc:creator>dom99</dc:creator>
      <dc:date>2019-11-12T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844667#M21371</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/61563"&gt;@dom99&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using powershell it is possible&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already created the entier script and published here&lt;/P&gt;&lt;P&gt;&lt;A href="https://gallery.technet.microsoft.com/AzureDevOps-CICD-for-fefd58b8" target="_blank"&gt;https://gallery.technet.microsoft.com/AzureDevOps-CICD-for-fefd58b8&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The powershell scripts looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$applicationId = "" 
$clientsec = "" | ConvertTo-SecureString -AsPlainText -Force # 
 
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec 
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "" 
  
 
$workspacename="PowerBI_CICD_PROD" 
$datasetname="AdventureReports" 
##Getworksapce 
 
$workspace =Get-PowerBIWorkspace -Name $workspacename 
 
# GetDataSets 
$DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json 
 
 
# Get DataSet 
$datasets = $DatasetResponse.value 
 
     foreach($dataset in $datasets){ 
                if($dataset.name -eq $datasetname){ 
                $datasetid= $dataset.id; 
                break; 
                } 
 
            } 
 
## Take Over DataSet 
 
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:19:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844667#M21371</guid>
      <dc:creator>Jayendran</dc:creator>
      <dc:date>2019-11-13T09:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844706#M21373</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100012"&gt;@Jayendran&lt;/a&gt;&amp;nbsp;Hi, thanks for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great thank you thats exactly what I needed. I will try it out shortly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:40:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844706#M21373</guid>
      <dc:creator>dom99</dc:creator>
      <dc:date>2019-11-13T09:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844856#M21376</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100012"&gt;@Jayendran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried your script but unfortunatly the method below&amp;nbsp;fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Invoke-PowerBIRestMethod&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I successfully log in as the service principal and assign the values as required, the script works up until the very end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error message is:&lt;/P&gt;&lt;P&gt;Invoke-PowerBIRestMethod : One or more errors occurred.&lt;BR /&gt;At line:3 char:1&lt;BR /&gt;+ Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($da ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIR&lt;BR /&gt;estMethod], AggregateException&lt;BR /&gt;+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help with finding out why its not working? I found your powershell scripts you'd uploaded, very handy to have thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 11:51:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844856#M21376</guid>
      <dc:creator>dom99</dc:creator>
      <dc:date>2019-11-13T11:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844871#M21377</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/61563"&gt;@dom99&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Make sure that SPN have admin access to your Workspace.&lt;/LI&gt;&lt;LI&gt;Make sure the workspace id ,datasetid are properly passing to the script&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After you got the error run the below script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Resolve-PowerBIError
&lt;/LI-CODE&gt;&lt;P&gt;Which will gives you the exact error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 12:08:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/844871#M21377</guid>
      <dc:creator>Jayendran</dc:creator>
      <dc:date>2019-11-13T12:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/845019#M21380</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100012"&gt;@Jayendran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read the documentation and turns out the -Body parameter (sometimes called the content) is now required for POST operations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the invoke method looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post -Body ""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 14:34:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/845019#M21380</guid>
      <dc:creator>dom99</dc:creator>
      <dc:date>2019-11-13T14:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Set Service Principal s Dataset Owner</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/2693083#M37824</link>
      <description>&lt;P&gt;Hiya!&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;Although I am pretty late to this party here, I still wanted to distribute two blog posts that are very much related to this topic. So, in case someone finds him/herself in the situation where a service principal needs to own the power bi dataset, I hope you find any of the following helpful.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;Blog Post A:&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;&lt;A href="https://www.tackytech.blog/how-to-make-a-service-principal-the-owner-of-a-power-bi-dataset/" target="_blank"&gt;https://www.tackytech.blog/how-to-make-a-service-principal-the-owner-of-a-power-bi-dataset/&lt;/A&gt;&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;A walkthrough on how to take over a dataset by a service principal via an Azure DevOps pipeline. Likewise to the accepted answer in this thread here, the core is also a Powershell script that can be used outside an Azure DevOps pipeline as well.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;Blog Post B:&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;&lt;A href="https://www.tackytech.blog/how-to-retrieve-oauth2-access-tokens-for-data-sources-via-data-factory-to-refresh-power-bi-dataset/" target="_blank"&gt;https://www.tackytech.blog/how-to-retrieve-oauth2-access-tokens-for-data-sources-via-data-factory-to-refresh-power-bi-dataset/&lt;/A&gt;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;An ETL flow in Azure Data Factory where the data factory is responsible for updating the oauth2 token for all data sources in the power bi dataset&amp;nbsp;&lt;STRONG&gt;prior&lt;/STRONG&gt; to kickstarting the dataset refresh (via managed identity). Here, a prerequesite is that the dataset is owned by a service principal.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;Once again, I hope this is helping! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;/Tom&lt;BR /&gt;&lt;A href="https://www.tackytech.blog/" target="_blank" rel="noopener"&gt;https://www.tackytech.blog/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.instagram.com/tackytechtom/" target="_blank" rel="noopener"&gt;https://www.instagram.com/tackytechtom/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2023 19:40:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Set-Service-Principal-s-Dataset-Owner/m-p/2693083#M37824</guid>
      <dc:creator>tackytechtom</dc:creator>
      <dc:date>2023-04-16T19:40:02Z</dc:date>
    </item>
  </channel>
</rss>

