[英]Can an Azure Logic App read an excel file from a storage account?
I have an excel spreadsheet residing in a container in an azure storage account.我有一个 excel 电子表格驻留在 azure 存储帐户的容器中。
I can use an Azure Logic App with the "Get Blob Content" to access the file.我可以使用带有“获取 Blob 内容”的 Azure 逻辑应用程序来访问该文件。 But I cannot find any documentation discussing actually reading the file within the Azure Logic App from blob storage.
但我找不到任何文档讨论从 Blob 存储中实际读取 Azure 逻辑应用程序中的文件。 Note that there are connectors for accessing Excel files in OneDrive or Office365 but not from a storage account container.
请注意,有用于访问 OneDrive 或 Office365 中的 Excel 文件的连接器,但不能从存储帐户容器访问。
Despite furious searching I have not found any discussion of this use case in Microsoft Documentation or otherwise.尽管进行了激烈的搜索,但我没有在 Microsoft 文档或其他文件中找到有关此用例的任何讨论。 Any links would be appreciated.
任何链接将不胜感激。
What is the best approach to read/search an excel file in Azure Logic Apps from Blob Storage?从 Blob 存储读取/搜索 Azure 逻辑应用程序中的 excel 文件的最佳方法是什么?
You can add an Azure Function to your workflow and easily read the contents of your spreadsheet:您可以将 Azure Function 添加到您的工作流程中,并轻松阅读电子表格的内容:
public class ExcelFileContentExtractorService : IExcelFileContentExtractorService
{
public ExcelFileRawDataModel GetFileContent(Stream fileStream)
{
IDictionary<string, string> cellValues = new Dictionary<string, string>();
IWorkbook workbook = WorkbookFactory.Create(fileStream);
ISheet reportSheet = workbook.GetSheetAt(0);
if (reportSheet != null)
{
int rowCount = reportSheet.LastRowNum + 1;
for (int i = 0; i < rowCount; i++)
{
IRow row = reportSheet.GetRow(i);
if (row != null)
{
foreach (var cell in row.Cells)
{
var cellValue = cell.GetFormattedCellValue();
if (!string.IsNullOrEmpty(cellValue))
{
cellValues.Add(cell.Address.FormatAsString(), cellValue);
}
}
}
}
}
return new ExcelFileRawDataModel()
{
Id = cellValues["A6"],
CarBrand = cellValues["B6"],
CarModel = cellValues["C6"],
CarPrice = decimal.Parse(cellValues["D6"]),
CarAvailability = int.Parse(cellValues["E6"])
};
}
}
source: https://daniel-krzyczkowski.github.io/Extract-Excel-file-content-with-Azure-Logic-Apps-and-Azure-Functions/来源: https://daniel-krzyczkowski.github.io/Extract-Excel-file-content-with-Azure-Logic-Apps-and-Azure-Functions/
I tried to do same with CSV and didnt make a lot of progress.我尝试对 CSV 做同样的事情,但没有取得很大进展。 It is clumsy to try and parse file contents in my experience.
根据我的经验,尝试解析文件内容很笨拙。 There are a few 3rd party plug-ins (connectors) for logic-apps, but I'm reluctant to use them since I believe the data is send to the 3rd party site as part of processing.
有一些逻辑应用程序的第 3 方插件(连接器),但我不愿意使用它们,因为我相信数据作为处理的一部分发送到第 3 方站点。 If your data isn't particularly sensitive, you could try these connectors.
如果您的数据不是特别敏感,您可以尝试这些连接器。
And here I will add what I have learned.在这里,我将补充我所学到的。
Despite native support for reading excel files from OneDrive and Sharepoint at the time of this writing Microsoft Product managers somehow missed that Azure customers may wish to read their content from within Azure (storage account blob) with Azure tools such as Logic Apps. Despite native support for reading excel files from OneDrive and Sharepoint at the time of this writing Microsoft Product managers somehow missed that Azure customers may wish to read their content from within Azure (storage account blob) with Azure tools such as Logic Apps.
The only solution at the time of this writing is to create an Azure Function that generates the SAS token and reads the blob.在撰写本文时,唯一的解决方案是创建一个 Azure Function 生成 SAS 令牌并读取 blob。
As a result I have marked Thiago's response as correct.因此,我将蒂亚戈的回答标记为正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.