Not able to read all folders & files available in azure storage container using c#? -
i using below code read files available in azure :
private const string account = "testaccount"; private const string key = "i1ymjhk1pp10kbxu4mnuaxxnsupk3usn8b85ttsunxzo+wlz+uybfl/mckd8q7yqaa=="; private const string url = "http://testaa.blob.core.windows.net/contractattachments/201503/20150302110215315197/20150331114910310626/test%20-%20copy%20-%20file.txt"; private const string containername = "testfiles"; private const string blobname = "file1"; static void main(string[] args) { // storage storagecredentialsaccountandkey creds = new storagecredentialsaccountandkey(account, key); cloudblobclient blobstorage = new cloudblobclient(url, creds); //get blob container cloudblobcontainer blobcontainer = blobstorage.getcontainerreference(containername); blobcontainerpermissions permissions = new blobcontainerpermissions(); permissions.publicaccess = blobcontainerpublicaccesstype.blob; blobcontainer.setpermissions(permissions); //get blob data cloudblob cloudblob = blobcontainer.getblobreference(blobname); //string text = cloudblob.downloadtext(); // print text // console.writeline(text); //list blobs , directories in container var blobs = blobcontainer.listblobs(); list<string> listofblobs=new list<string>(); foreach (var blobitem in blobs)// exception ----the requested uri not represent resource on server. { blobitem.container.getpermissions(); } foreach (var blobitem in blobs) { string bolbname = blobitem.container.name.tostring(); console.writeline(blobitem.uri); } }
> have above mentioned storage account , there containers in account. again container contains sub folders , sub folder contains ..some files .....so requirement read files available container ... first of trying read files 1 container ..but giving me exception below requested uri not represent resource on server. please me.....let me know if missing ...
url
not point azure blob service account though passed cloudblobclient's constructor. please consider using cloudstorageaccount instead , instantiate cloudblobclient using createcloudblobclient.storagecredentialsaccountandkey
removed in azure storage client library 2.0, using old version. please consider upgrading latest version performance improvements , bug fixes.
Comments
Post a Comment