0

我正在构建一个新的基于 yaml 的构建过程,通过 terraform 进行配置,使用 Azure GIT 存储库。发布管道使用 yaml 文件(如下),我知道它的所有其余部分都有效,因为整个部署都有效,除了部署只是将 .zip 文件放到 site/wwwroot 目录中,而不是解压缩它。据我所知,这完全是关于文件最底部部署部分的最后两行。

此外,包和 zip 本身也很好,因为我能够通过 Azure CLI 在 VS Code 中手动部署代码并且它可以工作。

我是否需要其他东西来获得将 zip 内容解压缩到 wwwroot 目录的版本?

name: Deploy $(Date:yyyyMMdd)$(Rev:.r)  # build numbering format

trigger: none

resources:
  repositories:
  - repository: templates
    type: git
    name: repo/branch
    ref: refs/heads/main
  pipelines:
  - pipeline: build
    project: ADOProject
    source: buildpipelinename
    trigger:
      branches:
      - dev

variables:
- name: tier_prefix
  value: D
- name: env_identifier
  value: dev
- name: workstream
  value: liehadmin
- name: region_prefix
  value: C
- name: rgp_identifier
  value: OURRGP
- group: terraform (non-prod)

stages:
- stage: infrastructure # our terraform methods are called from here
  condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual', 'Schedule', 'ResourceTrigger'))
  displayName: UPDATE INFRASTRUCTURE
  jobs:
  - template: 'core/terraform.yaml@templates'
    parameters: 
      tier_prefix: $(tier_prefix)
      tf_key: $(workstream)-$(env_identifier)
      module_name: 'web_1tier1region_S'
      variable_file_path: "$(System.DefaultWorkingDirectory)/$(Build.Repository.Name)/pipelines/$(workstream)/$(workstream).$(env_identifier).tfvars.json"
- stage: deploy
  dependsOn: [infrastructure]
  displayName: DEPLOY APP
  jobs:
    # Track deployments on the environment.
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'windows-latest'
    # Creates an environment if it doesn't exist.
    environment: 'site-dev'
    strategy:
      # Default deployment strategy, more coming...
      runOnce:
        deploy:
          steps:
          - checkout: self 
          - bash: ls $BUILD_ARTIFACTSTAGINGDIRECTORY
          - bash: ls $PIPELINE_WORKSPACE
          - task: AzureRmWebAppDeployment@4
            displayName: 'deploy $(tier_prefix)-$(region_prefix)-$(workstream)-UI-01'
            inputs:
              ConnectionType: 'AzureRM'
              azureSubscription: 'subname'
              # SlotName: 'slot'
              appType: 'webApp'
              WebAppName: '$(tier_prefix)-$(region_prefix)-$(workstream)-UI-01'
              ResourceGroupName: '$(region_prefix)-Y-Z-$(rgp_identifier)-$(tier_prefix)-XXX-XX'
              # DeployToSlotOrASEFlag: true
              Package: '$(Pipeline.Workspace)/build/repo_name'
              enableCustomDeployment: true
              deploymentMethod: 'zipDeploy'
4

1 回答 1

0

我可能已经找到了解决方法:

UseWebDeploy: true
enableCustomDeployment: true
deploymentMethod: 'runFromPackage'

现在,如果您阅读Microsoft 文档,这很奇怪,因为它列出enableCustomDeployment了 的参数别名UseWebDeploy,但出于某种原因,两者都有效;我的代码部署到site/wwwroot.

于 2022-01-26T23:03:26.913 回答