gpt4 book ai didi

c# - Azure 应用服务 Linux Web 应用 : It was not possible to find any installed . NET Core SDK

转载 作者:行者123 更新时间:2023-12-03 00:56:15 30 4
gpt4 key购买 nike

我尝试在 Azure 应用服务 (Linux) 上发布一个小型 .NET Core 3.1 Web 应用,但该应用无法启动。

无论我是使用 Visual Studio 还是 Azure DevOps 进行发布,我的 Linux Azure 应用服务(顺便说一下,它已经包含另外两个应用)都会出现以下错误:

2021-06-23T22:19:47.102376527Z   _____
2021-06-23T22:19:47.102415627Z / _ \ __________ _________ ____
2021-06-23T22:19:47.102422327Z / /_\ \___ / | \_ __ \_/ __ \
2021-06-23T22:19:47.102426627Z / | \/ /| | /| | \/\ ___/
2021-06-23T22:19:47.102430627Z \____|__ /_____ \____/ |__| \___ >
2021-06-23T22:19:47.102434927Z \/ \/ \/
2021-06-23T22:19:47.102438927Z A P P S E R V I C E O N L I N U X
2021-06-23T22:19:47.102442827Z
2021-06-23T22:19:47.102446327Z Documentation: http://aka.ms/webapp-linux
2021-06-23T22:19:47.102449927Z Dotnet quickstart: https://aka.ms/dotnet-qs
2021-06-23T22:19:47.102453427Z ASP .NETCore Version: 3.1.13
2021-06-23T22:19:47.102457227Z Note: Any data outside '/home' is not persisted
2021-06-23T22:19:47.307988432Z Running oryx create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand 'dotnet WebApplication1.dll'
2021-06-23T22:19:47.378242802Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2021-06-23T22:19:47.382799606Z Could not find operation ID in manifest. Generating an operation id...
2021-06-23T22:19:47.382816206Z Build Operation ID: 7f48597c-0791-46e5-bffd-b0007d8b27b7
2021-06-23T22:19:49.335414280Z Writing output script to '/opt/startup/startup.sh'
2021-06-23T22:19:49.567879341Z Running user provided startup command...
2021-06-23T22:19:49.610748271Z A compatible installed .NET Core SDK for global.json version [3.1.409] from [/home/site/wwwroot/global.json] was not found
2021-06-23T22:19:49.610783071Z Install the [3.1.409] .NET Core SDK or update [/home/site/wwwroot/global.json] with an installed .NET Core SDK:
2021-06-23T22:19:49.610825071Z It was not possible to find any installed .NET Core SDKs
2021-06-23T22:19:49.610829471Z Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
2021-06-23T22:19:49.610835971Z https://aka.ms/dotnet-download
2021-06-23T22:19:50.944Z ERROR - Container procoding-me_0_8935305e for site procoding-me has exited, failing site start
2021-06-23T22:19:50.961Z ERROR - Container procoding-me_0_8935305e didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2021-06-23T22:19:50.978Z INFO - Stopping site procoding-me because it failed during startup.```

我尝试再次在azure上创建Web应用程序,甚至尝试发布其他应用程序的相同代码,但出现了相同的问题。

有人知道这个问题的原因吗?

最佳答案

因此,经过一整天的尝试解决这个问题,我成功地将应用程序发布到运行 Linux 的应用程序服务。我正在使用位于“共享”资源组中的应用程序服务计划(Linux、B1),因为我想在其上运行多个应用程序。我还使用 Bicep 部署基础设施,管道是 yaml。

问题似乎是,当我通过 Azure DevOps 部署应用程序时,它会将应用程序存档嵌套在另一个 zip 文件中。应用程序 zip 文件需要是应用程序中的根文件夹,除非您下载在应用程序服务本身中执行的文件,否则这一点并不明显。

是的,我也在这里使用独立的部署版本。您可以阅读更多相关信息here 。除非我从 Visual Studio 2022 发布应用程序,否则我没有成功地使用依赖于框架的方式完成此操作。

所以,最后,以下是让这件事对我有用的片段:

azure-pipelines.yaml - 构建阶段

- task: DotNetCoreCLI@2
inputs:
command: 'publish'
projects: '**/*Api.csproj'
arguments: '--configuration $(buildConfiguration) -r linux-x64 --self-contained true --output $(Build.ArtifactStagingDirectory)'
modifyOutputPath: false
publishWebProjects: false
zipAfterPublish: true
displayName: 'Dotnet Publish'

- task: PublishBuildArtifacts@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
ArtifactName: drop

azure-pipelines.yaml - 部署阶段

- task: AzureRmWebAppDeployment@4
inputs:
azureSubscription: '$(azureSubscription)'
appType: webAppLinux
WebAppName: '$(output_appServiceName)'
packageForLinux: '$(Pipeline.Workspace)/**/a.zip' #Since we are not specifying the folder name in the steps prior, the folder will be called just a.zip, this is fine since the deployment is going to rename it any way in the app service file system anyway(in Kudu)

Bicep 中的应用服务资源

 resource appService 'Microsoft.Web/sites@2021-01-01' = {
name: '${serviceName}-${environment}-app'
location: resourceGroup().location
kind: 'app'
properties: {
serverFarmId: planId

siteConfig: {
alwaysOn: true
http20Enabled: true
linuxFxVersion: 'DOTNETCORE|5.0'
appSettings: [
{
name: 'WEBSITE_RUN_FROM_PACKAGE'
value: '1'
}
]
}
}
}

希望这有帮助。

附注应用程序服务 (Kudu) 中的 zip 文件“损坏”可能会导致应用程序失败。我建议任何遇到此问题的人要么从 wwwroot 中删除所有文件,要么干脆删除应用服务资源并从头开始部署,以确保它可以正常启动。

关于c# - Azure 应用服务 Linux Web 应用 : It was not possible to find any installed . NET Core SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68107671/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com