使用 Release Pipeline 将 .NET Core 3.0 API 部署到 Azure Web App [英] Deploying .NET Core 3.0 API to Azure Web App using Release Pipeline

查看:24
本文介绍了使用 Release Pipeline 将 .NET Core 3.0 API 部署到 Azure Web App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm attempting to upgrade my API from .NET Core 2.2 to 3.0, but I cannot get the Azure Web App to actually run the application using 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.一切正常运行

I then have a multi-stage release pipeline that publishes the artifact to Azure using the Azure App Service Deploy Task. Everything runs without issue

我已经按照指示安装了预览版扩展此处,并运行 powershell 命令 Test-Path D:homeSiteExtensionsAspNetCoreRuntime.3.0.x86 返回 true.尽管如此,我仍然看到以下错误.

I've installed the preview extension, as directed here, and running the powershell command Test-Path D:homeSiteExtensionsAspNetCoreRuntime.3.0.x86 returns true. I'm still seeing the following error though.

ANCM 未能找到本地依赖

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

Back in Powershell, running dotnet --version and dotnet --list-runtimes shows that it only recognizes .NET Core 2 runtimes, despite the 3.0 runtime being present. As best I can tell, installing the site extension doesn't update the path to use the new dotnet version, and the Azure Devops deploy task doesn't seem to have any options to override the default. Has anyone managed to get a .NET Core 3 app deployed through Azure Devops Release Pipelines?

推荐答案

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

I don't consider it a good solution by any means, but the workaround I'm using right now that is working is to add a web.config file that passes the full path to the site extension version of 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:homeSiteExtensionsAspNetCoreRuntime.3.0.x86dotnet" arguments=".Api.dll" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

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

I'm still looking for a solution that isn't so error prone.

这篇关于使用 Release Pipeline 将 .NET Core 3.0 API 部署到 Azure Web App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆