Exercise - Configure continuous integration by using Azure Pipelines
In this exercise, you deploy a container app from an image in the Azure Container Registry to the Azure Container Apps platform.
The following Azure resources must be available in your Resource group named RG1:
- A Container registry instance that contains one image.
- A Virtual network with subnets.
- A Service Bus Namespace
- A Managed Identity
- A Private endpoint
- A Container App
- A Container Apps Environment
You've been asked to configure a continuous integration environment for Container Apps that meets the following requirements:
- You need an Azure Container Apps deployment task in your Azure DevOps environment.
Pipeline1must deploy a container image from your container registry to your container app using a self-hosted agent pool.- You must ensure that the pipeline successfully deploys the image at least once.
You complete the following tasks during this exercise:
Configure
Pipeline1to use the self-hosted agent pool.Configure
Pipeline1with an Azure Container Apps deployment task.Run the
Pipeline1deployment task.Verify the configuration.
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.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
poolsection specifies the agent pool to use for the pipeline. Thenameproperty specifies the name of the agent pool. In this case, the name isdefault, which is the pool you configured as a self-hosted agent pool.Under Validate and save, select Save without validating.
Enter a commit message, and then select Save.
Configure Pipeline1 with an Azure Container Apps deployment task
Ensure that you have
Pipeline1open 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.
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
Pipeline1Task information:- Docker Image to Deploy:
<Registry>/<Image>:<Image tag> - Azure Container App name:
<Name>
- Docker Image to Deploy:
Configure the following
Pipeline1Task information:- Azure Resource group name: RG1
Note
If you need to verify the resource group name, you can find it on the Overview page of your Container App resource.
On the Azure Container Apps Deploy page, select Add.
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: '<Subscription>(<Subscription ID>)' imageToDeploy: '<Registry>/<Image>:<Image tag>' from Container App resource containerAppName: '<Name>' from Container App resource resourceGroup: '<resource group name>'Here's an example that shows a YAML configuration snippet:
trigger: - main pool: name: default steps: - task: AzureContainerApps@1 inputs: azureSubscription: 'Visual Studio Enterprise(1111aaaa-22bb-33cc-44dd-555555eeeeee)' imageToDeploy: 'acraz2003cah12oct.azurecr.io/aspnetcorecontainer:latest' containerAppName: 'aca-az2003' resourceGroup: 'RG1'Select Validate and save, and then select Save again to commit directly to the main branch.
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
Pipeline1open 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.
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.
Monitor the status of the run operation and verify that the run is successful.

Check your work
In this task, you examine your pipeline and container app to verify successful pipeline runs.
Ensure that you have
Project1open 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.

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.

Notice that the Event initiated by column on the right shows your
Project1as the source.