简体   繁体   English

如何连接Azure存储以从blob存储中读取.txt文件

[英]How to connect Azure Storage to read .txt files from blob storage

任何人都可以让我知道如何从Azure Blob存储中读取文本文件?

It's pretty easy: 这很简单:

string text = CloudStorageAccount.Parse("<your connection string>").CreateCloudBlobClient().GetBlobReference("path/to/the/blob.txt").DownloadText();

Of course, if the blob is in a public container, you can just do: 当然,如果blob在公共容器中,您可以这样做:

string text = new WebClient().DownloadString("http://youraccount.blob.core.windows.net/path/to/blob.txt");
// connect to development storage. To connect to azure storage use connection string
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudBlobClient client = storageAccount.CreateCloudBlobClient();

// if you know the blob you want to access you can do this:
CloudBlob blob = client.GetBlobReference("containername/blobname.txt");

// To display text in console:
Console.WriteLine(blob.DownloadText());
Console.ReadKey();

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

相关问题 更改 Azure 存储 Blob 中文件的内容类型 - Change Content Type for files in Azure Storage Blob Azure教程 - 如何使用本地blob存储 - Azure tutorial - How to use local blob storage 从 Windows Azure 中的 blob 存储逐行读取 - Reading line by line from blob Storage in Windows Azure 在 Azure blob 存储中存储我的角色服务 package 有多安全? - How safe is storing my role service package in Azure blob storage? 如何将多个 Azure VM 中的文件自动复制到 Azure 存储并随后访问 - How to copy files from multiple Azure VM to Azure Storage automatically and access then 备份符合SQL Azure DB的Azure Blob存储 - Backup Azure blob storage in line with SQL Azure DB 如何在不编写自己的程序的情况下将一些文件上传到 Azure blob 存储? - How do I upload some file into Azure blob storage without writing my own program? Jenkins Azure Blob 存储插件将构建文件夹的内容而不是构建文件夹复制到 $web azure blob 静态容器 - Jenkins Azure Blob Storage plugin to copy the contents of Build folder and not build folder to $web azure blob static cotainer 如何从启动任务访问 Azure 本地存储? - How to access Azure local storage from a startup task? Azure 存储更改传播到实例的速度有多快? - How fast are Azure Storage changes propagated to instances?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM