如何在Azure中导入CSV文件(Blob存储已上传)(.NET) [英] How to import csv file( already uploaded in blob storage) in Azure(.Net)

查看:655
本文介绍了如何在Azure中导入CSV文件(Blob存储已上传)(.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要导入CSV文件(Blob存储已上传)在Azure上。

I want to import csv file(already uploaded in blob storage) in Azure.

例如我曾uploded test.csv上Blob存储,现在我只想导入.NET(蔚蓝)的test.csv文件并导入后,我会插入到数据Azure数据库。我使用C#.net。请建议我怎么能达致这。我想跟进belwo步骤: -

For example I have uploded test.csv on blob storage, now i just want to import that test.csv file in .net(azure) and after importing i will insert that data into azure database. I am using C# .net. Please suggest how can I acheive this. I want to follow belwo steps:-


  1. 创建CVS文件包含所有行。

  2. 上传它作为BLOB。

  3. 与辅助角色分析它,并在SQL蔚蓝分贝插入。

感谢。

推荐答案

多一点澄清围绕你的问题将是有益的。你们是不是要上传文件到Azure的Blob存储?从那里下载你的应用程序消耗?什么语言(S)您使用的?

A bit more clarification around your question would be helpful. Are you trying to upload a file to Azure blob storage? Download it from there for your app to consume? What language(s) are you using?

有大量的加载文件的例子进入和使用.NET至少一把用于Java或PHP做它的Azure Blob存储拉扯他们。

There are plenty of examples of loading files into and pulling them from Azure blob storage using .NET at least a handful for doing it with Java or PHP.

我可以明确你想要做什么,我很乐意在适当的人来点你。 :)

I you can clarify what you're trying to do, I'd be happy to point you at the appropriate ones. :)

- 答案基于评论更新 -
检索BLOB的步骤相当简单:
1)使用Azure存储凭据创建Azure存储客户端
添加使用条款:

-- answer based on comment update -- The steps for retrieving the blob are fairly straight forward: 1) create your Azure storage client using your azure storage credentials add a using clause:

获取客户端来访问Blob存储:
CloudBlobClient tmpClient =新CloudBlobClient();

get a client for accessing blob storage: CloudBlobClient tmpClient = new CloudBlobClient("");

获得参鉴您要下载的blob:
CloudBlob myBlob = tmpClient.GetBlobReference(集装箱/ myblob.csv);

get a referrence to the blob you want to download: CloudBlob myBlob = tmpClient.GetBlobReference("container/myblob.csv");

2),阅读BLOB和放大器;保存到一个文件

2) read the blob & save to a file

myBlob.DownloadToFile(/ myblob.csv);

myBlob.DownloadToFile("/myblob.csv");

保存位置可以在%temp%位置,或者如果它的一个大的文件,你可能要分配一些局部的存储空间,并把它放在那里。要记住的另一件事是,如果你是在一个角色实例这样做,你需要从试图同时处理同一个文件请确保您有措施,以prevent两个实例。如果该文件是足够小,你可能甚至保持它作为一个内存流和处理这种方式。如果是这种情况,则可以使用CloudBlob对象的DownloadToStream属性

The save location can be the %temp% location or if its a large file you may want to allocate some local storage space and put it there. The other thing you want to keep in mind is that if you are doing this in a role instance, you'll need to make sure you have measures in place to prevent two instances from concurrently trying to process the same file. If the file is small enough, you can probably even keep it as a memory stream and process it that way. If this is the case, you can use the DownloadToStream property of the CloudBlob object.

有关额外读书,我建议你检查了MSDN库的StorageClient和CloudBlob包含的细节。此外,Windows Azure平台培训工具包有一些很好的实验室,以帮助您更好地了解Azure存储是如何工作的。

For additionally reading, I'd recommend checking out the MSDN library for the details on the StorageClient and CloudBlob contains. Additionally, the Windows Azure Platform Training Kit has some good labs to help you get a better understanding of how Azure Storage works.

这篇关于如何在Azure中导入CSV文件(Blob存储已上传)(.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆