Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Blob if not there #12826

Merged
merged 7 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Tasks/AzureFileCopyV4/AzureFileCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,22 @@ try {
if([string]::IsNullOrEmpty($containerName) -or ($destination -ne "AzureBlob"))
{
$containerName = [guid]::NewGuid().ToString()
Create-AzureContainer -containerName $containerName -storageContext $storageContext -isPremiumStorage $isPremiumStorage
Write-Verbose "Container Name input not found. Creating Temporary container for uploading files."
Create-AzureContainer -containerName $containerName -storageContext $storageContext -isPremiumStorage $isPremiumStorage
}
else
{
#checking if the containerName provided exist or not
$containerPresent = Get-AzureContainer -containerName $containerName -storageContext $storageContext

#creating container if the containerName provided does not exist
if($containerPresent -eq $null)
{
Write-Verbose "Creating container if the containerName provided does not exist"
Create-AzureContainer -containerName $containerName -storageContext $storageContext -isPremiumStorage $isPremiumStorage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a debug log here.

}
}


# Getting Azure Blob Storage Endpoint
$blobStorageEndpoint = Get-blobStorageEndpoint -storageAccountName $storageAccount -endpoint $endpoint
Expand Down
5 changes: 5 additions & 0 deletions Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $AzureFileCopyRemoteJob = {
{
$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 @@ -73,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 at user level to include azcopy.exe path as the above command used do set the path at machine level and not at user level
$env:Path = $azCopyFolderEnvPath + ';' + $env:Path
}
catch
{
Expand Down
25 changes: 25 additions & 0 deletions Tasks/AzureFileCopyV4/AzureUtilityARM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@ function Create-AzureContainer
}
}

function Get-AzureContainer
{
param([string]$containerName,
[object]$storageContext)

$container = $null

if(-not [string]::IsNullOrEmpty($containerName) -and $storageContext)
{
$storageAccountName = $storageContext.StorageAccountName

Write-Verbose "[Azure Call]Getting container: $containerName in storage account: $storageAccountName"
try
{
$container = Get-AzureStorageContainer -Name $containerName -Context $storageContext -ErrorAction Stop
}
catch
{
Write-Verbose "Container: $containerName does not exist in storage account: $storageAccountName"
}
}

return $container
}

function Remove-AzureContainer
{
param([string]$containerName,
Expand Down
25 changes: 25 additions & 0 deletions Tasks/AzureFileCopyV4/AzureUtilityAz1.0.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ function Create-AzureContainer
}
}

function Get-AzureContainer
{
param([string]$containerName,
[object]$storageContext)

$container = $null

if(-not [string]::IsNullOrEmpty($containerName) -and $storageContext)
{
$storageAccountName = $storageContext.StorageAccountName

Write-Verbose "[Azure Call]Getting container: $containerName in storage account: $storageAccountName"
try
{
$container = Get-AzStorageContainer -Name $containerName -Context $storageContext -ErrorAction Stop
}
catch
{
Write-Verbose "Container: $containerName does not exist in storage account: $storageAccountName"
}
}

return $container
}

function Remove-AzureContainer
{
param([string]$containerName,
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 168,
"Patch": 3
"Minor": 170,
"Patch": 0
},
"preview": true,
"demands": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 168,
"Patch": 3
"Minor": 170,
"Patch": 0
},
"preview": true,
"demands": [
Expand Down