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

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

问题描述

我想在Azure中导入csv文件(已在blob存储中上传)。



例如,我已经uploded test.csv blob存储,现在我只是想导入test.csv文件在.net(azure)和导入后,我会插入该数据进入天蓝数据库。我使用C#.net。请建议我如何能够实现这一点。我想按照以下步骤操作: -


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

  2. 上传





<

感谢。

解决方案

有关您的问题的更多说明会有所帮助。您是否尝试将文件上传到Azure blob存储?从那里下载您的应用程序来消费?您使用什么语言?



有很多例子,使用.NET加载文件和从Azure blob存储中提取它们至少有一些与Java或PHP。



我可以澄清你想做什么,我很乐意指出你的意思。 :)

- 基于注释更新回答 -
检索blob的步骤是相当简单的:
1)创建Azure存储客户端使用您的天蓝色存储凭证
使用Microsoft.WindowsAzure.StorageClient添加一个使用子句:

  

获取访问blob存储的客户端:

  CloudBlobClient tmpClient = new CloudBlobClient(< nameofyourconfigsetting>); 

获取您要下载的blob的引用:

  CloudBlob myBlob = tmpClient.GetBlobReference(container / myblob.csv); 

2)读取blob&保存到文件

  myBlob.DownloadToFile(< path> /myblob.csv); 

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



对于另外的阅读,我建议查看MSDN库以了解 StorageClient CloudBlob 包含。此外,Windows Azure平台培训套件有一些好的实验室,以帮助您更好地了解Azure存储如何工作。


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

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. Creating a cvs file with all rows.
  2. Upload it as blob.
  3. Parse it with a Worker role and insert it in the sql azure db.

Thanks.

解决方案

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?

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. :)

-- 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:

using Microsoft.WindowsAzure.StorageClient;

get a client for accessing blob storage:

CloudBlobClient tmpClient = new CloudBlobClient("<nameofyourconfigsetting>");

get a referrence to the blob you want to download:

CloudBlob myBlob = tmpClient.GetBlobReference("container/myblob.csv");

2) read the blob & save to a file

myBlob.DownloadToFile("<path>/myblob.csv");

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.

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(.Net)中的csv文件(已在blob存储中上传)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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