Azure DevOps pipeline: Azure Copy Files step V4 error - can't find the specified folder


I am tying to deploy static version of storybook to Azure Cloud Storage blob container using Azure DevOps pipeline.

Since the image is sometimes more descriptive: what is the absolute path

The SourcePath (or Source in image above) needs to be an absolute path to file/folder you want to copy to blob. I referred to: and various other sources. No matter what predefined variable I try to use, I always see the same error:

failed to perform copy command due to error: cannot start job due to error: cannot scan the path \\?\D:\a\1\dist-storybook, please verify that it is a valid.

And this is what I tried so far:

  - task: AzureFileCopy@4
#      SourcePath: '$(Build.Repository.LocalPath)/dist-storybook'
#      SourcePath: '$(Build.SourcesDirectory)/dist-storybook'
      SourcePath: '$(Agent.BuildDirectory)/dist-storybook'
#      SourcePath: '$(System.DefaultWorkingDirectory)/dist-storybook'
      azureSubscription: 'xxx'
      Destination: 'AzureBlob'
      storage: 'xxx'
      ContainerName: 'storybook'

Before you go with the comments to check if dist-storybook folder exists and whether I verified.

Yes it exists. Before I tried Azure File Copy v4 task I was using AzureRmWebAppDeployment task with this param: packageForLinux: '$(System.DefaultWorkingDirectory)/dist-storybook' (which deploys to Azure App Service [but in case of Storybook it's an overkill, because generated Storybook consists of static files and doesn't require the server to run]) and it was deploying Storybook successfully. So the dist-storybook is properly generated in previous step in the pipeline.

Anyone has any clues?


After receiving some help on Microsoft Developer Forum:

I started using v3 (AzureFileCopy@3) of the task with the $(Build.Repository.LocalPath) predefined system variable (which I already used unsuccessfully with v4 [AzureFileCopy@4])

This is the full task:

  - task: AzureFileCopy@3
      SourcePath: '$(Build.Repository.LocalPath)/dist-storybook/*'
      azureSubscription: 'xxx'
      Destination: 'AzureBlob'
      storage: 'xxx'
      ContainerName: 'storybook'

Now I get this error:

2020-09-30T09:19:03.1646485Z ##[section]Starting: AzureFileCopy
2020-09-30T09:19:03.1870156Z ==============================================================================
2020-09-30T09:19:03.1871285Z Task         : Azure file copy
2020-09-30T09:19:03.1872336Z Description  : Copy files to Azure Blob Storage or virtual machines
2020-09-30T09:19:03.1873312Z Version      : 3.175.2
2020-09-30T09:19:03.1874422Z Author       : Microsoft Corporation
2020-09-30T09:19:03.1876194Z Help         :
2020-09-30T09:19:03.1877411Z ==============================================================================
2020-09-30T09:19:06.0053519Z ##[command]Import-Module -Name C:\modules\azurerm_6.13.1\AzureRM\6.13.1\AzureRM.psd1 -Global
2020-09-30T09:19:29.9367823Z ##[command]Clear-AzureRmContext -Scope Process
2020-09-30T09:19:31.1812482Z ##[command]Clear-AzureRmContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
2020-09-30T09:19:32.3448727Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
2020-09-30T09:19:34.2134374Z ##[command] Set-AzureRmContext -SubscriptionId 5a6f9ac1-3fc5-4ecc-9909-7c1f7be55b1f -TenantId ***
2020-09-30T09:19:41.8630229Z Uploading files from source path: 'D:\a\1\s\dist-storybook\*' to storage account: 'stdesignsystemdevuksouth' in container: 'storybook' with blob prefix: ''
2020-09-30T09:19:41.9074144Z ##[command] & "AzCopy\AzCopy.exe" /Source:"D:\a\1\s\dist-storybook\*" /Dest:"" /@:"D:\a\_temp\9a9dd952-202a-4851-91ed-e27a062f8f4a" /XO /Y /SetContentType /Z:"AzCopy" /V:"AzCopy\AzCopyVerbose_a1f6be33-1856-4036-98e1-d6c9c5a151af.log" /S
2020-09-30T09:19:42.8784330Z [2020/09/30 09:19:42][ERROR] Error parsing source location "D:\a\1\s\dist-storybook\*": Failed to enumerate directory D:\a\1\s\dist-storybook\*\ with file pattern *. The system cannot find the path specified. (Exception from HRESULT: 0x80070003) For more details, please type "AzCopy /?:Source" or use verbose option /V.
2020-09-30T09:19:43.1065203Z ##[command]Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
2020-09-30T09:19:43.9220995Z ##[command]Clear-AzureRmContext -Scope Process -ErrorAction Stop
2020-09-30T09:19:44.4426511Z ##[error]Upload to container: 'storybook' in storage account: 'stdesignsystemdevuksouth' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to
2020-09-30T09:19:44.5187191Z ##[section]Finishing: AzureFileCopy
asked on Stack Overflow Sep 29, 2020 by codeepic • edited Oct 1, 2020 by codeepic

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0