1

I'm writing a Power Shell based Azure Function App and have a requirement to output a HTML file to a storage blob.

I'm using the External File Output through the Function Apps Integrate Menu.

I run the following code to output the HTML to a file.

Out-file -FilePath $outputFile -InputObject $html -Encoding ascii

Unfortunately, when I link directly to the file the browser downloads the HTML file rather than displaying it. I believe this is some type of Content type issue. When I open the downloaded file the browser then displays it properly.

I've provided a picture of the output file (result.html) in azure storage explorer below Image of file

2 Answers 2

2

This is pretty old but wth. The reason why it's downloading it is because you need to tell the browser to display the html rather than download it using content-type header.

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
     StatusCode = [HttpStatusCode]::OK
     ContentType = "text/html"
     Body       = $html
 })
Sign up to request clarification or add additional context in comments.

Comments

0

Unfortunately, current Blob binding can't modify content-type using PowerShell.

In case of C#, ICloudBlob type can modify content-type, but that's is not simply.

If you are interest this issue, see also as follows: https://github.com/Azure/azure-webjobs-sdk-script/issues/364

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.