Azure function writing to blob storage using output binding is mangling the output RRS feed

  • Question

  • I have a powershell azure function that is converting my object into a csv object.

    $csvstring = $alldbs | select SubscriptionName, ServerName, DatabaseName | ConvertTo-Csv -NoTypeInformation
    # This is not formatting the output properly
    Push-OutputBinding -name outputBlob -value $csvstring
    # This is creating a long line like
    # ["\"SubscriptionName\",\"Servername\",\"DatabaseName\"","\"[****] cust ********\",\"c6ns8l-********-p1-server\",\"c6ns8l-*******-p1-db\"","\"[*****] cust ******\",\"c6ns8l-*****-p2-server\",

    so the entire output is wrapped in an [] and all line breaks are stripped as well as the " are escaped

    Any ideas how I can get my powershell function to export a csv file to blob storage using the output binding?

    • Edited by RScottWatson Friday, September 27, 2019 3:43 PM forgot something
    Friday, September 27, 2019 3:41 PM


  • I will add the answer here incase this helps someone.

    https:// github.com/Azure/azure-functions-powershell-worker/issues/343

    (remove the space as I was not allowed to post links between the // and github)

    Thanks to Anatoli B for figuring this out.


    use this to output the csv object.  

    Push-OutputBinding -name outputBlob -value ($csvstring -join "`n")

    • Marked as answer by RScottWatson Monday, September 30, 2019 12:52 PM
    Monday, September 30, 2019 12:51 PM