azure - 使用发布管道将.NET Core 3.0 API部署到Azure Web App

标签 azure .net-core azure-devops azure-web-app-service .net-core-3.0

我正在尝试将 API 从 .NET Core 2.2 升级到 3.0,但无法让 Azure Web App 使用 3.0 实际运行应用程序。

我的构建管道配置:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core 3'
  inputs:
    version: 3.x
- script: dotnet tool install --global dotnet-ef
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'
- task: efcore-migration-script-generator-task@0
  inputs:
    projectpath: 'Models/Models.csproj'
    databasecontexts: 'DataContext'
    startupprojectpath: 'Api/Api.csproj'
    targetfolder: '$(build.artifactstagingdirectory)/migrations'
- script: dotnet publish --output $(Build.ArtifactStagingDirectory)
  displayName: 'dotnet publish $(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

然后,我有一个多阶段发布管道,它使用 Azure 应用服务部署 任务将工件发布到 Azure。一切运行没有问题

我已按照指示安装了预览扩展 here ,并运行 powershell 命令 Test-Path D:\home\SiteExtensions\AspNetCoreRuntime.3.0.x86\ 返回 true。但我仍然看到以下错误。

ANCM Failed to Find Native Dependencies

返回 Powershell,运行 dotnet --versiondotnet --list-runtimes 显示它仅识别 .NET Core 2 运行时,尽管存在 3.0 运行时。据我所知,安装站点扩展不会更新使用新 dotnet 版本的路径,并且 Azure Devops 部署任务似乎没有任何选项来覆盖默认值。有人设法通过 Azure Devops 发布管道部署 .NET Core 3 应用程序吗?

最佳答案

无论如何,我都不认为这是一个好的解决方案,但我现在正在使用的解决方法是添加一个 web.config 文件,该文件将完整路径传递给dotnet

的站点扩展版本
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="D:\home\SiteExtensions\AspNetCoreRuntime.3.0.x86\dotnet" arguments=".\Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

我仍在寻找一种不太容易出错的解决方案。

关于azure - 使用发布管道将.NET Core 3.0 API部署到Azure Web App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58174691/

相关文章:

node.js - 尝试连接到 Azure 中的 API 但允许来源时出错

xml - 尝试通过 Azure AD B2C 自定义策略登录时,Discord api 返回 401 未经授权

c# - 在 .NET Core 中使用 System.IO.Enumeration 自定义目录枚举

testing - VSTS : Test Case Added from Work section not available in Test section

visual-studio - 对 PackageReference 使用GeneratePathProperty true 时,Azure Devops 构建失败

c# - Azure Pipeline 在 dotnet 构建中失败,需要升级到最新的 .net core 版本

regex - 如何在 Azure API 管理策略表达式中添加正则表达式验证

powershell - 删除项目与 [System.IO.File]::Delete()

c# - ASP.NET docker-compose 应用程序没有出现在分配的端口上

c# - 如何为 BackgroundService 的 ExecuteAsync 设置超时?