How to download and read files from azure blob con

2019-08-05 07:37发布

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条回答
闹够了就滚
2楼-- · 2019-08-05 08:29

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.

查看更多
登录 后发表回答