メインコンテンツへスキップ

AzCopy・PowerShellを使用したAzure Blob Storageへのファイルアップロード方法【企業向けガイド】

Table of Contents

このページを共有

Yifat Perry
Yifat Perry

既存のリポジトリから Azure Blob Storage にデータを移行し、ハイブリッド展開でデータを同期させることは、多くの組織にとってクラウド導入時の大きな課題となる可能性があります。特に企業規模の環境では、大容量データの移行と継続的なデータ同期は重要な検討事項です。 Azure へのデータ移行を支援する Azure ネイティブおよびサードパーティのツールやサービスがいくつかありますが、最も人気のあるものは AzCopy、Azure Import/Export、Azure PowerShell、Azure Data Box です。では、自社の要件に最適な移行ツールをどのように選定すればよいのでしょうか。

適切なツールの選択は、移行のタイムライン、データサイズ、ネットワーク帯域幅の可用性、オンライン/オフライン移行の要件など、いくつかの要因に依存します。さらに、セキュリティ要件、コンプライアンス、パフォーマンス目標も重要な判断基準となります。 このブログでは、これらの Azure 移行ツールのいくつかと、Azure Blob Storage にファイルを効率的に移行する手順を解説します。あわせて、NetApp Cloud Volumes ONTAP の高度なデータ管理機能を活用することで、Azure Blob Storage 環境におけるデータ移行の効率化、パフォーマンス最適化、データ保護強化を実現する方法も紹介します。 詳細については、以下をご確認ください。

詳細については、以下をクリックしてください:

Azure Blob Storageにデータをアップロードする主要ツール【企業向け】

データ移行とデータモビリティは、クラウド導入における重要な成功要因です。そのため、Microsoft はこれらのプロセスを支援するために、企業向けに最適化された複数のネイティブツールおよびサービスを提供しています。それぞれのツールは、移行規模や要件に応じて異なる特長を備えています。 ここでは、代表的なツールをいくつか詳しく見ていきましょう。

AzCopyは、Azure ストレージとの間でデータを転送するために使用されるコマンドライン ユーティリティです。これは、Windows、Linux、または Mac マシンにインストールして Azure へのデータ転送を開始できる軽量ツールです。AzCopyは、オンプレミスから Azure Blob や Azure Files へ、または Amazon S3 から Azure ストレージへのデータ転送など、さまざまなシナリオで使用できます。このツールは、Azure Stack との間のデータのコピーにも使用できます。

AzCopyを使用してAzureにデータをアップロードする方法については、こちらをクリックしてください

Azure PowerShellは、オンプレミスからAzure Blobストレージへデータを転送するための別のコマンドラインオプションです。Azure PowerShellコマンドSet-AzStorageBlobContentは、Azure Blobストレージにデータをコピーするために使用できます。

Azure PowerShell とその使用方法については、こちらをクリックしてください

Azure Import/Export は、Azure Blob Storage または Azure Files との間でデータをインポートまたはエクスポートする必要がある大規模なデータ転送シナリオで使用される物理的な転送方法です。このソリューションは、大規模なデータ転送に加えて、コンテンツ配信やデータのバックアップ/リストアなどのユースケースにも使用できます。データは、お客様が用意した SSD または HDD で Azure データセンターに出荷されます。

Azure Data Box は、Microsoft が提供する独自の Data Box ストレージデバイスを使用して、Azure データセンターとの間でデータを転送します。このサービスは、データサイズが 40 TB を超え、ネットワーク経由でデータを転送する帯域幅が限られているシナリオで推奨されます。最も一般的なユースケースは、データの 1 回限りの一括移行、Azure への最初のデータ転送とそれに続くネットワーク経由の増分転送、および一括データの定期的なアップロードです。

AzCopyでAzure Blob Storageにファイルをアップロードする方法

AzCopyは、Windows、Linux、およびMacOSシステムで使用できます。AzCopyは実行可能ファイルとして実行されるため、インストールは必要ありません。ツールを実行するには、WindowsおよびLinux用のzipファイルをダウンロードして展開する必要があります。Linuxの場合は、コマンドを実行する前に、tarファイルをダウンロードして解凍する必要があります。

AzCopyツールは、Azure ADまたはSASトークンを使用してAzure Blob storageへのアクセスを承認できます。Azure AD認証を使用する場合、顧客はデータのコピーを開始する前にユーザーアカウントで認証することを選択できます。自動化スクリプトを使用する場合、サービスプリンシパルまたはマネージドIDを使用してAzure AD認証を実現できます。

このAzCopyのウォークスルーでは、Azure ADユーザーアカウントによる認証を使用します。アカウントには、データのコピー先となるストレージコンテナー、および使用するストレージアカウント、リソースグループ、サブスクリプションにおいて、Storage Blob Data ContributorロールまたはStorage Blob Data Ownerロールのいずれかが割り当てられている必要があります。

  1. AzCopy がダウンロードされているフォルダを参照し、次のコマンドを実行してログインします:

    azcopy login
    

    https://microsoft.com/deviceloginへのログイン方法の詳細が表示されます。出力の指示に従い、表示された認証用のコードを使用します。

  2. ログイン ページで、ストレージへのアクセス権を持つ Azure 資格情報を入力し、「次へ」をクリックします。

  3. コマンドラインに戻ると、「login succeeded」というメッセージが表示されます。

  4. 以下のAzCopyコマンドを実行して、ストレージアカウントにファイルをアップロードするためのコンテナーを作成します:

    azcopy make "https://.blob.core.windows.net/"
    

    <Azure storage account name> プレースホルダーを Azure のストレージアカウントの名前で更新し、<container> を作成するコンテナの名前で更新します。以下にサンプルコマンドを示します:

    azcopy make「https://teststor1110.blob.core.windows.net/folder1"
    
AzCopyコマンドを実行する
  • ローカルマシンから Storage account にファイルをコピーするには

    azcopy copy "https://.core.windows.net//"
    

    上記のコマンドの<Local of file in local disk>と<Azure storage account name>のプレースホルダーを環境の値に更新し、<container>を手順4で作成したストレージコンテナーの名前に置き換えます。

    以下にサンプルコマンドを示します:

    azcopy copy 'C:azcopyTestcopyolder1ile1.txt' 'https://teststor1110.blob.core.windows.net/folder1'
    

    注:上記の例では、上記のコマンドの folder1 は手順 4 で作成されたコンテナです。

  • ローカルマシンから Storage account にファイルをコピーする

    コマンドが正常に完了すると、ジョブのステータスが「完了」と表示されます。

  • ローカル フォルダーから Azure ストレージ コンテナーにすべてのファイルをコピーするには、次のコマンドを実行します:

    azcopy copy "" 'https://.blob.core.windows.net/' --recursive
    

    上記のコマンドの<Location of folder in local disk>、<Azure storage account name>、<container>プレースホルダーを環境の値に合わせて更新してください。以下にサンプルコマンドを示します:

    azcopy copy "C:azcopyTestcopysample" "https://teststor1110.blob.core.windows.net/folder1" --recursive
    

    ソース フォルダーの内容は次のように表示されます:

  • ソースフォルダーの内容
  • Azure ポータルでストレージ アカウントを参照すると、Azure ストレージ コンテナー内にフォルダーが作成され、そのフォルダー内にファイルがコピーされていることがわかります。

  • Azure ストレージコンテナ内にフォルダが作成されました
  • Azure ストレージに新しいフォルダーを作成せずにローカル フォルダーの内容をコピーするには、次のコマンドを使用します:

    azcopy copy "/*" 'https://.blob.core.windows.net/'
    

    以下にサンプルコマンドを示します:

    azcopy copy "C:azcopyTestcopyolder2*" "https://teststor1110.blob.core.windows.net/folder1"
    
  • 追加ファイルは、以下に示すように、folder2 という名前のローカル フォルダーから Azure コンテナーの folder1 にコピーされます。この場合、ソース フォルダーは作成されないことに注意してください。

  • Azure PowerShellとは何か、そしてその使い方

    Azure PowerShell コマンドレットを使用して、PowerShell コマンドおよびスクリプトから Azure リソースを管理できます。AzCopy に加えて、PowerShell を使用してローカルフォルダから Azure ストレージにファイルをアップロードすることもできます。Azure PowerShell コマンド Set-AzStorageBlobContent は同じ目的で使用されます。

    Azure PowerShellを使用したAzure Blob Storageへのファイル転送

    このセクションでは、WindowsマシンからPowerShellを使用してAzure BLOBストレージにファイルをアップロードするために使用できるコマンドについて説明します。

    1. 次のコマンドを使用して、管理者権限で開いたPowerShellセッションで、システム上のすべてのユーザーに対して最新バージョンのAzure PowerShellをインストールします:

      Install-Module -Name Az -AllowClobber -Scope AllUsers
      

      パッケージをインストールする権限を求められたら、「はい」を選択します。

    2. 次のコマンドを使用し、プロンプトが表示されたら Azure サブスクリプションにサインインします:

      Connect-AzAccount
      
    3. 次のコマンドを使用して、データ転送に使用するストレージアカウントコンテキストを取得します:

      $uploadstorage=Get-AzStorageAccount -ResourceGroupName <resource group name> -Name <storage account name>
      
      $storcontext=$uploadstorage.Context

      プレースホルダー<resource group name>および<storage account name>を、以下のサンプルコマンドのように環境固有の値で更新します:

      $uploadstorage=Get-AzStorageAccount -ResourceGroupName cvo177 -Name teststor1110
      

      $storcontext=$uploadstorage.Context
    4. ローカル ディレクトリから Azure ストレージ内のコンテナーにファイルをアップロードするには、次のコマンドを実行します:

      Set-AzStorageBlobContent -Container「<storage container name>」-File「<Location of file in local disk>」-Context $storcontext
      

      プレースホルダー<storage container name>と<Location of file in local disk>を環境固有の値に置き換えます。以下にサンプルを示します:

      Set-AzStorageBlobContent -Container「<storage container name>」-File「<Location of file in local disk>」-Context $storcontext
      

      ファイルが正常にアップロードされると、以下のスクリーンショットに示すようなメッセージが表示されます:

    5. 現在のフォルダ内のすべてのファイルをアップロードするには、次のコマンドを実行します

      Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container「<storage container name>」-Context $storcontext
      

      以下にサンプルコマンドを示します:

      Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container「folder2」-Context $storcontext
      
    6. Azure ストレージコンテナーを参照すると、手順 4 と 5 でアップロードされたすべてのファイルが表示されます。

    NetApp Cloud Volumes ONTAP:企業向けクラウドデータ移行を加速

    Azureへのデータ移行が、AzCopyとAzurePowerShellコマンドを使用して簡単に実現できる方法について説明しました。お客様は、信頼できるNetAppレプリケーションおよびクローニング技術を通じて、クラウドへのデータ移行にNetApp Cloud Volumes ONTAPを活用することもできます。Cloud Volumes ONTAPは、オンプレミスと複数のクラウド環境にまたがるハイブリッドデータ管理ソリューションを提供します。

    Cloud Volumes ONTAPは、高可用性、データ保護機能、および重複排除、圧縮、シンプロビジョニングなどのStorage Efficiency機能を通じて顧客に提供する価値で際立っています。Cloud Volumes ONTAPボリュームは、Azureの仮想マシンからSMB / NFSプロトコルを介してアクセスでき、これらの機能を通じて他に類を見ないストレージの経済性を実現するのに役立ちます。ストレージの使用効率が向上するにつれて、Azureのストレージ コストも大幅に削減されます。

    NetApp Snapshot™テクノロジとSnapMirror®データ レプリケーションを併用することで、オンプレミス環境からクラウドへのデータ移行をスムーズに進めることができます。SnapShotテクノロジを使用すると、オンプレミスNetAppストレージからデータのポイントインタイム バックアップ コピーを作成できますが、SnapMirrorデータ レプリケーションを使用すると、Azure内のCloud Volumes ONTAPボリュームにコピーをレプリケートするのに役立ちます。DR目的で、オンプレミス環境とクラウド環境の間でデータを同期させるためにも利用できます。

    NetApp FlexClone® データクローニング技術は、オンプレミスボリュームのストレージ効率に優れた書き込み可能なクローンを作成し、CI/CDプロセスに統合してクラウド上でテスト/開発環境を展開するのに役立ちます。これにより、オンプレミスからクラウドへの、またクラウド内でのデータポータビリティが向上し、すべてを統合管理画面から管理できます。このように、Cloud Volumes ONTAPは組織がアプリケーションの俊敏性と市場投入までの時間短縮を実現するのに役立ちます。

    もう1つのNetAppデータ移行サービスはCloud Syncです。オンプレミス システムからでも、クラウド間でも、任意のリポジトリからクラウド上のオブジェクトベース ストレージにデータを迅速かつ効率的に移行できます。

    まとめ:企業向けクラウドデータ移行のポイント

    お客様は、AzCopy や Azure PowerShell などのネイティブツールを活用して、Azure Blob Storage にファイルをアップロードできます。さらに、エンタープライズ環境では、SnapMirror レプリケーション、NetApp Snapshot、FlexClone などの機能を使用することで、Cloud Volumes ONTAP を基盤とした高度なデータ管理、効率的なデータ移行、継続的なデータ保護を実現できます。

    Copy a file from your local machine to Storage account

    Upon successful completion of the command, the job status will be shown as Completed.

  • To copy all files from a local folder to the Azure storage container run the following command:

    azcopy copy "" 'https://.blob.core.windows.net/' --recursive
    

    Update the <Location of folder in local disk>, <Azure storage account name>, and <container> placeholders in the above command to reflect values of your environment. Sample command given below:

    azcopy copy "C:azcopyTestcopysample" "https://teststor1110.blob.core.windows.net/folder1" --recursive
    

    Your source folder content will appear as below:

  • Source folder content
  • If you browse to the Storage account in the Azure portal, you can see that the folder has been created inside the Azure storage container and that the files are copied inside the folder.

  • The folder has been created inside the Azure storage container
  • To copy contents of the local folder without creating a new folder in Azure storage, you can use the following command:

    azcopy copy "/*" 'https://.blob.core.windows.net/'
    

    Sample command given below:

    azcopy copy "C:azcopyTestcopyolder2*" "https://teststor1110.blob.core.windows.net/folder1"
    
  • Use the command above
  • The additional files are copied from the local folder named folder2 to the Azure container folder1, as shown below. Note that the source folder is not created in this case.

  • Additional files are copied from the local folder

    What Is Azure PowerShell and How to Use It

    Azure PowerShell cmdlets can be used to manage Azure resources from PowerShell command and scripts. In addition to AzCopy, Powershell can also be used to upload files from a local folder to Azure storage. The Azure PowerShell command Set-AzStorageBlobContent is used for the same purpose.

    File Transfers to Azure Blob Storage Using Azure PowerShell

    In this section we will look into the commands that can be used to upload files to Azure blob storage using PowerShell from a Windows machine.

    1. Install the latest version of Azure PowerShell for all users on the system in a PowerShell session opened with administrator rights using the following command:

      Install-Module -Name Az -AllowClobber -Scope AllUsers
      

      Select “Yes” when prompted for permissions to install packages.

    Click
  • Use the following command and sign-in to your Azure subscription when prompted:

    Connect-AzAccount
    
  • Azure sign in
  • Get the storage account context to be used for the data transfer using the following commands:

    $uploadstorage=Get-AzStorageAccount -ResourceGroupName <resource group name> -Name <storage account name>
    
    $storcontext=$uploadstorage.Context

    Update the place holders <resource group name> and <storage account name> with values specific to your environment, as in the sample command given below:

    $uploadstorage=Get-AzStorageAccount -ResourceGroupName cvo177 -Name teststor1110
    

    $storcontext=$uploadstorage.Context
  • How to Upload Files to Azure Blob Storage wit - Inline Image 12 [po-j8tx]and values">
  • Run the following command to upload a file from your local directory to a container in Azure storage:

    Set-AzStorageBlobContent -Container "<storage container name>" -File "<Location of file in local disk>" -Context $storcontext
    

    Replace the placeholders <storage container name> and <Location of file in local disk> with values specific to your environment. Sample given below:

    Set-AzStorageBlobContent -Container "<storage container name>" -File "<Location of file in local disk>" -Context $storcontext
    

    Once the file is uploaded successfully, you will get a message similar to what you can see in the screenshot below:

  • File upload confirmation message
  • To upload all files in the current folder, run the following command

    Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container "<storage container name>" -Context $storcontext
    

    Sample command given below:

    Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container "folder2" -Context $storcontext
    
  • Run the command above to upload all files in the current folder
  • If you browse to the Azure storage container, you will see all the files uploaded in steps 4 and 5.

  • Copy Files

    NetApp Cloud Volumes ONTAP: Accelerate Cloud Data Migration

    We have discussed how data migration to Azure can be easily achieved using AzCopy and Azure PowerShell commands. Customers can also leverage NetApp Cloud Volumes ONTAP for data migration to the cloud through trusted NetApp replication and cloning technology. Cloud Volumes ONTAP delivers a hybrid data management solution, spanning on-premises as well as multiple cloud environments.

    Cloud Volumes ONTAP is distinguished by the value it provides to its customers through high availability, data protection, and storage efficiency features such as deduplication, compression and thin provisioning. Cloud Volumes ONTAP volumes can be accessed by virtual machines in Azure over SMB/NFS protocols and helps in achieving unparalleled storage economy through these features. As the storage is being used more efficiently, Azure storage cost is also reduced considerably.

    NetApp Snapshot technology along with SnapMirror® data replication can ease up the data migration from on-premises environments to the cloud. While SnapShot technology can be used to take Point-in-time backup copies of data from on-premises NetApp storage, SnapMirror data replications helps to replicate them to Cloud Volumes ONTAP volumes in Azure. The service can also be used to keep data between on-premises and cloud environments in sync for DR purposes.

    NetApp FlexClone® data cloning technology helps in creating storage efficient writable clones of on-premises volumes that can be integrated into CI/CD processes to deploy test/dev environments in the cloud. This enhances data portability from on-premises to cloud and also within the cloud, which can all be managed from a unified management pain. Thus, Cloud Volumes ONTAP helps organizations achieve agility and faster time to market for their applications.

    Another NetApp data migration service is Cloud Sync, which can quickly and efficiently migrate data from any repository to object-based storage in the cloud, whether it’s from an on-prem system or between clouds.

    Conclusion

    Customers can choose from native tools like AzCopy and Azure PowerShell to upload files to Azure Blob Storage. They can also leverage Cloud Volumes ONTAP for advanced data management and migration capabilities using features like SnapMirror replication, NetApp Snapshots and FlexClone.

    Yifat Perry

    Yifat Perry

    Yifat Perryのすべての投稿を見る

    次のステップ

    AzCopy・PowerShellでAzure Blobへアップロード | NetApp