Configure continuous integration by using Azure Pipelines


Continuous Integration (CI) enables development teams to automatically build, test, and validate application changes whenever code is committed to a repository. In Azure environments, Azure Pipelines provides a robust CI service that integrates seamlessly with platforms like GitHub and Azure Repos. By configuring CI with Azure Pipelines, teams can automate the process of building container images, run tests, and securely pushing updated images to Azure Container Registry (ACR). This automated workflow ensures consistent deployments, reduces manual errors, and supports a scalable DevOps lifecycle for applications running on Azure Container Apps.

Configure Pipeline1 to use the self-hosted agent pool

  • Open a browser window, navigate to https://dev.azure.com, and then open your Azure DevOps organization.

  • On your Azure DevOps page, to open your DevOps project, select Project1.

  • In the left-side menu, select Pipelines.

  • Select Pipeline1, and then select Edit.
    6ftrd6uyu
    7ttfrd

  • To use the self-hosted agent pool, update the azure-pipelines.yml file as shown in the following example:

               trigger:
                - main
    
               pool:
               name: default
    
               steps:
    

Recall that the pool section specifies the agent pool to use for the pipeline. The name property specifies the name of the agent pool. In this case, the name is default, which is the pool you configured as a self-hosted agent pool.

fytkfyt66

  • Under Validate and save, select Save without validating.
  • Enter a commit message, and then select Save.
    I87uhgyt
    ht6dxzd

Configure Pipeline1 with an Azure Container Apps deployment task

Ensure that you have Pipeline1 open for editing.

  • On the right side under Tasks, in the Search tasks field, enter azure container
  • In the filtered list of tasks, select Azure Container Apps Deploy
  • Under Azure Resource Manager connection, select the Subscription you’re using, and then select Authorize.

87tfdrt
87trdtryy

  • In the Azure portal tab, open your Container App resource, and then open the Containers page.

Use the information on the Containers page to configure the following Pipeline1 Task information:

Docker Image to Deploy: Registry/Image:Image tag
Azure Container App name: Name

  • Configure the following Pipeline1 Task information:

Azure Resource group name: RG1

  • On the Azure Container Apps Deploy page, select Add.
    76ttr

uyt76rrrrr

The Yaml file for your pipeline should now include the AzureContainerApps tasks as follows:

                 trigger:
                   - main
                 pool:
                   name: default
                 steps:
                   - task: AzureContainerApps@1
                     inputs:
                       azureSubscription: '()'
                       imageToDeploy: '/:' from Container App resource
                       containerAppName: '' from Container App resource 
                       resourceGroup: ''
Enter fullscreen mode

Exit fullscreen mode

Select Validate and save, and then select Save again to commit directly to the main branch.

rtcewwd
4ctbeub

You most likely have an indentation error. Review and correct the indentation to resolve the issue.

The contents of the YAML file must be formatted correctly, including indentation. If you encounter an error, review the YAML file and correct any indentation issues.

Navigate back to the main page of your pipeline.

Run the Pipeline1 deployment task

Ensure that you have Pipeline1 open in Azure DevOps.

  • On the Runs tab of the Pipeline1 page, select Run pipeline.

  • A Run pipeline page opens to display the associated job.

  • Select Run.
    6tderdtrr

The Jobs section displays job status, which progresses from Queued to Waiting.

It can take a couple minutes for the status to transition from Queued to Waiting.

  • If a ‘Permission needed’ message is displayed (“This pipeline needs permission to access 2 resources before this run can continue”), select View and then provide the required permissions.

6frdrtfft
ftrrd55
Monitor the status of the run operation and verify that the run is successful.
r6rdduy

Verify your work

In this task, you examine your pipeline and container app to verify successful pipeline runs.

Ensure that you have Project1 open in Azure DevOps.

  • On the left side menu, select Pipelines, and then select Pipeline1.

  • The Runs tab displays individual runs that can be selected to review details.
    f65detr

  • Open your Azure portal, and then open your Container App.

  • On the left side menu, select Activity Log.

  • Verify that a Create or Update Container App operation succeeded as a result of running your pipeline.
    I87yrr
    Notice that the Event initiated by column on the right shows your Project1 as the source.

In summary, configuring continuous integration (CI) with Azure Pipelines enables automated building, testing, and deployment of containerized applications to Azure Container Apps. By integrating your source code repository with Azure Pipelines, each commit or pull request can automatically trigger a pipeline that builds the container image, pushes it to Azure Container Registry (ACR), and deploys the updated image to Azure Container Apps. This setup ensures consistent application delivery, reduces manual overhead, and improves deployment reliability. Using YAML-based pipelines also provides version-controlled build definitions, promoting repeatability and alignment with DevOps best practices.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *