【问题标题】:Release from Azure DevOps to Azure App Service: "You do not have permission to view this directory or page"从 Azure DevOps 发布到 Azure App Service:“您无权查看此目录或页面”
【发布时间】:2021-01-25 11:20:41
【问题描述】:

我看到很多关于这个问题的帖子。我想创建从 Azure DevOps 到 Azure App Service 的管道。

在 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>

我哪里做错了?

【问题讨论】:

  • 嗨@Enrico。这张票有更新吗?如果答案可以给你一些帮助,请随时告诉我。只是提醒this

标签: azure azure-devops azure-web-app-service


【解决方案1】:

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

从截图来看,文件已经成功上传到site/wwwroot路径。

您需要检查您的应用程序设置的Path mappings。然后在Virtual applications and directories 部分,您需要将Physical path 更改为site/wwwroot/appname

您可以在the Blog获得更详细的步骤。

如果上面没有解决。您可以执行以下步骤来显示更多错误消息并解决问题。

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

查看this thread了解详情。

对于 Visual Studio 中的错误

您可以参考this ticket

删除应用设置“WEBSITE_RUN_FROM_PACKAGE”,它会让你重新部署。

【讨论】:

    【解决方案2】:

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

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

    部署方法:zipDeploy/msDeploy

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

    Run from package reference

    Dev Ops deployment type Reference

    【讨论】:

    • 感谢您的评论。我按照我发布的脚本/程序为项目创建了很多管道和版本,并且它一直在工作。我不明白问题出在哪里。
    • 您的应用是否将此应用设置设为 1? WEBSITE_RUN_FROM_PACKAGE
    猜你喜欢
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-02
    • 2021-01-29
    • 1970-01-01
    相关资源
    最近更新 更多