As per the requirement, trying to upload large file (any: xml, images) (more than 100MB) from browser to private azure storage blob via APIM using SAS Token. The methods which I followed below not working. I tried TWO different options of upload, which request has cancelled after 6 to 7 seconds. However, when I tried to upload very small files (like 40 to 70Bytes) which uploaded successfully. Providing the APIM policies and javascript code below.
Let me know what I'm making wrong over here in below steps.
Note: I tried download the large file (1GB) from storage account via APIM using SAS token which works perfectly without any issue.
Option 1:
<policies>
<inbound>
<base />
<set-method>PUT</set-method>
<set-header name="x-ms-blob-type" exists-action="override">
<value>BlockBlob</value>
</set-header>
<set-header name="x-ms-version" exists-action="override">
<value>2020-02-10</value>
</set-header>
<set-header name="Authorization" exists-action="delete" />
<set-backend-service base-url="https://{{storageAccountName}}.blob.core.windows.net/test/test.xml?{{SASToken}}" />
<rewrite-uri template="?" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Option 2:
<policies>
<inbound>
<base />
<set-variable name="storageAccount" value="{{storageAccountName}}" />
<send-request mode="new" response-variable-name="blobdata" ignore-error="true" fail-on-error-status-code="true">
<set-url>@{return string.Format("https://{0}.blob.core.windows.net/test/test.xml?{{SASToken}}",(string)context.Variables["storageAccount"]);}</set-url>
<set-method>PUT</set-method>
<set-header name="x-ms-blob-content-type" exists-action="override">
<value>application/xml</value>
</set-header>
<set-header name="x-ms-blob-type" exists-action="override">
<value>BlockBlob</value>
</set-header>
<set-header name="x-ms-version" exists-action="override">
<value>2020-02-10</value>
</set-header>
<set-header name="Authorization" exists-action="delete" />
<set-body>@( context.Request.Body.As<string>() )</set-body>
</send-request>
<return-response>
<set-status code="200" reason="OK" />
<set-body>@($"{((IResponse)context.Variables["blobdata"]).Body.As<string>() }")</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>