Skip to content

Commit

Permalink
Resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivangi authored and Shivangi committed May 11, 2020
1 parent c12dbaf commit 1c5e27e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Tasks/AzureFileCopyV4/AzureFileCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ try {
if([string]::IsNullOrEmpty($containerName) -or ($destination -ne "AzureBlob"))
{
$containerName = [guid]::NewGuid().ToString()
Write-Verbose "Creating temporary container for uploading files if no input is provided for container name"
Create-AzureContainer -containerName $containerName -storageContext $storageContext -isPremiumStorage $isPremiumStorage
}
else
Expand All @@ -126,8 +127,9 @@ try {
$containerPresent = Get-AzureContainer -containerName $containerName -storageContext $storageContext

#creating container if the containerName provided does not exist
if([string]::IsNullOrEmpty($containerPresent) )
if($containerPresent -eq $null)
{
Write-Verbose "Creating container if the containerName provided does not exist"
Create-AzureContainer -containerName $containerName -storageContext $storageContext -isPremiumStorage $isPremiumStorage
}
}
Expand Down
15 changes: 9 additions & 6 deletions Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ $AzureFileCopyRemoteJob = {
$shouldDownload = $true
}

$azCopyFolderName = "ADO_AzCopyV10"
$azCopyFolderPath = Join-Path -Path $env:systemdrive -ChildPath $azCopyFolderName

if($shouldDownload)
{
try
{
$azCopyFolderName = "ADO_AzCopyV10"
$azCopyFolderPath = Join-Path -Path $env:systemdrive -ChildPath $azCopyFolderName

New-Item -ItemType Directory -Force -Path $azCopyFolderPath
$azCopyZipPath = Join-Path -Path $azCopyFolderPath -ChildPath "AzCopy.zip"

Expand All @@ -74,7 +74,11 @@ $AzureFileCopyRemoteJob = {

$azCopyFolderEnvPath = Join-Path -Path $azCopyFolderPath -ChildPath "AzCopy"

#setting path at machine level so that when user again do copy on VM, there is no need to download the azcopy.exe again
[Environment]::SetEnvironmentVariable("Path", $azCopyFolderEnvPath + ';' + $env:Path, [System.EnvironmentVariableTarget]::Machine)

#setting $env:Path to include azcopy.exe path as the above command used to set path at machine level takes some time to update the path environment variable
$env:Path = $azCopyFolderEnvPath + ';' + $env:Path
}
catch
{
Expand All @@ -93,10 +97,9 @@ $AzureFileCopyRemoteJob = {
$additionalArguments = "--recursive --log-level=INFO"
}

$azCopyExeLocation = Join-Path -Path $azCopyFolderPath -ChildPath "AzCopy\AzCopy.exe"
Write-DetailLogs "##[command] & `"$azCopyExeLocation`" copy `"$containerURL*****`" `"$targetPath`" $additionalArguments"
Write-DetailLogs "##[command] & azcopy copy `"$containerURL*****`" `"$targetPath`" $additionalArguments"

$azCopyCommand = "& `"$azCopyExeLocation`" copy `"$containerURL/*$containerSasToken`" `"$targetPath`" $additionalArguments"
$azCopyCommand = "& azcopy copy `"$containerURL/*$containerSasToken`" `"$targetPath`" $additionalArguments"
Invoke-Expression $azCopyCommand
}
catch
Expand Down

0 comments on commit 1c5e27e

Please sign in to comment.