azure - 从 Azure DevOps 发布到 Azure 应用服务 : "You do not have permission to view this directory or page"

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

我看到很多关于这个问题的帖子。我想创建从 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()

enter image description here

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

enter image description here

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

enter image description here

然后,我检查 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>

我哪里做错了?

最佳答案

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#prerequisites-for-the-task

Run from package reference

Dev Ops deployment type Reference

关于azure - 从 Azure DevOps 发布到 Azure 应用服务 : "You do not have permission to view this directory or page",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64295928/

相关文章:

c++ - 带有 c++ dll 的 azure webapp 无法正常工作

Azure 持久实体还是静态变量?

python - 如何通过Azure函数将csv文件上传到Azure blob存储?

azure - 在 Azure 应用服务部署任务中设置 XML 转换环境

azure - 为什么在我的发布管道中自动创建发布注释?

azure-web-app-service - NopCommerce 部署决策

python - azure-storage-python - 使用 create_blob_from_path 进行异常处理

azure - 发布到 Azure 失败,出现 "Unrecognized link extension ' contentLibExtension'"错误

powershell - "PowerShell on Target Machines"任务因 TFS 2017\Azure Dev Ops 中的错误而失败

azure - 在 azure 管道上拉取并运行 Linux docker 镜像