GithubHelp home page GithubHelp logo

neosalpha / dynamically-pass-parameter-value-in-fuction-app-url-query-string-or-header-in-azure- Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 10.52 MB

NeosAlpha Azure

azure azure-functions azure-blob trigger-events

dynamically-pass-parameter-value-in-fuction-app-url-query-string-or-header-in-azure-'s Introduction

Dynamically pass parameter value in Fuction App URL Query String or Header in Azure

Published by NeosAlpha Technologies

Function App

We are creating Function App with HTTP Trigger in Visual Studio and configure Azure Blob storage connection string. Here we are getting file name dynamically from Fuction App URL query string or Header and Read data from CSV file and Transform data into JSON format.

Here we can call Function App like : {functionappurl}?filename=test.csv . Code will be like:

    [FunctionName("CSVtoJSON")]
    public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route =null)] HttpRequest req
    , [Blob("hotfile/{query.filename}", FileAccess.Read, Connection = "AzureWebJobsStorage")]Stream myBlob, TraceWriter log)
    {
        log.Info("C# HTTP trigger function processed a request.");
        string name = req.Query["name"];
        var json = Convert(myBlob);
        return (ActionResult)new OkObjectResult(json);
       
    }
    public static string Convert(Stream blob)
    {
        // Properties per = new Properties();
        //List<Properties> records = new List<Properties>();
        var sReader = new StreamReader(blob);
        var csv = new CsvReader(sReader);

        csv.Read();
        csv.ReadHeader();

        //*** To add into list without customization ***//
        var csvRecords = csv.GetRecords<object>().ToList();

        return JsonConvert.SerializeObject(csvRecords);
    }

dynamically-pass-parameter-value-in-fuction-app-url-query-string-or-header-in-azure-'s People

Contributors

neosalpha avatar

Stargazers

 avatar  avatar

Watchers

 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.