<?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: Upload CSV from Powershell to Lakehouse in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4824194#M12300</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also use a fabric notebook.&lt;/P&gt;&lt;P&gt;I always use notebooks for this because I find them easier to handle. It's another approach, and you might like it.&lt;/P&gt;&lt;P&gt;You can find an example in my GitHub repository. I use it to retrieve cost data, but some of it can be adopted for other purposes. An Azure Key Vault can also be integrated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Click here for the repository.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/renefuerstenberg/Microsoft_Fabric/tree/main/fabric_nb_code_get_azure_cost_data_example" target="_blank" rel="noopener"&gt;https://github.com/renefuerstenberg/Microsoft_Fabric/tree/main/fabric_nb_code_get_azure_cost_data_example&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An other option is to use a Data Pipeline and us a Copy Activity when a Notebook is oversized. Its easy to create it.&lt;/P&gt;&lt;P&gt;Steps:&lt;/P&gt;&lt;P&gt;1. Connect you local environment with Data Gateway&lt;/P&gt;&lt;P&gt;2. Create a Data Pipeline and use a Copy Activity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need any further help, please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
    <pubDate>Fri, 12 Sep 2025 06:30:30 GMT</pubDate>
    <dc:creator>spaceman127</dc:creator>
    <dc:date>2025-09-12T06:30:30Z</dc:date>
    <item>
      <title>Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4815784#M12122</link>
      <description>&lt;P&gt;Im running in some trouble with permissions, trying to upload some CSV to a lakehouse.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Install-Module -Name Az -AllowClobber -Scope CurrentUser

$TenantId = "xx"
$ClientId = "xx"
$ClientSecret = "xx"

$AuthUrl = "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token"
$Body = @{
client_id = $ClientId
scope = "https://storage.azure.com/.default" # Required for OneLake API
client_secret = $ClientSecret
grant_type = "client_credentials"
}

# Get Access Token
$TokenResponse = Invoke-RestMethod -Method Post -Uri $AuthUrl -Body $Body -ContentType "application/x-www-form-urlencoded"
$AccessToken = $TokenResponse.access_token
Write-Host "Access Token: $AccessToken"
$OneLakeUri = "https://onelake.dfs.fabric.microsoft.com/aaaaa/bbbbb/Files"

Invoke-WebRequest -Method GET -Uri $OneLakeUri -Headers @{
Authorization = "Bearer $AccessToken"
}

Define variables
$WorkspaceId = "aaaa"  # The Fabric workspace ID
$LakehouseName = "lh_dev_dwh"  # The name of your lakehouse
$FolderPath = "Files"  # Target folder in OneLake to upload the file to
$FileName = "Daily_Report_XXX.csv"  # File to upload
$LocalFilePath = "C:\taod_export\Daily_Report_XXX.csv"  # Path to the file on your local machine

# OneLake API endpoint
#$OneLakeUri = "https://$WorkspaceId.lakehouse.fabric.microsoft.com/$LakehouseName/$FolderPath/$FileName"
$OneLakeUri = "https://onelake.dfs.fabric.microsoft.com/aaaa/bbbb/Files/Daily_Report_XXX.csv" 



# Read the file content
$FileContent = Get-Content -Path $LocalFilePath -Raw -Encoding Byte

# Upload the file
Invoke-RestMethod -Method Put -Uri $OneLakeUri -Headers @{ 
    "Authorization" = "Bearer $AccessToken" 
    "Content-Type"  = "application/octet-stream"
} -Body $FileContent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I am trying, and i hope this is the right way to do it. Please let me know if there is an easier way to do it via Powershell.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;My main Problem right now is, even tho I put the &lt;SPAN&gt;Storage Blob Data Contributor and the Storage Account Contributer in my subscritpion to my AD App and the underlying Fabric ressource is inherting it, when I decode my access token at jwt.io i wont get any "role". So with this missing permissions my script wont work. I tried GPTing and I am now running in circles. Does anyone have a better approach or an idea of what to test next?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;throwserror&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 14:35:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4815784#M12122</guid>
      <dc:creator>throwserror</dc:creator>
      <dc:date>2025-09-03T14:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4815809#M12123</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;What’s Going Wrong&lt;/P&gt;&lt;P&gt;You're using &lt;STRONG&gt;client credentials flow&lt;/STRONG&gt; to get an access token for OneLake, but you're not seeing any roles in the token payload. That’s expected behavior for this flow unless you're using &lt;STRONG&gt;role-based access control (RBAC)&lt;/STRONG&gt; via &lt;STRONG&gt;Microsoft Entra ID (formerly Azure AD)&lt;/STRONG&gt; and have explicitly assigned &lt;STRONG&gt;app roles&lt;/STRONG&gt; or &lt;STRONG&gt;API permissions&lt;/STRONG&gt; to your app registration.&lt;/P&gt;&lt;P&gt;The key issue: &lt;STRONG&gt;Storage Blob Data Contributor&lt;/STRONG&gt; and &lt;STRONG&gt;Storage Account Contributor&lt;/STRONG&gt; are &lt;STRONG&gt;Azure RBAC roles&lt;/STRONG&gt;, but OneLake in Microsoft Fabric doesn't use traditional Azure Storage RBAC directly. Instead, it uses &lt;STRONG&gt;Microsoft Fabric-specific permissions&lt;/STRONG&gt; and &lt;STRONG&gt;Entra ID scopes&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recommended Fixes and Alternatives&lt;/P&gt;&lt;P&gt;1. &lt;STRONG&gt;Use &lt;FONT color="#333300"&gt;Connect-AzAccount &lt;/FONT&gt;Instead of Client Credentials&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you're just uploading files manually via PowerShell, the simplest route is to use &lt;STRONG&gt;interactive login&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Install-Module Az.Storage -Force Connect-AzAccount $ctx = New-AzStorageContext -StorageAccountName "onelake" -UseConnectedAccount -Endpoint "fabric.microsoft.com" Set-AzDataLakeGen2ItemContent -Context $ctx ` -FileSystem "" ` -Path ".lakehouse/Files/Daily_Report_XXX.csv" ` -Source "C:\taod_export\Daily_Report_XXX.csv"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This avoids the whole token dance and uses your signed-in identity, which already has access to the workspace.&lt;/P&gt;&lt;P&gt;Reference: &lt;A href="https://learn.microsoft.com/en-us/fabric/onelake/onelake-powershell" target="_blank" rel="noopener"&gt;Microsoft’s PowerShell guide for OneLake&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &lt;STRONG&gt;If You Must Use Client Credentials&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then you need to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Register your app in Microsoft Entra ID&lt;/LI&gt;&lt;LI&gt;Assign &lt;STRONG&gt;API permissions&lt;/STRONG&gt; like Storage delegated access or Files.ReadWrite.All&lt;/LI&gt;&lt;LI&gt;Use &lt;STRONG&gt;delegated permissions&lt;/STRONG&gt; if possible (requires user context)&lt;/LI&gt;&lt;LI&gt;Or configure &lt;STRONG&gt;app roles&lt;/STRONG&gt; and assign them to your app&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But this is complex and not well-supported for OneLake yet. The REST API is still evolving, and many operations expect &lt;STRONG&gt;user context&lt;/STRONG&gt;, not app-only tokens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &lt;STRONG&gt;Use AzCopy with Entra ID Auth&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you're automating uploads, consider using &lt;A href="https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-auth" target="_blank" rel="noopener"&gt;AzCopy with Entra ID&lt;/A&gt;. It supports OneLake and handles token acquisition and permissions more gracefully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What to Test Next&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Try switching to Connect-AzAccount and New-AzStorageContext for a quick win&lt;/LI&gt;&lt;LI&gt;If you must use client credentials, inspect the token’s scp (scope) claim—not just roles&lt;/LI&gt;&lt;LI&gt;Check whether the Fabric workspace has granted access to your app via &lt;STRONG&gt;Microsoft Fabric Admin Portal&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Use the &lt;A href="https://www.purplefrogsystems.com/2024/01/upload-files-to-a-lakehouse-in-onelake-using-powershell/" target="_blank" rel="noopener"&gt;Purple Frog PowerShell script&lt;/A&gt; as a reference—it’s tailored for OneLake uploads&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 15:01:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4815809#M12123</guid>
      <dc:creator>anilgavhane</dc:creator>
      <dc:date>2025-09-03T15:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4816873#M12147</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P data-start="118" data-end="559"&gt;Thanks for posting in Microsoft Fabric Community.&lt;/P&gt;
&lt;P data-start="118" data-end="559"&gt;As &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="87706" data-lia-user-login="anilgavhane" class="lia-mention lia-mention-user"&gt;anilgavhane&lt;/a&gt;&amp;nbsp; already mentioned, the behavior you see with the token not containing&amp;nbsp;roles&amp;nbsp;is expected when using client credentials. What matters for OneLake is not Azure Storage RBAC but permissions within the Fabric workspace. The service principal must be added as a Member, Contributor, or Admin in the Fabric workspace itself, since Fabric manages its own access model and does not honor Azure RBAC roles.&lt;/P&gt;
&lt;P data-start="118" data-end="559"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="561" data-end="1022" data-unlink="true"&gt;Also, when requesting the token, please make sure the scope is set to&amp;nbsp;https://onelake.dfs.fabric.microsoft.com/.default instead of https://storage.azure.com/.default.&lt;/P&gt;
&lt;P data-start="561" data-end="1022"&gt;Using the storage endpoint scope is valid for Azure Storage accounts, but OneLake requires its own scope.&lt;/P&gt;
&lt;P data-start="561" data-end="1022"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="561" data-end="1022"&gt;For more details on SPNs:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-warehouse/service-principals" target="_blank" rel="noopener"&gt;Service Principals in Fabric Data Warehouse - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P data-start="561" data-end="1022"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="907" data-end="1027"&gt;In addition, for service principal access to work, the following tenant settings need to be enabled by a Fabric admin:&lt;/P&gt;
&lt;OL class="lia-list-style-type-lower-roman" data-start="1029" data-end="1160"&gt;
&lt;LI data-start="1029" data-end="1083"&gt;
&lt;P data-start="1031" data-end="1083"&gt;Service principals can call Fabric public APIs&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="1084" data-end="1160"&gt;
&lt;P data-start="1086" data-end="1160"&gt;Users can access data stored in OneLake with apps external to Fabric&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Hope this helps. Please reach out for further assistance.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also thanks to&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="87706" data-lia-user-login="anilgavhane" class="lia-mention lia-mention-user"&gt;anilgavhane&lt;/a&gt;&amp;nbsp;for detailed explanation and for sharing useful resources.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Sep 2025 12:11:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4816873#M12147</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-09-04T12:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4819858#M12186</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Just wanted to check if the responses provided were helpful. If further assistance is needed, please reach out.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 10:07:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4819858#M12186</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-09-08T10:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4824164#M12299</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2025 05:12:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4824164#M12299</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-09-12T05:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4824194#M12300</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also use a fabric notebook.&lt;/P&gt;&lt;P&gt;I always use notebooks for this because I find them easier to handle. It's another approach, and you might like it.&lt;/P&gt;&lt;P&gt;You can find an example in my GitHub repository. I use it to retrieve cost data, but some of it can be adopted for other purposes. An Azure Key Vault can also be integrated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Click here for the repository.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/renefuerstenberg/Microsoft_Fabric/tree/main/fabric_nb_code_get_azure_cost_data_example" target="_blank" rel="noopener"&gt;https://github.com/renefuerstenberg/Microsoft_Fabric/tree/main/fabric_nb_code_get_azure_cost_data_example&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An other option is to use a Data Pipeline and us a Copy Activity when a Notebook is oversized. Its easy to create it.&lt;/P&gt;&lt;P&gt;Steps:&lt;/P&gt;&lt;P&gt;1. Connect you local environment with Data Gateway&lt;/P&gt;&lt;P&gt;2. Create a Data Pipeline and use a Copy Activity&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need any further help, please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2025 06:30:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4824194#M12300</guid>
      <dc:creator>spaceman127</dc:creator>
      <dc:date>2025-09-12T06:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Upload CSV from Powershell to Lakehouse</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4828139#M12379</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1348372" data-lia-user-login="throwserror" class="lia-mention lia-mention-user"&gt;throwserror&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;May I ask if the solutions provided have addressed your needs?&lt;/P&gt;
&lt;P&gt;If you need any further assistance, feel free to reach out.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;Also thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="644531" data-lia-user-login="spaceman127" class="lia-mention lia-mention-user"&gt;spaceman127&lt;/a&gt;&amp;nbsp;for sharing your valuable suggestions.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Sep 2025 07:03:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Upload-CSV-from-Powershell-to-Lakehouse/m-p/4828139#M12379</guid>
      <dc:creator>v-veshwara-msft</dc:creator>
      <dc:date>2025-09-17T07:03:57Z</dc:date>
    </item>
  </channel>
</rss>

