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

3
我正在尝试将我的API从.NET Core 2.2升级到3.0,但是我无法让Azure Web应用程序使用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 App Service Deploy 任务将制品发布到 Azure。一切都正常运行。
我已按照 此处 的指示安装了预览扩展,并运行 PowerShell 命令 Test-Path D:\home\SiteExtensions\AspNetCoreRuntime.3.0.x86\ 返回 true。但我仍然看到以下错误。 ANCM 无法找到本机依赖项
在 Powershell 中运行 dotnet --versiondotnet --list-runtimes 命令,发现它只识别 .NET Core 2 运行时,尽管 3.0 运行时已经存在。据我所知,安装站点扩展并不会更新路径以使用新的 dotnet 版本,而 Azure Devops 部署任务似乎没有任何选项可以覆盖默认设置。有人成功通过 Azure Devops 发布流程部署 .NET Core 3 应用程序吗?

2
我怀疑Azure App服务是否已经支持.Net Core 3.0。https://stackoverflow.com/questions/58133089/azure-functions-stopped-working-after-core-3-0-update - Venkata Dorisala
1个回答

0

我并不认为这是一个好的解决方案,但目前我正在使用的解决方法是添加一个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>

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


太好了!感谢您在这里分享您的解决方案,您可以将其接受为答案,这样可以帮助其他遇到相同问题的社区成员,并且我们可以归档此线程,谢谢。 - Hugh Lin
@HughLin-MSFT 但这只是一个权宜之计,微软声称支持3.0版本的工作。 - Dan Friedman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接