简体   繁体   English

从 blob 中提取数据并将其加载到 SQL Server 中的表中的最简单方法是什么?

[英]What is the easiest way to pull data from a blob and load it into a table in SQL Server?

I have hundreds of zipped files sitting in different folders, which I can access using MS Storage Explorer.我有数百个压缩文件位于不同的文件夹中,我可以使用 MS Storage Explorer 访问这些文件。 I just setup a SQL Server DB in Azure.我刚刚在 Azure 中设置了一个 SQL Server DB。 Now I am trying to figure out how I can pull data from each file in each folder, unzip it, parse it, and load it into tables.现在我想弄清楚如何从每个文件夹中的每个文件中提取数据,解压缩它,解析它并将其加载到表中。 The data is coming in daily, so the folders are named '1', '2', '3', etc. '31', for the days of the month.数据每天都进来,所以文件夹被命名为“1”、“2”、“3”等。“31”,代表一个月中的几天。 Also, I have monthly folders '1' through '12', for the 12 months of the year.此外,我在一年中的 12 个月内有每月文件夹“1”到“12”。 Finally, I have folders named '2017', '2018', and '2019'.最后,我有名为“2017”、“2018”和“2019”的文件夹。 I could ask some people on my team to write Python code to do the work, but it seems like there should be an easier way.我可以请我团队中的一些人编写 Python 代码来完成这项工作,但似乎应该有更简单的方法。 I would like to avoid writing thousands of lines of Python code, if there is a simpler way to do this kind of thing.如果有更简单的方法来做这种事情,我想避免编写数千行 Python 代码。 TIA. TIA。

I would create Azure Logic App that would我会创建 Azure 逻辑应用程序

  1. HTTP trigger (this will be manually ran) HTTP 触发器(这将手动运行)
  2. Iterate through all blobs present on storage account遍历存储帐户上存在的所有 blob
  3. For each element use blob connector which has action called Extract archive to extract zipped files into blob对于每个元素,使用 blob 连接器,该连接器具有名为 Extract archive 的操作将压缩文件提取到 blob
  4. Use Azure SQL BCP to pull this, if this is different format than CSV then use Azure Data Factory使用 Azure SQL BCP 来提取它,如果这与 CSV 格式不同,则使用 Azure 数据工厂

Later if you expect new blobs do similar flow except use New or modified blob trigger.稍后,如果您希望新的 blob 执行类似的流程,除了使用新的或修改后的 blob 触发器。

For Azure SQL BCP from BLOB example with Logic Apps check this article https://marczak.io/posts/azure-loading-csv-to-sql/对于带有逻辑应用程序的 BLOB 示例中的 Azure SQL BCP,请查看这篇文章https://marczak.io/posts/azure-loading-csv-to-sql/

And if you want general intro into Azure Logic Apps check this video https://youtu.be/ZvsOzji_8ow In here there is also new blob trigger demo.如果您想了解 Azure 逻辑应用程序的一般介绍,请查看此视频https://youtu.be/ZvsOzji_8ow此处还有新的 blob 触发器演示。

In case you need data factory feel free to check this video.如果您需要数据工厂,请随时查看此视频。 It has blob to sql demo too.它也有 blob 到 sql 演示。 Also you can trigger data factory from logic apps too.您也可以从逻辑应用程序触发数据工厂。 https://youtu.be/EpDkxTHAhOs https://youtu.be/EpDkxTHAhOs

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

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