Azure Logic Apps - Get Blob Content - Setting Content type

前端 未结 4 760
攒了一身酷
攒了一身酷 2020-12-21 04:00

The Azure Logic Apps action \"Get Blob Content\" doesn\'t allow us to set the return content-type.

By default, it returns the blob as binary (octet-stream), which is

相关标签:
4条回答
  • 2020-12-21 04:16

    Workaround I found is to use the Logic App expression base64ToString.

    For instance, create an action of type "Compose" (Data Operations group) with the following code:

            "ComposeToString": {
                "inputs": "@base64ToString(body('Get_blob_content').$content)",
                "runAfter": {
                    "Get_blob_content": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            }
    

    The output will be the text representation of the blob.

    0 讨论(0)
  • 2020-12-21 04:21

    After fiddling much with Logic Apps, I finally understood what was going on.

    The JSON output from the HTTP request is the JSON representation of an XML payload:

    {
      "$content-type": "application/xml",
      "$content": "77u/PD94bWwgdm..."
    }
    

    So we can decode it, but it is useless really. That is an XML object for Logic App. We can apply xml functions to it, such as xpath.

    0 讨论(0)
  • 2020-12-21 04:29
    1. You would need to know the content-type.
    2. Use @{body('Get_blob_content')['$content']} to get the content part alone.
    0 讨论(0)
  • 2020-12-21 04:35

    So I had a blob sitting in az storage with json in it. Fetching blob got me a octet back that was pretty useless, as I was unable to parse it.

    BadRequest. The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/octet-stream'.

    So I setup an "Initialize variable", content type of string, pointing to GetBlobContent->File Content. The base64 conversion occurs under the hood and I am now able to access my json via the variable.

    No code required.

    JSON OUTPUT...

    FLOW, NO CODE...

    Enjoy! Healy in Tampa...

    0 讨论(0)
提交回复
热议问题