Rey Norbert Besmonte
Rey Norbert Besmonte

Reputation: 811

Azure Logic App: Create CSV File in Blob

I am having a problem updating a csv file in my blob. I have an existing file inside my blob which is a CSV file, and when I press the download button it will automatically download the file to my machine.

Now I already created a Logic App that will update the csv file. When I run the trigger of the app, it updates the file but when I press download, it opens up a new tab where the csv file will be displayed.

I want it the way like the original when I press download it download the file to my machine.

Any help will do or verification if this is possible.

I already tried "compose" and "create to csv" but this way it will not store it to a blob.

Upvotes: 0

Views: 4335

Answers (1)

Joey Cai
Joey Cai

Reputation: 20127

As I have test, when you want to create a .csv file with "create blob" action in logic app, it will always get the same problem with you. Because the blob content is "text/plan" which will display in another tab to show.

So, I suggest that you could use azure function to create the blob. In azure function you could set:blob.Properties.ContentType = "application/octet-stream";

Here is the create blob method in azure function:

    storageAccount = CloudStorageAccount.Parse(connectionString);

    client = storageAccount.CreateCloudBlobClient();

    container = client.GetContainerReference("data");

    await container.CreateIfNotExistsAsync();

    blob = container.GetBlockBlobReference(name);
    blob.Properties.ContentType = "application/octet-stream";

    using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(data)))
    {
        await blob.UploadFromStreamAsync(stream);
    }

For more detailed code, you could refer to this article. After following that, you could download your blob in your local machine.

Note: when you create the azure function action in logic app, it will show error. Just delete Appsetting of "AzureWebJobsSecretStorageType" to "blob".

Upvotes: 2

Related Questions