Azure Function Powershell: How to change encoding for push-outputbinding

Schott Ludwig 1 Reputation point
2021-06-29T06:12:03.053+00:00

When retrieving data from an online API, converting it to JSON and using Push-Outputbinding to write to Azure Data Lake Gen2 Container, special characters are off:
Code snippet:

#Convert PSCustomObject ($APIResults) to JSON and write to Azure Data Lake Gen2
$APIResultsJSON = $APIResults | ConvertTo-Json -depth 20
Push-OutputBinding -Name dataoutputBlob -Value $APIResultsJSON

Examples for changed characters:
Ü --> is transformed to Ãœ
在庫金額 --> is transformed to 在庫金é¡

Running the Powershell Script locally, using:

$APIResults | ConvertTo-Json -depth 20 | Out-File ($BasePath+$DataPath)

works fine (with correct encoding).

How can I change the encoding behavior in Azure Function (Powershell)?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,468 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 61,141 Reputation points
    2021-07-01T06:44:34.213+00:00

    Hi @Schott Ludwig

    Welcome to Microsoft Q&A! Thanks for posting the question.

    I don't see any issue with the Push-OutputBinding at my end. Whatever data I have received it is saving the same data in my Azure Data Lake Gen2 Container.

    110892-image.png

    Downloading the blob file I can see the same data that I have written

    Hello 在庫金額, This HTTP triggered function executed successfully.

    I will suggest you to log the value of $APIResultsJSON on your function app to double check whether the data is converted before writing it to the Output binding.
    There could be issue that the data would have converted when you have retrieve data from your API call. This will help you to figure out where exacting the data is converted.