You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Azure DevOps实现Bitbucket仓库指定文件夹变更的自动化部署至Azure Web App

Alright, I’ve worked through similar scenarios before—let’s get this automated pipeline set up exactly how you need it. The key here is to narrow down the trigger to only the Theme folder in your DEV branch, and then deploy just that folder to your Azure Web App without touching anything else.

Step 1: Set Up Azure DevOps Project & Connect Your Bitbucket Repository

First, create a new project in Azure DevOps (or use an existing one). Then:

  • Go to Pipelines > Pipelines and click New pipeline
  • Select Bitbucket Cloud as your source (you’ll need to authenticate and grant access to your WPTheme repository)
  • Choose the DEV branch when prompted, then select Starter pipeline to generate a base YAML file—we’ll edit this next.
Step 2: Configure the Trigger to Only Watch the Theme Folder in DEV

We need to make sure the pipeline only runs when changes are made to the Theme folder in the DEV branch. Update the trigger section of your YAML like this:

trigger:
  branches:
    include:
      - DEV
  paths:
    include:
      - Theme/**  # Matches all files/subfolders inside Theme
    exclude:
      - '*'       # Excludes everything else to avoid false triggers
Step 3: Package Only the Theme Folder for Deployment

We don’t need to build the entire repo—just package the Theme folder into a zip artifact that we’ll deploy. Add these steps to your YAML:

steps:
  # Archive the Theme folder (without including the parent "Theme" folder in the zip)
  - task: ArchiveFiles@2
    inputs:
      rootFolderOrFile: 'Theme'
      includeRootFolder: false
      archiveType: 'zip'
      archiveFile: '$(Build.ArtifactStagingDirectory)/theme-deploy.zip'
      replaceExistingArchive: true

  # Publish the zip as a pipeline artifact
  - task: PublishBuildArtifacts@1
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)/theme-deploy.zip'
      ArtifactName: 'theme-artifact'
      publishLocation: 'Container'

The includeRootFolder: false ensures that when we deploy, the files go directly into the target Theme folder in your Web App (instead of creating an extra nested folder).

Step 4: Deploy the Theme Folder to Azure Web App

Now we’ll deploy the packaged zip directly to the Theme folder in your Web App. Add this final step (replace the placeholder values with your actual Azure resources):

# Deploy to Azure Web App, targeting the existing Theme folder
  - task: AzureWebApp@1
    inputs:
      azureSubscription: '<Your Azure Service Connection Name>'
      appType: 'webApp'
      appName: '<Your Azure Web App Name>'
      package: '$(Pipeline.Workspace)/theme-artifact/theme-deploy.zip'
      deploymentMethod: 'zipDeploy'
      # Specify the exact target path in your Web App
      additionalArguments: '-dest-path "site/wwwroot/Theme"'
  • For Linux Web Apps, change the dest-path to /home/site/wwwroot/Theme
  • Make sure you’ve set up an Azure Service Connection in Azure DevOps (under Project Settings > Service connections) with permissions to deploy to your Web App.
Quick Validation Tips
  • Test the pipeline manually first: Go to your pipeline in Azure DevOps, click Run pipeline, select DEV, and verify it packages and deploys correctly.
  • Make a small change to a CSS/JS file in the Theme folder of your Bitbucket DEV branch—this should automatically trigger the pipeline and update the Web App’s Theme folder.

内容的提问来源于stack exchange,提问作者Saad Zulfiqar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 07:32:48