dotnet / AzCopyNet

.NET Library to seamlessly leverage AzCopy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AzCopy.Net

AzCopy.Net is a .net standard library for AzCopy. It is a thin wrapper out of AzCopy v10 cli.

Build Status Azure DevOps coverage License: MIT

Quick start

First, add nuget reference to AzCopy.Client. It provides straight forward API to call into AzCopy v10 cli.

<PackageReference Include="AzCopy.Client" Version="1.0.0" />

Then add reference to one of the four nuget asset packages based on your OS and platform. The version of these packages are corresponded to the version of azcopy v10 cli it carries with.

  • AzCopy.WinX64
  • AzCopy.WinX86
  • AzCopy.OsxX64
  • AzCopy.LinuxX64

For example:

<PackageReference Include="AzCopy.WinX64" Version="1.0.0" />

If azcopy v10 cli has already installed on your machine, you can also add its full path to $AZCOPYPATH. When running the app, AzCopy.Client will use the azcopy cli pointed by $AZCOPYPATH.

Finally, use AzCopy.Client the same way of using azcopy in cmd!

var localFile = new LocalLocation()
{
  UseWildCard = true,
  Path = @"src",
};

var sasLocation = new RemoteSasLocation()
{
    ResourceUri = @"uri",
    Container = @"container"
    Path = @"dest",
    SasToken = @"sastoken",
};

var option = new AZCopyOption()
{
    IncludePattern = "*.jpg;*.png",
};

var client = new AZCopyClient();

// subscribe output event hander to get output from azcopy v10 cli
client.OutputMsgHandler += (object sender, JsonOutputTemplate e) =>
            {
                Console.WriteLine(e.MessageContent);
            };
await client.CopyAsync(localFile, sasLocation, option);

Supported command

AzCopy.Net supports all commands that azcopy v10 cli has. The interface of supported command is AzCopy.Contract.IAZCopyClient, and is implemented by AzCopy.Client.AzCopyClient class.

The supported command list is presented below.

  • bench
  • copy
  • doc
  • env
  • jobs clean
  • jobs list
  • jobs remove
  • jobs resume
  • jobs show
  • list
  • login
  • logout
  • make
  • remove
  • sync

Tested senarios

The following scenarios have been validated on windows, mac os and ubuntu.

  • Upload files and directories to azure blob container (use SAS only)
  • Delete files and directories from azure blob container (use SAS only)
  • Download files and directories from azure blob container (use SAS only)

Nightly build

https://pkgs.dev.azure.com/xiaoyuz0315/BigMiao/_packaging/AzCopy.Net/nuget/v3/index.json

Pre-released package

AzCopy.Net Local
AzCopy.Contract AzCopy.Contract package in AzCopy.Net feed in Azure Artifacts
AzCopy.Client AzCopy.Client package in AzCopy.Net feed in Azure Artifacts
AzCopy.WinX64 AzCopy.WinX64 package in AzCopy.Net@Local feed in Azure Artifacts
AzCopy.WinX86 AzCopy.WinX86 package in AzCopy.Net@Local feed in Azure Artifacts
AzCopy.OsxX64 AzCopy.OsxX64 package in AzCopy.Net@Local feed in Azure Artifacts
AzCopy.LinuxX64 AzCopy.LinuxX64 package in AzCopy.Net@Local feed in Azure Artifacts

Examples

Check AzCopy.Test for more examples.

About

.NET Library to seamlessly leverage AzCopy

License:MIT License


Languages

Language:PowerShell 40.9%Language:C# 30.5%Language:Shell 26.1%Language:CMake 2.5%Language:Batchfile 0.1%