question

ShellyGoel-4881 avatar image
0 Votes"
ShellyGoel-4881 asked pituach commented

Set Content-Type as text/csv instead of text/plain of the blob created using "Create Blob" step in Azure Logic Apps

Hello,

I have a "Create Blob" step in my Logic App and I'm trying to create a csv file. I have added the "Blob Content" as the comma separated header value ("assetPath,biddingAgency,campaignType,market") and it works fine but when I check the blob in Azure storage, the blob's content-type is set to text/plain whereas I need it to be text/csv as another action is dependent on this content-type.

I also tried passing below in the blob content but it doesn't help as mentioned here (https://theazureguy.wordpress.com/2020/02/13/setting-blob-content-type-in-logic-apps/comment-page-1/?unapproved=456&moderation-hash=388291d38fa9ea8bf026d0c77c362b4e#comment-456)
{
"$content": "assetPath,biddingAgency,campaignType,market",
"$content-type": "text/csv"
}

When I add "Compose" step with "Content-Type" in it, I get below error on execution
171639-content-type-error.png


azure-logic-appsazure-blob-storage
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered

@ShellyGoel-4881 The Create blob does accept the Content-Type parameter which you can set it to text/csv as per your requirement.
The Blob content parameter should only have the content of the blob.

171903-image.png

171913-image.png


image.png (11.9 KiB)
image.png (35.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

pituach avatar image
0 Votes"
pituach answered pituach commented

Hi,

(1) Please provide the code you use and not only the error. You can the entire code of the logic apps or image of the flow when all configuration of all operators and trigger are displayed.

(2) In the following thread I added a full example of how to create csv files, so check if this help in any way please:

https://docs.microsoft.com/en-us/answers/questions/720189/create-a-folder-and-csv-file-in-sharepoint-based-o.html

(3) According to the screenshot and the description, your issue is not in the CREATE BLOB but with the Compose action.

Remove the next action and first fixt this part. Run the app and check that you are getting the right output from the Compose action first.

By the way, why do you use Compose action !?? What is the input to the Compose action?

Compose action construct a single output such as a JSON object from multiple inputs. Why do you need JSON in order to CREATE BLOB ?!?

Take a look at the document: https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-perform-data-operations#compose-action

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@pituach
1. Please see attached screenshot of the flow in logic app
2. The thread you've shared does not help with the content-type of the file. To clarify, I'm able to create a csv file in Azure blob as expected, it's just the content-type of the file being set as text/plain but it should be text/csv.
3. As I mentioned in my original question that I followed this link () to set the content-type of the file to text/csv and that requires a json object to be provided in the blob content as below.
{
"$content": "assetPath,biddingAgency,campaignType,market",
"$content-type": "text/csv"
}
4. If you have any other suggestion to set the content-type (=text/csv) of a file in azure blob using logic apps then please suggest that.
5. If I remove compose step and pass the above json in blob content directly, the logic app runs fine but content-type in Azure blob store is set to text/plain


0 Votes 0 ·
logic-app.png (16.3 KiB)
pituach avatar image pituach ShellyGoel-4881 ·

I see that you mark the answer which mean that it solved your need. Glad to see this :-)

Have a great day

0 Votes 0 ·