首页 > 解决方案 > 部署时的 Azure DevOps 管道问题

问题描述

我是 Azure 的新手,我确信在 Azure 中配置管道和部署我的解决方案很容易......但我被困了 2 天,我没有找到最新的文章解释了完整的 CI/CD。

这是我的解决方案(基于 ABP 样板):

- solution folder
  - aspnet-core solution folder (API .NET Core 2.2)
  - angular (frontend part in Angular 8)

我有一个 Azure 帐户,并创建了两个应用服务:

对于这两种设置都是默认设置:

在 Azure DevOps 中,一切都是绿色的......

2条管道:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

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

- script: |
    cd angular
    npm install -g @angular/cli
    npm install
    ng build --prod
  displayName: 'npm install and build'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'angular/dist'
    TargetPath: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'UiApp'
    publishLocation: 'Container''
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    TargetPath: '$(Build.ArtifactStagingDirectory)'

对于发布部分:

它在 wwwroot 中创建了一个子文件夹 UIApp 但我不明白为什么

steps:
- task: AzureWebApp@1
  displayName: 'Azure Web App Deploy: XXXXX'
  inputs:
    azureSubscription: 'XXXXXXXX'
    appType: webApp
    appName: 'XXXXX'
    package: '_XXX - Angular'
  enabled: false

我尝试了 Azure Web App Deploy 和 Azure App Service Deploy。

我尝试使用 deploy Zip / Run from package / deploy Web ...但没有成功。

在 API 中,我看到它已创建:

在 /data/sitePackages/ 中包含日期时间的 zip 文件

在 /site/wwwroot/ 中也有 zip 文件,但名称不同(wwwroot 是只读的)

yaml:

steps:
- task: AzureWebApp@1
  displayName: 'Azure Web App Deploy: XXXXX'
  inputs:
    azureSubscription: 'XXXXXXXXXXX'
    appType: webApp
    appName: 'XXXXXX'
    package: '_XXXXX - API/drop'
    deploymentMethod: runFromPackage
  enabled: false

我不明白我错过了什么,使用完整的 azure 堆栈应该很容易......我应该在某个地方错过一个细节(或者我可能错过了一张大图和关于 Yaml 的培训)

我想阻止在 wwwroot 中为前端创建子文件夹 UiApp。

后端根本无法使用该软件包,我不知道如何修复或调试该问题。顺便说一句,我不需要从包中运行。我更喜欢 IIS 的“经典”方式

标签: c#azure.net-coreazure-devopsabp

解决方案


我终于让它正常工作了。

我现在为这两个应用程序使用 Azure App Service Deploy,但在“包或文件夹”中没有看到“...”按钮。

选择正确的工件文件(.Net 版本的 zip 文件和 Angular 应用程序的文件夹“drop”)后,我让文件同步成功。

下一步:更新实体框架核心的数据库并应用配置变量。


推荐阅读