azure-pipelines-tasks: Azure File Copy Task Fails with Azure PS Version 1.4.0

When a build agent has Azure PS Cmdlets version 1.4.0 installed the Azure File Copy Task will fail with the following error:

Cannot bind argument to parameter 'storageKey' because it is an empty string.

The previous version of Azure PS Cmdlets 1.3.2 works fine.


Raw Task Logs with Azure PS 1.4.0

2016-05-08T06:24:48.9801943Z Executing the powershell script: C:\Agent\tasks\AzureFileCopy\1.0.52\AzureFileCopy.ps1
2016-05-08T06:24:49.1676994Z Looking for Azure PowerShell module at C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1
2016-05-08T06:24:49.9958542Z AzurePSCmdletsVersion= 1.4.0
2016-05-08T06:24:50.0583559Z Get-ServiceEndpoint -Name ******** -Context Microsoft.TeamFoundation.DistributedTask.Agent.Worker.Common.TaskContext
2016-05-08T06:24:50.0739805Z tenantId= ********
2016-05-08T06:24:50.0739805Z azureSubscriptionId= ********
2016-05-08T06:24:50.0739805Z azureSubscriptionName= ********
2016-05-08T06:24:50.2146097Z Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential
2016-05-08T06:24:50.7982308Z Select-AzureRMSubscription -SubscriptionId ******** -tenantId ********
2016-05-08T06:24:51.0235517Z ##[debug]Loading AzureUtilityGTE1.1.0.ps1
2016-05-08T06:24:57.3994077Z ##[error]Cannot bind argument to parameter 'storageKey' because it is an empty string.

Raw Task Logs with Azure PS 1.3.2

2016-05-08T06:56:10.0177511Z Executing the powershell script: C:\Agent\tasks\AzureFileCopy\1.0.52\AzureFileCopy.ps1
2016-05-08T06:56:10.2052547Z Looking for Azure PowerShell module at C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1
2016-05-08T06:56:11.0646512Z AzurePSCmdletsVersion= 1.3.2
2016-05-08T06:56:11.1271528Z Get-ServiceEndpoint -Name ******** -Context Microsoft.TeamFoundation.DistributedTask.Agent.Worker.Common.TaskContext
2016-05-08T06:56:11.1427777Z tenantId= ********
2016-05-08T06:56:11.1427777Z azureSubscriptionId= ********
2016-05-08T06:56:11.1427777Z azureSubscriptionName= ********
2016-05-08T06:56:11.2834062Z Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential
2016-05-08T06:56:11.7897892Z Select-AzureRMSubscription -SubscriptionId ******** -tenantId ********
2016-05-08T06:56:11.9616688Z ##[debug]Loading AzureUtilityGTE1.1.0.ps1
2016-05-08T06:56:14.5176791Z Uploading files from source path: 'D:\Agent\Work\326ad65b5\********.Backend.CI\Backend\artifacts\package.zip' to storage account: '********' in container: '********' with blobprefix: 'deployments/********'
2016-05-08T06:56:16.7210196Z Uploaded files successfully from source path: 'D:\Agent\Work\326ad65b5\********.Backend.CI\Backend\artifacts\package.zip' to storage account: '********' in container: '********' with blobprefix: 'deployments/********'

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

While waiting for the fix, we’ve manually patched AzureFileCopy\1.0.54\AzureUtilityGTE1.0.ps1 as follows:

function Get-AzureStorageKeyFromARM
{
    param([string]$storageAccountName)

    if (-not [string]::IsNullOrEmpty($storageAccountName))
    {
        # get azure storage account resource group name
        $azureResourceGroupName = Get-AzureStorageAccountResourceGroupName -storageAccountName $storageAccountName

        Write-Verbose "[Azure Call]Retrieving storage key for the storage account: $storageAccount in resource group: $azureResourceGroupName"
        $storageKeyDetails = Get-AzureRMStorageAccountKey -ResourceGroupName $azureResourceGroupName -Name $storageAccountName -ErrorAction Stop
        $storageKey = $storageKeyDetails[0].Value
        Write-Verbose "[Azure Call]Retrieved storage key successfully for the storage account: $storageAccount in resource group: $azureResourceGroupName"

        return $storageKey
    }
}

The line:

        $storageKey = $storageKeyDetails[0].Value

is what has been changed.

I also have this issue now with 1.0.69. Surely this shouldn’t be closed…

@soccerjoshj07 , Closing the issue as the new Azure File Copy V3 should fix this issue.

@vincentdass This shouldn’t be closed - still an issue in Azure DevOps pipelines as @mkusmiy alluded to.

A fix that worked for me is by modifying line 27 of AzureUtilityGTE1.0.ps1 (@mkusmiy , you had a small typo in your snippet above, missing the “_” in $.ResourceType and $.Name)

from $azureStorageAccountResourceDetails = (Get-AzureRMResource -ErrorAction Stop) | Where-Object { ($_.ResourceType -eq $ARMStorageAccountResourceType) -and ($_.ResourceName -eq $storageAccountName)}

to $azureStorageAccountResourceDetails = (Get-AzureRMResource -ErrorAction Stop) | Where-Object { ($_.ResourceType -eq $ARMStorageAccountResourceType) -and ($_.Name -eq $storageAccountName)}

Edit: V2 of the task (in preview) also worked.

@stack111 , It’s currently in progress. Will be updating the status soon.

I got this problem again, now with the task version 1.0.69 @kmkumaran Any plans to have this fixed?

We have the sing-off planned sometime next sprint. I will post back to this thread once we have it ready.