Content-Type Problem with Azure Storage Connector

One of our Logic Apps, which we developed as a static site generator, began writing the Web pages to the storage account as octet stream files, and I narrowed down the problem to a defect in the storage account connector.

I believe (but I’m not 100% certain yet) Microsoft’s developers hadn’t implemented the ‘"headers": {"Content-Type": "text/html"}’ code for the storage account connectors, and the file type, therefore, always defaults to octet stream. What seemed to confirm this was one of our developers added more connectors specifically to change the MIME type of the files after they were written, but was gettting the same result.

One workaround is to set the output of the Function App as a variable, then use that variable as the payload for the file write step. I forced the data type at each step.

"Initialize_variable": {
"inputs": {
    "variables": [
    {
        "name": "indexPageString",
        "type": "string",
        "value": "@{body('GenerateMainIndexHTMLStage')}"
    }
]},

The payload for the file write connector will look something like this in the Logic app designer:

{
    "content":"@{variables('indexPageString')}⁠",
    "content-type": "text/html"
}

In the code view:

"Create_Home_Page": {
    "inputs": {
        "body": "{\n\"content\":\"@{variables('indexPageString')}⁠\",\n\"content-type\":\"text/html\"\n}",
        "host": {
            "connection":
                {"name":"@parameters('$connections')['azureblob']['connectionId']"},
                "headers": {"Content-Type":"text/html"}
                },

Note the ‘"headers": {"Content-Type": "text/html"}’ element. This needs to be added manually in the code view for the new Logic App format.

If there is a step to update the MIME type of the file, it needs removing, as the file type defaults to octet stream regardless of what was explicitly set.