title: How to upload to azure blob from a dataset or a datatable
body: <p>I am currently working in <code>Powershell</code>, trying to get some data from my <code>Azure SQL Database</code>. I have with success fetched some data into a dataset. However, i cannot seem to figure out how to upload it to <code>Azure blob storage</code> without saving it locally first as a csv.</p>
  
  <blockquote>
    <p>The dataset must be converted to csv and uploaded to the blob as a csv without saving it locally.</p>
  </blockquote>
  
  <p>This is what  got so far:</p>
  
  <pre><code>$SQLServer = "xxxxxxx"
  $SQLDBName = "xxxxxx"
  $uid ="xxxxxxxx"
  $pwd = "xxxxxxx"
  $SqlQuery = "SELECT * from Dim.xxxxxx;"
  $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
  $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; Integrated Security = False; User ID = $uid; Password = $pwd;"
  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
  $SqlCmd.CommandText = $SqlQuery
  $SqlCmd.Connection = $SqlConnection
  $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
  $SqlAdapter.SelectCommand = $SqlCmd
  $DataSet = New-Object System.Data.DataSet
  $SqlAdapter.Fill($DataSet)
  
  $csv = $DataSet.Tables[0] | ConvertTo-Csv -Delimiter ";" -NoTypeInformation
  
  Set-AzStorageBlobContent -File $csv -Context $context -Container "xxxxxx"
  </code></pre>
  
  <p>However the last line gives me this error:</p>
  
  <blockquote>
    <p>Set-AzStorageBlobContent : Cannot convert 'System.Object[]' to the
    type 'System.String' required by parameter 'File'. Specified method is
    not supported.</p>
  </blockquote>
  
  <p>I know im doing something wrong but i cannot figure out how to convert the dataset and upload it at the same time. Or maybe there is another way?</p>