.NET Library to seamlessly leverage AzCopy
Перейти к файлу
Xiaoyun Zhang fe964018aa
update azcopy to 10.16.2 (#18)
* update azcopy to 10.16

* update azcopy

* update version
2022-12-19 21:12:47 -08:00
eng update azcopy to 10.16.2 (#18) 2022-12-19 21:12:47 -08:00
src update azcopy to 10.16.2 (#18) 2022-12-19 21:12:47 -08:00
.editorconfig use enum in contract (#6) 2020-08-28 23:14:49 -07:00
.gitignore Merge branch 'main' of https://github.com/dotnet/AzCopyNet into main 2020-09-18 12:03:49 -07:00
AzCopy.Net.sln rm azcopyService (#3) 2020-08-25 22:35:42 -07:00
CODE_OF_CONDUCT.md Link .NET Foundation Code of Conduct 2020-10-13 17:19:20 -07:00
CodeCoverage.runsettings add pipeline (#1) 2020-08-18 19:01:58 -07:00
Directory.Build.props migrate to arcade 2020-09-21 16:28:28 -07:00
Directory.Build.targets migrate to arcade 2020-09-21 16:28:28 -07:00
LICENSE Update ci.yaml for Azure Pipelines (#5) 2020-10-29 13:35:37 -07:00
NuGet.config wrap remote location inside quote when transfer to string (#11) 2021-02-25 21:30:03 -08:00
README.md Link .NET Foundation Code of Conduct 2020-10-13 17:19:20 -07:00
SECURITY.md Initial SECURITY.md commit 2020-09-18 11:53:03 -07:00
ci.yaml Update ci.yaml 2021-10-22 10:52:39 -07:00
global.json migrate to arcade 2020-09-21 16:28:28 -07:00
stylecop.json init 2020-08-18 16:01:37 -07:00

README.md

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.