azure - 我应该将 AzureWebApp 任务指向什么路径?

标签 azure azure-devops azure-pipelines

我正在尝试部署一个 react 网络应用程序。这是我当前的 yaml 文件。我一直在关注this教程。

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'
  
variables:
  azureSubscription: <myServiceConnection>
  appName: <myAppName>

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'
  
  #so this calls the build object in package.json. Theoretically creates a /build/ directory
- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

#this should copy contents of build into artifactstagingdirectory. 
- task: CopyFiles@2
  inputs:
    Contents: 'build/**' # Pull the build directory (React)
    TargetFolder: '$(Build.ArtifactStagingDirectory)' 

- task: PublishBuildArtifacts@1
  inputs: 
    pathtoPublish: $(Build.ArtifactStagingDirectory) # dist or build files
    ArtifactName: 'www' # output artifact named www


- task: AzureWebApp@1
  inputs:
    azureSubscription: <myServiceConnection>
    appName: <myAppName>
    appType: webAppLinux
    package: $(Build.ArtifactStagingDirectory)/**/www/build
    customWebConfig: '-handler iisnode -NodeStartFile server.js -appType node'

基本上,问题是我不明白 PublishBuildArtifact 任务在哪里发布文件,因此我不知道将 AzureWebApp 的包指向哪里。

所以我打开了system.debug,并得到了以下信息

  1. npm install build 使用以下目录:/home/vsts/work/1/s
  2. 复制文件复制构建文件夹。因此,它会从 /home/vsts/work/1/s/build 转到 /home/vsts/work/1/a/build。所以这意味着artifactstagingdirectory是/home/vsts/work/1/a
  3. 发布构建工件采用artifactstagingdirectory并将其发布到某个文件夹www/build。提供以下输出:将 '/home/vsts/work/1/a' 上传到文件容器:'#/8995596/www'
  4. 当前的 AzureWebApp 任务正在 /home/vsts/work/1/a/**/www/build 中查找

所以我认为它应该是正确的目录。但是,它没有在步骤 3 中提供完整路径。所以看起来我错了。这个 www 文件夹是在哪里创建的?

此外,由于构建/发布 React 应用程序似乎不会创建 zip 文件,我是否只需将其指向构建文件夹或 www 文件夹?

最佳答案

尝试一下 **/wwwroot/ 而不是 **/www/

查看 Microsoft 的以下博客,其中概述了部署详细信息。

https://learn.microsoft.com/en-us/azure/app-service/faq-deployment

关于azure - 我应该将 AzureWebApp 任务指向什么路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63201301/

相关文章:

azure - Microsoft Graph OData 查询参数 $expand 似乎不起作用

Azure 开发运营 : How to set the value of the Variable in Variable Group

ios - Visual Studio 需要凭据才能在 Mac 上访问 pkgs.dev.azure.com

构建 Docker 镜像时的 Azure Pipeline "Permission denied"

amazon-web-services - 从 Azure Devops Pipeline 上传到 AWS s3 存储桶

c# - 如何获取Azure存储队列大小/位置

azure - 使用 Azure 逻辑应用将 CSV 转换为 JSON

c# - 从 HTML 网页 (C#) 将文件上传到 Azure Blob?

Azure DevOps Pipeline Build - 注册 COM DLL

azure - 如何手动触发 Azure Pipelines 中的单个作业?