Search code examples
azure-devopsyamlcontinuous-integrationazure-pipelinesazure-synapse

Deploy to another workspace in synapse with CI/CD


Currently I am able to deploy to Synapse via the Azure DevOps portal pipeline that I made with the UI. I am trying to achieve the same result via a yml file but I am encountering the problem [error]Encountered with exception:Error: No file found with this pattern and I have the following code:

trigger:
  branches:
    include:
        - workspace_publish

pool:
  name: Azure Pipelines

stages:
    - stage: Build
      displayName: Build stage
jobs:

    - job: Deploying

steps:
- task: CopyFiles@2
  displayName: 'Copy ARM Template Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: testsaws
    Contents: '*json'
    archiveFile: '$(Build.ArtifactStagingDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'


- task: PublishPipelineArtifact@1
  displayName: 'Publish Pipeline Artifact'
  inputs:
    #PathtoPublish: ./testsaws
    targetPath: '$(Build.ArtifactStagingDirectory)'
    artifact: 'ASA_Drop'
  
- task: AzureSynapseWorkspace.synapsecicd-deploy.synapse-deploy.Synapse workspace deployment@1
  displayName: 'Synapse deployment task for workspace: qasaws'
  inputs:
    azureSubscription: 'dataplatform-qa-group-SPN'
    subscriptionId: 'XXX'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'dataplatform-qa-group'
    location: 'West US 2'
    TemplateFile: '$(Build.ArtifactStagingDirectory)/ASA_Drop/ARM/TemplateForWorkspace.json'
    ParametersFile: '$(Build.ArtifactStagingDirectory)/ASA_Drop/ARM/TemplateParametersForWorkspaceQA.json' 
    

Any help or suggestion in finding the problem is welcome and appreciated.


Solution

  • When in doubt, print out the contents. I used the following command to print out the content of the current working directory and found out the artifact didn't contain any file.

    # PowerShell
    # Run a PowerShell script on Linux, macOS, or Windows
    - task: PowerShell@2
      inputs:
        #targetType: 'filePath' # Optional. Options: filePath, inline
        #filePath: # Required when targetType == FilePath
        #arguments: # Optional
        #script: '# Write your PowerShell commands here.Write-Host Hello World' 
        # Required when targetType == Inline
        #errorActionPreference: 'stop' # Optional. Options: default, stop, continue, silentlyContinue
        #warningPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
        #informationPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
        #verbosePreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
        #debugPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
        #failOnStderr: false # Optional
        #ignoreLASTEXITCODE: false # Optional
        #pwsh: false # Optional
        #workingDirectory: # Optional
    

    Then I changed the following in the yaml file:

    - task: PublishPipelineArtifact@1
      displayName: 'Publish Pipeline Artifact'
      inputs:
        #PathtoPublish: ./testsaws
        targetPath: '$(Build.ArtifactStagingDirectory)'
        artifact: 'ASA_Drop'
    
    - task: AzureSynapseWorkspace.synapsecicd-deploy.synapse-deploy.Synapse workspace deployment@1
      displayName: 'Synapse deployment task for workspace: qasaws'
      inputs:
        azureSubscription: 'qa-group-SPN'
        subscriptionId: 'XXX'
        action: 'Create Or Update Resource Group'
        resourceGroupName: 'qa-group'
        location: 'West US 2'
        TemplateFile: 'testsaws/TemplateForWorkspace.json'
        ParametersFile: 'testsaws/TemplateParametersForWorkspaceQA.json'