Hello Jeffrey,
Thanks for putting the solution to upload the files to Storage Account using Azure APIM.
I also tried to use the solution with some tweaks to test how it works.
I am able to upload the files but when I am uploading any PDF or gifs , the contents gets lost or the file gets corrupted when I download them from storage account.
Below is the APIM policy snippet I am using.
<send-request mode="new" response-variable-name="result" timeout="300" ignore-error="false">
<!-- Get variables to configure your: storageaccount, destination container and file name with extension -->
<set-url>@{ return "https://devbaswareinvaccount.blob.core.windows.net/baswareinvxml/People.pdf"; }</set-url>
<set-method>PUT</set-method>
<set-header name="Host" exists-action="override">
<value>{{storageAccountName}}.blob.core.windows.net</value>
</set-header>
<set-header name="x-ms-type" exists-action="override">
<value>file</value>
</set-header>
<set-header name="x-ms-blob-type" exists-action="override">
<value>BlockBlob</value>
</set-header>
<set-header name="x-ms-Blob-Cache-Control" exists-action="override">
<value />
</set-header>
<set-header name="x-ms-Blob-Content-Disposition" exists-action="override">
<value>attachment</value>
</set-header>
<set-header name="Content-Type" exists-action="override">
<value>application/pdf</value>
</set-header>
<set-header name="x-ms-content-length" exists-action="override">
<value>65336</value>
</set-header>
<set-header name="x-ms-Version" exists-action="override">
<value>2019-12-12</value>
</set-header>
<!-- Set the header with authorization bearer token that was previously requested -->
<set-header name="Authorization" exists-action="override">
<value>@("Bearer " + (string)context.Variables["msi-access-token"])</value>
</set-header>
<!-- Set the file content from the original request body data -->
<set-body>@(context.Request.Body.As<string>(preserveContent: true))</set-body>
</send-request>
<!-- Returns directly the response from the storage account -->
<return-response response-variable-name="result" />
I appreciate if you could help me to figure out the problem or provide me the solution to upload the pdfs as well.
Thanks
Sudhir