azure - Azure 静态网站构建管道 -> Blob 上传
问题描述
我有一个在 azure 中托管的 vue spa 应用程序。但是,在 Azure DevOps 中设置它后,我无法让它作为构建管道运行
npm install 和 npm run build 完美运行,但是,将我的 dist 目录复制到我的 blob 存储的脚本失败。
这是我尝试的方法和结果。有人对此有经验吗?
AzureFileCopy
- task: AzureFileCopy@3
inputs:
SourcePath: '$(System.DefaultWorkingDirectory)/dist'
azureSubscription: '[my subscription details]'
Destination: 'AzureBlob'
storage: 'mystorageaccountname'
ContainerName: '$web'
结果
##[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
解决方案
感谢建议我运行“目录”的评论。它实际上没有用。经过检查,以下命令甚至没有构建应用程序。
- script: |
npm install
npm run build
dir
displayName: 'npm install and build'
我认为这是因为我将代理更改为在 Windows 上运行(我之前发现 AzureFileCopy 仅在 Windows 上运行)并且 Windows 代理不允许像 ubuntu 代理那样堆叠脚本。所以我将安装和构建拆分为单独的任务,现在它只运行动词警告。这是工作脚本:
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'
推荐阅读
- javascript - 同名函数但基于条件执行
- python - 在矩形列表中移动单个矩形pygame
- python - 如何根据数据框的长度从 groupby 对象创建文件
- python - Instagram API - 如何获取我在我的帐户上关注的人的简历?
- python - 如何更改为python中以下代码的列表理解
- reactjs - 尝试部署我的 Gatsby 站点时收到“props.children 不是函数”错误
- spring - 如何避免在 Sping Reactor 中对类似订阅者重复映射操作?
- python - 设置背景颜色和背景图像
- python - anaconda 环境中的 pip vs conda
- python - 如何在按钮按下tkinter时从文本框中检索输入