How to set content-type when copy to blob storage by ADF

Peter Ma 206 Reputation points Microsoft Employee
2021-07-09T20:05:54.767+00:00

I don't want to use the default content-type which blob storage provided. How can I set the content-type when using ADF data flow ?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,444 questions
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 26,011 Reputation points
    2021-07-12T22:27:30.677+00:00

    Hello anonymous user-0048 and welcome back to Microsoft Q&A.

    To summarize our offline discussion:

    • You are using DataFlow, and writing to blob storage, using delimited text .
    • The resulting blob has content-type as application/octet-stream . You want it to be text/html .
    • This is important for you because the content-type affects the behavior of a web browser pointed to the blob. When set to text/html , the file is displayed. When set to application/octet-stream, it is downloaded.
    • There does not seem to be any controls in DataFlow to alter this property.
    • The custom metadata option in Copy Activity is not helpful, because content-type is a property, not metadata. This option instead creates a custom metadata named 'content-type'. Not useful.

    As a temporary solution, I have suggested using Web Activity to call the blob api to set properties. This should be executed after the DataFlow completes.

    Given that you are writing a text-like file, it would make more sense for the content-type to reflect this anyway. I will recommend this become a feature request.

    @MarkKromer-MSFT for awareness.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Mohammed Brueckner 6 Reputation points Microsoft Employee
    2022-10-17T13:20:17.437+00:00

    Hello @Peter Ma ,

    maybe you are still struggling with this and while @MartinJaffer-MSFT puts his magic to work, let me show you how you can execute what he suggested:
    https://medium.com/serverless-and-lowocode-pioneers/managed-identity-on-azure-bac5ace69e1b

    (I took this very challenge of yours of having to change the content-type for a file in a DF pipeline sink - and what I did is, I solve it in this article linked above and so can you now.)

    Hope this helps in the meantime!

    Cheers

    1 person found this answer helpful.