I have two goals: Learn more about Git and learn about DMLib. Azure Storage Data Movement Library (DMLib) has the same performance and exposes the core functionalities of AzCopy and this is an awesome super(ficial) review of one of its methods. It’s not that in-depth, but it does a good job of checking just beneath the hood. I’m going to try to use commits and branches to tell the story, the real goal of this post. This is a simple example to start out, but if you like this method of storytelling using Git, or if you don’t, leave a comment!
On January 7th, Microsoft posted to the Azure Blog that there is a new release of DMLib and it rev’ed to 0.2.0. Lot’s of work went into giving us the ability to move directories around: up to Azure, around in Azure, you get the idea. I’ve played a lot with AzCopy, on which this particular set of classes is based. I’ve not played at all with DMLib, but it’s a big deal, so let’s have a look.
We have a repository to work from hosted at: https://github.com/devdash/AzureStorageDataMovementTester. I want you to first focus on the branches, there are four: ParallelOps, ProgressManager, SvcPointMgr, and of course master. We’ll follow the Branches and commits in this order:
Let’s take a step back and have a look at the documentation for DMLib, the reasons for these branches will become apparent. The docs have you Upload a blob. This upload creates a progress tracker and configures parallel operations. There is a best practice section in the docs that talks about increasing the HTTP connections limit using the ServicePointManager class. Now have a look at the commits for the “last” branch…
As you see, the commits/branches mirror the examples the documentation gives us. It also let’s us switch between different configurations of the uploader, so that we can test the functionality of what each piece of code adds. Cool! I think this is a neat way of using Git, not just for keeping code safe, but also as a learning tool.
Enough of the Git horse play, let us look at the code! The “Initial Commit” is nothing more than GitHub creating the repo, so we’ll skip over that and only four commits left. Starting with the master branch I simply added the project with a bit of bits already laid down. This code will take a ZIP file found in the project and upload it to blob storage. We will use the app.config file and drop the connection string in, hit F5 and it uploads the file. It then pauses and waits for you to verify everything has worked as expected. If it has you can the hit any key and it will clean up all the changes it just made to you storage account and close. Simple.
The Code that Does the Dang Thing
From the Master Branch: