Search code examples
azurepowershellcsvblobazure-data-lake

How to read content from a CSV or text from ADLS Gen2 location using powershell without downloading that file?


I have a use case where I have to read some files from Blob.. but I am unable to do it..I am only getting the Metadata. How to do the same without download the file and importing?

Get-AzDataLakeGen2ItemContent


Solution

  • I agree the discussion in the comments, there is no way you can read the blob directly from the blob storage. You need to download the blob locally and then read the contents from it using Import-CSV. Below is the complete code.

    $context = New-AzStorageContext -StorageAccountName "<STORAGE_ACCOUNT_NAME>" -StorageAccountKey "<STORAGE_ACCOUNT_KEY>"
    
    $blobName = "input.csv"
    Get-Content (Get-AzStorageBlobContent -Context $context -Container "container" -Blob $blobName)
    
    Import-CSV -Path $blobName