How to download and read files from azure blob container

戏子无情 提交于 2019-12-11 10:12:56

问题


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.

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?

Or else we can compare its like:

  • We will store all files from a premise database in Excel or collection.
  • Read them one by one
  • Ehen we read first then (at the same time) we can check in azure blob container whether the same file exists or not, and its size. Downloaded or not like that

Please suggest me anything.


回答1:


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.



来源:https://stackoverflow.com/questions/29726115/how-to-download-and-read-files-from-azure-blob-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!