(සචියාගේ ටෙක් බොලොගය)

Breaking

Welcome to Sachin's technology blog site.

Wednesday, July 4, 2018

AzCopy stuck? No progress? Add the correct parameter to AzCopy

Recently I have face an issue with Azure AzCopy upload to blob. My AzCopy command is worked and while uploading data to blob storage, it was stuck and no more progress shown in the power shell or log file.

before use AzCopy you should read full Microsoft AzCopy documentation related to upload data from windows. https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy


while uploading multiple files in to blob storage AzCopy will prompt confirmations. but it wont show in your power shell screen.



















this could be the reason of stuck your upload.

the solution is /Y parameter

.\AZCopy.exe /Source:$path /Dest:$BlobServiceEndpoint$ContainerName/$name /DestKey:$BlobAccessKey  /Z:restart.log  /S /XO /Y /V:azcopyupload.log


this will suppresses all AzCopy confirmation prompts

here I upload my customized command for uploading one by one folder to my blog container

$SourceDirPath = Read-Host -Prompt 'Insert Source Directory Path (Fully Qualified Directory Path)'
$BlobServiceEndpoint = Read-Host -Prompt 'Insert Primary Blob Service Endpoint (Available in Storage account properties)'
$BlobAccessKey = Read-Host -Prompt 'Insert Blob Access Key'
$ContainerName = Read-Host -Prompt 'Insert Container Name (Container will be created if do not exist)'
$CompanyFolderName = Read-Host -Prompt 'Insert Company Folder Name to upload files belong to single company(Leave this blank to upload all files)'
$directories = Get-ChildItem -Path $SourceDirPath
Write-Output $directories;
Foreach($directory in $directories)
{
    $name = $directory.Name
    if([string]::IsNullOrEmpty($CompanyFolderName) -or $name.ToLower() -contains $CompanyFolderName.ToLower())
    {
        if(-not ([string]::IsNullOrEmpty($name)))
        {
            Write-Output 'Uploading company files: ' + $CompanyFolderName;
        }
    $name = $name -replace '[.,_]','-'
    $name = $name.ToLower()
    $path = $directory.FullName
    Write-Output $name;
    Write-Output $path;
        .\AZCopy.exe /Source:$path /Dest:$BlobServiceEndpoint$ContainerName/$name /DestKey:$BlobAccessKey  /Z:restart.log  /S /XO /Y /V:azcopyupload.log
    }
}

2 comments:

  1. I'm impressed with AzCopy's ability to stay stuck in a situation like this! Thankfully, all it takes is adding the correct parameter to get it moving again. Its Drago It's great that AzCopy can help us out so quickly and easily.

    ReplyDelete
  2. Insurance companies use fax services to exchange sensitive policyholder information securely.
    Fax Services Network

    ReplyDelete