Configuring change control using the Azure Invoke REST API

  • Release version: Washingtondc
  • Updated August 1, 2024
  • 1 minute to read
  • You can use the Azure Invoke REST API in your YAML or Classic Azure pipeline to configure change control for DevOps.

    You must enable the This property decides whether to create a Generic Connection on configure operation for Azure DevOps property to use Invoke REST API.

    For Azure Invoke REST API details, visit the Microsoft documentation site and search for Invoke HTTP REST API task- Azure Pipelines.

    Important:

    If you have duplicate or reused job names in your pipeline execution steps, ensure that the stageName attribute contains azurestageName/jobName in it’s value, i.e. stageName = azureStageName/jobName. The artifact registration tasks send both stage and job names to associate the artifact version to the correct task execution.

    Generic service connection

    Using the Azure Invoke REST API requires the creation of a generic service connection in Azure DevOps.

    Azure YAML REST API change control connection

    YAML Azure pipeline

    In Azure DevOps, a server task must be created with the service connection as the change control endpoint.

    Table 1. Invoke REST API payload requirements
    Azure pipeline type Values
    Build
    • buildNumber
    • isMultiBranch
    • branchName
    Release
    • releaseNumber
    • projectName
    Note:
    For release pipelines, set the Pre-deployment conditions > Advanced > Completion event field to Callback.
    Build pipeline:
    
    - task: InvokeRESTAPI@1
          inputs:
            connectionType: 'connectedServiceName'
            serviceConnection: 'change1'
            method: 'POST'
            body: |
             {
                "buildNumber": "$(build.buildId)",
                "isMultiBranch": "true",
                "branchName": "$(build.sourceBranchName)"
             }
            waitForCompletion: 'true'
    Release pipeline:
    
    - task: InvokeRESTAPI@1
          inputs:
            connectionType: 'connectedServiceName'
            serviceConnection: 'change1'
            method: 'POST'
            body: |
             {
                "releaseNumber": "$(Release.ReleaseId)",
                "projectName": "$(System.TeamProject)"
             }
            waitForCompletion: 'true'

    Classic Azure pipeline

    For a Classic Azure pipeline, an Invoke REST API server task must be added.

    Figure 1. Classic Azure build pipeline example
    Azure Pipeline Invoke REST API change control
    Figure 2. Classic Azure release pipeline example
    DevOps Azure classic release pipeline