Git Product home page Git Product logo

function-excel-csv's Introduction

Convert Excel to CSV with Azure Function

Prerequisites

Prior Azure Function deployment, create following resources (login with az login first, if necessary):

  1. Storage Account
az storage account create \
--name <STORAGE_NAME> \
--location <REGION> \
--resource-group <RESOURCE_GROUP> \
--sku Standard_LRS
  1. Function App
az functionapp create \
--name <APP_NAME> \
--resource-group <RESOURCE_GROUP> \
--consumption-plan-location <REGION> \
--storage-account <STORAGE_NAME> \
--runtime dotnet \
--functions-version 4 

Afterwards, you need to checkout this repository and setup your local environment according to documentation

Deployment

To deploy Azure Function to Azure, run following command from local command line:

func azure functionapp publish <APP_NAME>

NOTE: You need to be in function-app directory of this repository prior running this command.

Development

To develop Azure Function in this project further, it is recommended to setup Visual Studio Code development environment according to documentation.

Logic App

Following is an example of logic app that is using Azure Function to convert Excel to CSV. It implements following workflow:

  1. Receive an Excel file as body of HTTP request.
  2. Call Azure Function and send received Excel file as body of HTTP request.
  3. If response status of Azure Function is 200, continue, otherwise terminate logic app.
  4. Parse response body from Azure Function and convert according to JSON schema (in order to reference elements in further steps). Response is an JSON array which contains name and content pairs with CSVs. Azure Function generates one CSV file per worksheet from Excel file.

Example response:

[
	{
		"name": "First Sheet",
		"content": "Header1, Header2, ..."
	}, {
		"name": "Second Sheet",
		"content": "Cell1, Cell2, ..."
	}
]
  1. Iterate over all CSVs returned from Azure Function and save each CSV as blob in Storage Account.
  2. Return OK response to client.

Source code of this logic app is in excel2csv.json file.

Logic app visualization:

Logic App Example

License

Distributed under MIT license.

function-excel-csv's People

Contributors

tomasszabo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.