微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

关于带有Apim和MSI的示例Azure存储Blob CRUD

如何解决关于带有Apim和MSI的示例Azure存储Blob CRUD

我在Apim仓库中发现了以下示例:https://github.com/Azure/api-management-policy-snippets/blob/master/examples/Authenticate%20using%20Managed%20Identity%20to%20access%20Storage%20Account.xml 有人可以用CRUD和Msi(深度潜水政策)解释一个更好的例子吗?如果我需要处理其他类型的文件(不是json对象)怎么办?将此文件发送到Blob怎么办?我正在尝试从S3获取文件(通过get API)并将其写入Blob存储。 我可以使用发送请求从S3获取数据,否则当我尝试将其发送到Blob存储时会生成错误,因为文件的类型不是纯json对象:

`<send-request mode="new" timeout="20" response-variable-name="blobdata2" ignore-error="false">
        <set-url>https://{{storage}}.blob.core.windows.net/container</set-url>
        <set-method>POST</set-method>
        <set-header name="x-ms-version" exists-action="override">
            <value>2019-07-07</value>
        </set-header>
        <set-header name="x-ms-blob-type" exists-action="override">
            <value>BlockBlob</value>
        </set-header>
        <set-header name="x-ms-type" exists-action="override">
            <value>file</value>
        </set-header>
        <set-body>@($"{((IResponse)context.Variables["blobdata"]).Body.As<JObject>() }")</setbody>
        <authentication-managed-identity resource="https://storage.azure.com" />
    </send-request>`

在这里,我尝试发送“ blobdata ”,因为该变量包含第一个Send-Request中的文件(此处未显示)。我收到的错误如下:

"Expression evaluation Failed. The message body is not a valid JSON. Unexpected character encountered while parsing value: P. Path '',line 0,position 0.\r\n at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader,JsonLoadSettings settings)\r\n at Microsoft.WindowsAzure.apimanagement.Proxy.Gateway.MessageBody.AsJObject(Stream stream,Encoding encoding,JsonSerializerSettings settings)\r\n at Microsoft.WindowsAzure.apimanagement.Proxy.Gateway.MessageBody.As[T](Boolean preserveContent)","Unexpected character encountered while parsing value: P. Path '',position 0."

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。