Azure Logic Apps - Get Blob Content - Setting Content type

点点圈 提交于 2019-11-28 09:19:02

问题


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 useless in most cases. In general it would be useful to have text (e.g. json, xml, csv, etc.).

I know the action is in beta. Is that on the short term roadmap?


回答1:


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.




回答2:


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.




回答3:


  1. You would need to know the content-type.
  2. Use @{body('Get_blob_content')['$content']} to get the content part alone.


来源:https://stackoverflow.com/questions/43598188/azure-logic-apps-get-blob-content-setting-content-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!