如何从azure blob容器下载和读取文件 [英] How to download and read files from azure blob container

查看:1484
本文介绍了如何从azure blob容器下载和读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的文件从一个前提数据库迁移到azure blob。

我想要的是验证这些文件是否已成功迁移。

因此,我想检查来自azure blob的所有文件。

使用它们的名称,大小...。

如果大小为<

I have a large number of files which are migrated from a premise database to azure blob.
what I want is to verify whether those files are successfully migrated or not.
Therefore I want to check all the files from azure blob.
With their name, size, ...
And if the size is < 0 or if it is not downloaded, then I have to report that as corrupted.

我可以从azure中读取所有文件吗?

如何

Can I read all files from azure?
And how can I check their size and whether they are downloaded or not?

我已经尝试过下面的代码:

I have tried the code below:

private const string account = "romantest";
    private const string key = "bwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhfbwhf==";
    private const string url = "https://backup.blob.core.windows.net/";
    private const string containerName = "testcontainer";
    private const string blobName = "testblob";

// get storage
        StorageCredentialsAccountAndKey creds = new StorageCredentialsAccountAndKey(account, key);
        CloudBlobClient blobStorage = new CloudBlobClient(url, creds);

        // get blob container
        CloudBlobContainer blobContainer = blobStorage.GetContainerReference(containerName);

        // get blob data
        CloudBlob cloudBlob = blobContainer.GetBlobReference(blobName);
        string text = cloudBlob.DownloadText();

但它没有给出确切的结果。

你能帮助我吗?

But it's not giving the exact results.
Could you please help me?

或者我们可以比较它:


  • 从Excel或集合中的前提数据库。

  • 逐一阅读它们

  • 如果我们先阅读,然后(同时),我们可以检查azure blob容器是否存在相同的文件或不,和它的大小。已下载或不喜欢

请向我建议。

推荐答案

请参阅以下文章中的容器中的blob列表: http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

Please look at list the blobs in a container in the following article - http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

这段代码段应该有帮助。

The code snippet there should help.

这篇关于如何从azure blob容器下载和读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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