Azure blob download is blocked -
i downloading large azure blob (6 gb) web application. blob downloaded web server after 40 minutes, application blocked in wcf line of code downloads blob, , gives timeout exception. file smaller don't have problem.
here code:
mvc controller:
timeoutminutes = 60; basichttpbinding binding = new basichttpbinding(); endpointaddress address = new endpointaddress(endpoint); factory = new channelfactory<remotingservicelibrary.iremotingservice>(binding, address); factory.endpoint.binding.sendtimeout = new timespan(0, timeoutminutes, timeoutseconds); iremotingservice channel = factory.createchannel(); channel.loadblob(containername, blobname, sqlmachinebackupfile, connectionstring);
wcf:
public string loadblob(string blobcontainer, string blobname, string destinationfilepath, string connectionstring) { try { cloudstorageaccount storageaccount = cloudstorageaccount.parse(connectionstring); cloudblobclient blobclient = storageaccount.createcloudblobclient(); cloudblobcontainer container = blobclient.getcontainerreference(blobcontainer); cloudblockblob blob = container.getblockblobreference(blobname); int segmentsize = 1 * 1024 * 1024; blob.fetchattributes(); var bloblengthremaining = blob.properties.length; long startposition = 0; { long blocksize = math.min(segmentsize, bloblengthremaining); byte[] blobcontents = new byte[blocksize]; using (memorystream ms = new memorystream()) { blob.downloadrangetostream(ms, startposition, blocksize); ms.position = 0; ms.read(blobcontents, 0, blobcontents.length); using (filestream fs = new filestream(destinationfilepath, filemode.openorcreate)) { fs.position = startposition; fs.write(blobcontents, 0, blobcontents.length); } } startposition += blocksize; bloblengthremaining -= blocksize; } while (bloblengthremaining > 0); } catch (exception ex) { return ex.message; } return "ok"; }
thanks in advance
Comments
Post a Comment