Home > Software design >  How to create Azure Function PowerShell to convert .csv to Tab Delimited .txt file?
How to create Azure Function PowerShell to convert .csv to Tab Delimited .txt file?

Time:04-26

I have a Logic App that creates Comma Separated Values blob "abc.csv". I then want to run a Powershell Function App to convert its data from Comma Separated Values to Tab Delimited and create a new blob "abc.txt".

I can perform this conversion on my local desktop using Powershell but never used Powershell in Azure Function before so I just need help with the Powershell script in Azure Function to connect to blob, convert existing file's data type and create a new file in blob.

CodePudding user response:

If you are new to functions, i'd recommend first setting up a plan on a consumption plan. Then fiddling with these functions.

Here is the powershell developer guide:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell?tabs=portal

Python Functions and Powershell have a little bit of a niche in some areas due to how concurrency is handled and being Single threaded by default. I'd take note of that section if you are going to have high traffic.

I think the easiest way to push out data would be taking advantage of output bindings. They are Function's easy to set up connection to another resource in a sense, I highly recommend reading up on them here:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-output?tabs=in-process,extensionv5&pivots=programming-language-powershell

This is the powershell output bindings which essentially take a connection string and functions host will handle the pushing of data and connections for you to the storage account. All that needs to be done from your end is handling some configuration and setting data to the variable associated with the output binding.

CodePudding user response:

You can use the Azure Blob trigger to make the Azure function pickup the CSV files as soon as they get placed in the container of the storage account, then perform data conversion from Comma Separated Values to Tab Delimited and create a new blob using Azure Blob storage output binding.

To be specific here is how the flow goes

Step - 1: Creating .csv files from logic app and saving them to container of storage account

Step - 2: As soon as the file gets saved to container Azure Function triggers because of Blob trigger

Step - 3: Perform data conversion from Comma Separated Values to Tab-Delimited.

Step - 4: Use Azure Blob storage output binding for Azure Functions to save the generated data to another container.

  • Related