Put Blob REST API Content-Length error

Jez Walters 20 Reputation points
2024-05-07T10:06:05.8133333+00:00

I'm trying to write the XML response obtained from a REST API GET request to a file in Azure Blob Storage, using Azure Data Factory.

I'd prefer to use the Copy activity to achieve this, but it doesn't support XML sinks. I've therefore been forced into using separate Web activities, to get the response and then write it to Blob storage.

I have 3 activities in my pipeline:

  1. A Web activity, to issue my REST API GET request
  2. A Set Variable activity, to assign the response obtained from step 1 to the variable called "Body"
  3. A Web activity, to issue a REST API PUT request (using the "Body" variable from step 2)

This approach works fine for small responses but when I try doing the same for larger responses (around 1MByte), I get the following error:

Error calling the endpoint 'https://mystorageaccount.blob.core.windows.net'. Response status code: 'NA - Unknown'. More details: Exception message: 'NA - Unknown [ClientSideException] Bytes to be written to the stream exceed the Content-Length bytes size specified.'. Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout

What am I doing wrong, or is there a better way of achieving my goal (but still using Azure Data Factory)?

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,513 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,808 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Jez Walters 20 Reputation points
    2024-05-09T13:52:16.3366667+00:00

    TestPipeline.txt

    For anyone wanting to reproduce the problem, the above test pipeline (I've changed the extension changed from ".json" to ".txt") contains 3 activities:

    1. A Web activity to issue a REST API GET request, to get makes of cars (using a publicly available anonymous endpoint)
    2. A Set Variable activity to extract the XML response from step 1 (into a variable called "Body")
    3. A Web activity to issue a REST API PUT request, to write the XML response to Blob storage (using the variable called "Body" from step 2)

    For privacy/security reasons, I've amended the URL in the Web activity in step 3 (to use the storage account "mystorageaccount", and the container "mycontainer").