Azure static web site build pipeline -> blob upload

2

I have a vue spa application that I host in azure. However, I am not able to get it running as a build pipeline after setting it up in Azure DevOps

The npm install and npm run build work perfectly, however, the script to copy my dist directory to my blob store fails.

Here is what I tried and the results. Does anyone have experience with this?

AzureFileCopy

- task: AzureFileCopy@3
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist'
    azureSubscription: '[my subscription details]'
    Destination: 'AzureBlob'
    storage: 'mystorageaccountname'
    ContainerName: '$web'

Result

##[section]Starting: AzureFileCopy
==============================================================================
Task         : Azure file copy
Description  : Copy files to Azure Blob Storage or virtual machines
Version      : 3.1.11
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
==============================================================================
##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM\2.1.0\AzureRM.psd1 -Global
##[warning]The names of some imported commands from the module 'AzureRM.Websites' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##[warning]The names of some imported commands from the module 'AzureRM' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM.Profile\2.1.0\AzureRM.Profile.psm1 -Global
##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -EnvironmentName AzureCloud
##[command] Set-AzureRmContext -SubscriptionId dc6a0ce7-adcd-49fd-ad85-e1c082994145 -TenantId ***
Uploading files from source path: 'D:\a\1\s\dist' to storage account: 'mystorageaccountname' in container: '$web' with blob prefix: ''
##[command] & "AzCopy\AzCopy.exe" /Source:"D:\a\1\s\dist" /Dest:"https://mystorageaccountname.blob.core.windows.net/`$web" /@:"D:\a\_temp\ead7e7cf-0b6e-4b16-928f-c84cf3e3a7ab" /XO /Y /SetContentType /Z:"AzCopy" /V:"AzCopy\AzCopyVerbose_ae491d97-a7a8-44e6-b7b0-4b932a5e6c08.log" /S
[2019/06/13 00:31:08][ERROR] Error parsing source location "D:\a\1\s\dist": Failed to enumerate directory D:\a\1\s\dist\ 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.
##[error]Upload to container: '$web' in storage account: 'mystorageaccountname' 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 https://aka.ms/azurefilecopyreadme
##[section]Finishing: AzureFileCopy
azure
azure-storage
azure-pipelines
asked on Stack Overflow Jun 12, 2019 by Ron Gilchrist • edited Jun 13, 2019 by Ron Gilchrist

1 Answer

4

Thanks to the comment suggesting I run a "dir". It actually didn't work. Upon inspection, the following command was not even building the app.

- script: |
    npm install
    npm run build
    dir
  displayName: 'npm install and build'

I presume this is because I changed the agent to run on windows (I discovered earlier that AzureFileCopy only runs on windows) and windows agent does not allow stacked scripts the way the ubuntu agent does. So I split the install and build into separate tasks and now it runs with only verb warnings. Here is the working script:

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- script: |
    npm run build
  displayName: 'npm run build'

- script: |
    dir
  displayName: 'list cwd contents (verify build)'

- task: AzureFileCopy@3
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist'
    azureSubscription: '[my subscription details]'
    Destination: 'AzureBlob'
    storage: 'mystorageaccountname'
    ContainerName: '$web'
answered on Stack Overflow Jun 13, 2019 by Ron Gilchrist

User contributions licensed under CC BY-SA 3.0