azureazure-functionshttpresponseazure-logic-appshtml-content-extraction

Extract file from http response in Azure logic app


I have an Azure function (http triggered) which returns a CSV file in response. I am calling this function from a logic app using http request action (since I need to pass authentication details) and getting the http response with the CSV in body. Now I want to send this CSV as an attachment with an outlook email. Unfortunately I'm unable to do this. If I use the body of http response then the email body contains the full content of the CSV, whereas I want this as an attachment.

Thanks in advance.

Regards, SB


Solution

  • This is how I solved.

    Here is my sample Azure function and Logic app configuration

    [FunctionName("Function1")]
            public static IActionResult Run(
                [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
                ILogger log)
            {
                log.LogInformation("C# HTTP trigger function processed a request.");
                var csvFile = new StringBuilder();
                csvFile.AppendLine(string.Format("{0},{1}", "1", "ABC"));
                csvFile.AppendLine(string.Format("{0},{1}", "2", "ABcd"));
                csvFile.AppendLine(string.Format("{0},{1}", "3", "ABCde"));
                csvFile.AppendLine(string.Format("{0},{1}", "4", "ABCdef"));
                csvFile.AppendLine(string.Format("{0},{1}", "5", "ABCdefg"));
                csvFile.AppendLine(string.Format("{0},{1}", "6", "ABCdefgh"));
                return new OkObjectResult(csvFile.ToString());
            }
    

    enter image description here

    Let us know if this works for you..we can do same with outlook account..I just used gmail account.