Azure 逻辑应用程序 - 获取 Blob 内容 - 设置内容类型

Azure Logic Apps - Get Blob Content - Setting Content type

Azure 逻辑应用程序操作 "Get Blob Content" 不允许我们设置 return 内容类型。

默认情况下,它 return 将 blob 存储为二进制(八位字节流),这在大多数情况下是无用的。一般来说,有文本会很有用(例如 json、xml、csv 等)。

我知道该操作处于测试阶段。这是否在短期路线图上?

我发现的解决方法是使用 Logic App 表达式 base64ToString。

例如,使用以下代码创建类型为 "Compose" 的操作(数据操作组):

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

输出将是 blob 的文本表示形式。

在逻辑应用程序上摆弄了很多之后,我终于明白是怎么回事了。

HTTP 请求的 JSON 输出是 XML 负载的 JSON 表示:

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

所以我们可以解码它,但它真的没用。这是 Logic App 的 XML 对象。我们可以对其应用xml函数,比如xpath.

  1. 您需要了解 content-type。
  2. 使用@{body('Get_blob_content')['$content']}单独获取内容部分。

所以我在 az 存储中有一个 blob,里面有 json。 获取 blob 为我返回了一个非常无用的八位字节,因为我无法解析它。

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

所以我设置了一个 "Initialize variable",内容类型为字符串,指向 GetBlobContent->File Content。 base64 转换发生在幕后,我现在可以通过变量访问我的 json。

无需代码。

JSON 输出...

流程,无代码...

尽情享受吧!希利在坦帕...