開始使用 AzCopyGet started with AzCopy

AzCopy 是命令列公用程式,可讓您在儲存體帳戶之間複製 Blob 或檔案。AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. 本文可協助您下載 AzCopy、連線到您的儲存體帳戶,然後傳輸檔案。This article helps you download AzCopy, connect to your storage account, and then transfer files.


AzCopy V10 是目前支援的 AzCopy 版本。AzCopy V10 is the currently supported version of AzCopy.

如果您需要使用舊版的 AzCopy,請參閱本文的「 使用舊版的 AzCopy 」一節。If you need to use a previous version of AzCopy, see the Use the previous version of AzCopy section of this article.

下載 AzCopyDownload AzCopy

首先,將 AzCopy V10 可執行檔下載至您電腦上的任何目錄。First, download the AzCopy V10 executable file to any directory on your computer. AzCopy V10 只是一個可執行檔,因此不需要安裝任何專案。AzCopy V10 is just an executable file, so there's nothing to install.

這些檔案會壓縮成 zip 檔案 (Windows 和 Mac) 或 (Linux) 的 tar 檔案。These files are compressed as a zip file (Windows and Mac) or a tar file (Linux). 若要下載並解壓縮 Linux 上的 tar 檔案,請參閱您 Linux 發行版本的檔。To download and decompress the tar file on Linux, see the documentation for your Linux distribution.


如果您想要將資料複製到您的 Azure 表格儲存體 服務或從中複製資料,請安裝 AzCopy 7.3 版If you want to copy data to and from your Azure Table storage service, then install AzCopy version 7.3.

執行 AzCopyRun AzCopy

為了方便起見,請考慮將 AzCopy 可執行檔的目錄位置新增至您的系統路徑,以方便使用。For convenience, consider adding the directory location of the AzCopy executable to your system path for ease of use. 如此一來,您就可以 azcopy 從系統上的任何目錄進行輸入。That way you can type azcopy from any directory on your system.

如果您選擇不要將 AzCopy 目錄新增至您的路徑,您必須將目錄變更為 AzCopy 可執行檔的位置,並 azcopy .\azcopy 在 Windows PowerShell 命令提示字元中輸入或。If you choose not to add the AzCopy directory to your path, you'll have to change directories to the location of your AzCopy executable and type azcopy or .\azcopy in Windows PowerShell command prompts.

若要查看命令的清單,請輸入, azcopy -h 然後按下 enter 鍵。To see a list of commands, type azcopy -h and then press the ENTER key.

若要瞭解特定命令,請只包含命令的名稱 (例如: azcopy list -h) 。To learn about a specific command, just include the name of the command (For example: azcopy list -h).

內嵌說明Inline help

若要尋找每個命令和命令參數的詳細參考檔,請參閱 azcopyTo find detailed reference documentation for each command and command parameter, see azcopy


作為 Azure 儲存體帳戶的擁有者,您不會自動獲指派存取資料的許可權。As an owner of your Azure Storage account, you aren't automatically assigned permissions to access data. 您必須先決定要如何為儲存體服務提供授權認證,才能使用 AzCopy 來進行任何有意義的動作。Before you can do anything meaningful with AzCopy, you need to decide how you'll provide authorization credentials to the storage service.

授權 AzCopyAuthorize AzCopy

您可以使用 Azure Active Directory (AD) 或使用共用存取簽章 (SAS) 權杖來提供授權認證。You can provide authorization credentials by using Azure Active Directory (AD), or by using a Shared Access Signature (SAS) token.

使用此資料表作為指南:Use this table as a guide:

儲存體類型Storage type 目前支援的授權方法Currently supported method of authorization
Blob 儲存體Blob storage Azure AD 和 SASAzure AD & SAS
Blob 儲存體 (階層命名空間)Blob storage (hierarchical namespace) Azure AD 和 SASAzure AD & SAS
檔案儲存體File storage 僅限 SASSAS only

選項1:使用 Azure Active DirectoryOption 1: Use Azure Active Directory

此選項僅適用于 blob 儲存體。This option is available for blob Storage only. 藉由使用 Azure Active Directory,您可以提供一次認證,而不需要將 SAS 權杖附加至每個命令。By using Azure Active Directory, you can provide credentials once instead of having to append a SAS token to each command.


在目前的版本中,如果您打算在儲存體帳戶之間複製 blob,則必須將 SAS 權杖附加至每個來源 URL。In the current release, if you plan to copy blobs between storage accounts, you'll have to append a SAS token to each source URL. 您只能從目的地 URL 中省略 SAS 權杖。You can omit the SAS token only from the destination URL. 如需範例,請參閱 在儲存體帳戶之間複製 blobFor examples, see Copy blobs between storage accounts.

若要使用 Azure AD 來授與存取權,請參閱使用 AzCopy 和 Azure Active Directory (Azure AD) 來授權存取 blob To authorize access by using Azure AD, see Authorize access to blobs with AzCopy and Azure Active Directory (Azure AD).

選項2:使用 SAS 權杖Option 2: Use a SAS token

您可以將 SAS 權杖附加至每個在 AzCopy 命令中使用的來源或目的地 URL。You can append a SAS token to each source or destination URL that use in your AzCopy commands.

此範例命令會以遞迴方式將資料從本機目錄複寫到 blob 容器。This example command recursively copies data from a local directory to a blob container. 虛構的 SAS 權杖會附加至容器 URL 的結尾。A fictitious SAS token is appended to the end of the container URL.

azcopy copy "C:\local\path" "https://account.blob.core.windows.net/mycontainer1/?sv=2018-03-28&ss=bjqt&srt=sco&sp=rwddgcup&se=2019-05-01T05:01:17Z&st=2019-04-30T21:01:17Z&spr=https&sig=MGCXiyEzbtttkr3ewJIh2AR8KrghSy1DGM9ovN734bQF4%3D" --recursive=true

若要深入瞭解 SAS 權杖,以及如何取得 SAS 權杖,請參閱 使用共用存取簽章 (SAS) To learn more about SAS tokens and how to obtain one, see Using shared access signatures (SAS).

傳送資料Transfer data

授權您的身分識別或取得 SAS 權杖之後,您就可以開始傳輸資料。After you've authorized your identity or obtained a SAS token, you can begin transferring data.

若要尋找範例命令,請參閱這些文章。To find example commands, see any of these articles.

服務Service 發行項Article
Azure Blob 儲存體Azure Blob Storage 將檔案上傳至 Azure Blob 儲存體Upload files to Azure Blob Storage

從 Azure Blob 儲存體下載 blobDownload blobs from Azure Blob Storage

在 Azure 儲存體帳戶之間複製 blobCopy blobs between Azure storage accounts

與 Azure Blob 儲存體同步處理Synchronize with Azure Blob Storage
Azure 檔案Azure Files 使用 AzCopy 和檔案儲存體傳輸資料 (機器翻譯)Transfer data with AzCopy and file storage
Amazon S3Amazon S3 使用 AzCopy 和 Amazon S3 貯體轉送資料Transfer data with AzCopy and Amazon S3 buckets
Azure Stack 儲存體Azure Stack storage 使用 AzCopy 和 Azure Stack 儲存體傳輸資料Transfer data with AzCopy and Azure Stack storage

在腳本中使用Use in a script

經過一段時間後,AzCopy 下載連結 會指向 AzCopy 的新版本。Over time, the AzCopy download link will point to new versions of AzCopy. 如果您的腳本下載 AzCopy,如果較新版本的 AzCopy 修改您的腳本所依賴的功能,腳本可能會停止運作。If your script downloads AzCopy, the script might stop working if a newer version of AzCopy modifies features that your script depends upon.

若要避免這些問題,請) 連結至 AzCopy 的目前版本,取得靜態 (不變的連結。To avoid these issues, obtain a static (unchanging) link to the current version of AzCopy. 如此一來,您的腳本就會在每次執行時下載相同的 AzCopy 完全相同版本。That way, your script downloads the same exact version of AzCopy each time that it runs.

若要取得連結,請執行下列命令:To obtain the link, run this command:

作業系統Operating system 命令Command
LinuxLinux curl -s -D- https://aka.ms/downloadazcopy-v10-linux | grep ^Location
WindowsWindows (curl https://aka.ms/downloadazcopy-v10-windows -MaximumRedirection 0 -ErrorAction silentlycontinue).headers.location


若是 Linux, --strip-components=1 命令上的 tar 命令會移除包含版本名稱的最上層資料夾,並改為將二進位檔直接解壓縮到目前的資料夾中。For Linux, --strip-components=1 on the tar command removes the top-level folder that contains the version name, and instead extracts the binary directly into the current folder. 這可讓您只更新 URL 來更新腳本的新版本 azcopy wgetThis allows the script to be updated with a new version of azcopy by only updating the wget URL.

URL 會出現在此命令的輸出中。The URL appears in the output of this command. 然後,您的腳本就可以使用該 URL 來下載 AzCopy。Your script can then download AzCopy by using that URL.

作業系統Operating system 命令Command
LinuxLinux wget -O azcopy_v10.tar.gz https://aka.ms/downloadazcopy-v10-linux && tar -xf azcopy_v10.tar.gz --strip-components=1
WindowsWindows Invoke-WebRequest https://azcopyvnext.azureedge.net/release20190517/azcopy_windows_amd64_10.1.2.zip -OutFile azcopyv10.zip <<Unzip here>>

在 SAS 權杖中 Escape 特殊字元Escape special characters in SAS tokens

在副檔名為的批次檔中 .cmd ,您必須將 % 出現在 SAS 權杖中的字元進行換用。In batch files that have the .cmd extension, you'll have to escape the % characters that appear in SAS tokens. 若要這麼做,您可以 % % 在 SAS 權杖字串中的現有字元旁新增額外的字元。You can do that by adding an additional % character next to existing % characters in the SAS token string.

使用 Jenkins 執行腳本Run scripts by using Jenkins

如果您打算使用 Jenkins 來執行腳本,請務必在腳本的開頭放置下列命令。If you plan to use Jenkins to run scripts, make sure to place the following command at the beginning of the script.

/usr/bin/keyctl new_session

在 Azure 儲存體總管中使用Use in Azure Storage Explorer

儲存體總管 使用 AzCopy 來執行它的所有資料傳輸作業。Storage Explorer uses AzCopy to perform all of its data transfer operations. 如果您想要利用 AzCopy 的效能優勢,但想要使用圖形化使用者介面而非命令列來與檔案互動,您可以使用 儲存體總管You can use Storage Explorer if you want to leverage the performance advantages of AzCopy, but you prefer to use a graphical user interface rather than the command line to interact with your files.

儲存體總管會使用您的帳戶金鑰來執行操作,因此在您登入儲存體總管之後,就不需要提供額外的授權認證。Storage Explorer uses your account key to perform operations, so after you sign into Storage Explorer, you won't need to provide additional authorization credentials.

設定、優化和修正Configure, optimize, and fix

請參閱 設定、優化和疑難排解 AzCopySee Configure, optimize, and troubleshoot AzCopy

使用先前的版本Use a previous version

如果您需要使用舊版的 AzCopy,請參閱下列其中一個連結:If you need to use the previous version of AzCopy, see either of the following links:

後續步驟Next steps

如果您有任何疑問、問題或一般意見反應,請 在 GitHub 頁面上 提交。If you have questions, issues, or general feedback, submit them on GitHub page.