简体   繁体   English

从 Azure 逻辑应用中的 http 响应中提取文件

[英]Extract file from http response in Azure logic app

I have an Azure function (http triggered) which returns a CSV file in response.我有一个 Azure 函数(http 触发),它返回一个 CSV 文件作为响应。 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.我正在使用 http 请求操作从逻辑应用程序调用此函数(因为我需要传递身份验证详细信息)并使用正文中的 CSV 获取 http 响应。 Now I want to send this CSV as an attachment with an outlook email.现在我想将此 CSV 作为带有 Outlook 电子邮件的附件发送。 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.如果我使用 http 响应的正文,则电子邮件正文包含 CSV 的完整内容,而我希望将其作为附件。

Thanks in advance.提前致谢。

Regards, SB问候, SB

This is how I solved.我就是这样解决的。

Here is my sample Azure function and Logic app configuration这是我的示例 Azure 函数和逻辑应用配置

[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());
        }

在此处输入图片说明

Let us know if this works for you..we can do same with outlook account..I just used gmail account.让我们知道这是否适合您..我们可以用 Outlook 帐户做同样的事情..我只使用了 gmail 帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM