Random tech posts

Menu

AzureCopy assembly howto…

Now that AzureCopy has been split into a client executable and associated dll, it’s now possible to use the dll for your own applications. In this example I’ll show how to write a simple application to copy files from S3 to Azure Blob Storage. (again, for practical reasons I’d suggest using azurecopy executable itself… but hey, for those that want to code below are the steps required).

Firstly, learn to love Nuget. It the one stop shop for all your .NET assemblies and other dependencies. Assuming you know how to use it (if not, please see docs), add the “azurecopy” reference to your application. (in my case I’ll be creating a simple console app).

The AzureCopy dll has a number of key classes that implement the same simple interface. IBlobHandler is simply

– ReadBlob reads the blob stored at a given URL (with optional filePath if you want to cache it on local storage before copying to another cloud location).

– WriteBlob writes a blob to a given URL. Uploading can be performed in parallel for some cloud providers. You can specify the level of parallelism as well as how large those parallel chunks should be. These features will be expanded with future releases.

– ListBlobsInContainer is well, given a URL, list the blob contents (non-recursively).

Currently AzureCopy reads all its configuration from an App.Config file. Ideally these configurations will get injected by the client app, but for now, App.Config works fine.

In this case I want to copy from the S3 URL and write into the azureURL. The blob is stored in the S3 bucket “testabc123” (made up) and is writing to the Azure Storage account “myblobstorage” (again, made up) and put into the “temp” container.

This is just a starter on how to use AzureCopy assembly. In future posts I’ll go over more complex scenarios such as copying multiple files, asking Azure to do the copying for you (so you dont use any bandwidth!!!) among other things.