从 Azure DevOps 发布到 Azure App Service:“您无权查看此目录或页面”

问题描述 投票:0回答:3

我看到很多关于这个问题的帖子。我想创建从 Azure DevOps 到 Azure 应用服务的管道。

在 DevOps 中,我创建了如下管道:

pool:
  name: Azure Pipelines
steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: |
     **/PowerBIDashboard.csproj
     **/PowerBIDashboard.Tests.csproj

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: test

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: '**/*.csproj'
    arguments: '-o publish_output'

- task: ArchiveFiles@2
  displayName: 'Archive Files'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
    includeRootFolder: false
    archiveFile: '$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip'
  condition: succeededOrFailed()

Release 中,我将工件部署到应用服务。在App Service的Kudu中,我可以看到所有文件。

我删除了应用服务并重新部署,结果相同。然后我尝试直接从 Visual Studio 部署,但出现另一个错误。

然后,我检查 Kudu 中的日志,并在 eventlog.xml 中发现了这些错误:

<Events>
    <Event>
        <System>
            <Provider Name="ZipFS"/>
            <EventID>0</EventID>
            <Level>1</Level>
            <Task>0</Task>
            <Keywords>Keywords</Keywords>
            <TimeCreated SystemTime="2020-10-10T16:24:34Z"/>
            <EventRecordID>-1126954890</EventRecordID>
            <Channel>Application</Channel>
            <Computer>RD281878C97A29</Computer>
            <Security/>
        </System>
        <EventData>
            <Data>Failed to open siteversion.txt. ZipFS setup failed. Error: 0x80070003</Data>
        </EventData>
    </Event>
    <Event>
        <System>
            <Provider Name="ZipFS"/>
            <EventID>0</EventID>
            <Level>1</Level>
            <Task>0</Task>
            <Keywords>Keywords</Keywords>
            <TimeCreated SystemTime="2020-10-10T16:24:34Z"/>
            <EventRecordID>-1126954875</EventRecordID>
            <Channel>Application</Channel>
            <Computer>RD281878C97A29</Computer>
            <Security/>
        </System>
        <EventData>
            <Data>Failed to copy zip from remote source.</Data>
        </EventData>
    </Event>
</Events>

我哪里做错了?

azure azure-devops azure-web-app-service
3个回答
0
投票

DevOps 的部署很可能使用名为“从包运行”的功能,该功能从 zip 文件运行应用程序并将 D:/home/site/wwwroot 目录置于只读模式。 DevOps 将根据应用程序类型尝试选择最佳部署方法。建议从包运行以避免文件锁定问题并确保文件正在运行。

如果您希望 DevOps 使用另一种方法,您需要使用 ZipDeploy,而不使用 Run From Package 或 Msdeploy。我没有在 DevOps 中广泛使用 YAML,但我认为你会想要在输入下执行类似的操作,具体取决于你选择 zipDeploy 还是 msDeploy。

部署方式:zipDeploy/msDeploy

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops#preconditions-for-the-task

从包参考运行

Dev Ops 部署类型参考


0
投票

对于 Azure 应用服务:“您无权查看此目录或页面”

从截图来看,文件已成功上传至

site/wwwroot
路径。

您需要检查应用程序设置的

Path mappings
。然后在
Virtual applications and directories
部分,您需要将
Physical path
更改为
site/wwwroot/appname

您可以在博客中获得更详细的步骤。

如果以上方法不起作用。您可以执行以下步骤来显示更多错误消息并解决问题。

  • 转至 Azure 中的 Web 应用程序 > 应用程序服务日志 > 打开详细错误消息。
  • 在Web配置文件中,在
    标签下添加
    <customErrors mode="Off" />,在
    标签下添加
    <httpErrors errorMode="Detailed"></httpErrors>。并将 web.config 文件更新到您的 azure web 应用程序。

查看此线程了解详细信息。

对于Visual Studio中的错误

您可以参考这张票

删除应用程序设置“WEBSITE_RUN_FROM_PACKAGE”即可重新部署。


0
投票

作为对未来的自己的提醒——因为这是我第二次花费太多时间来解决这个问题......

如果部署包是使用 linux-x64 运行时标识符构建的,但您尝试部署到 Windows 应用服务,您将收到此错误。

-r win-x64

© www.soinside.com 2019 - 2024. All rights reserved.