Step 3: Create a new Build Pipeline to build and push Docker image
1. Create a new pipeline use the classic editor
2. Select source repository
3. Select Docker container template
4. Fill in your Azure Container Registry information in the "Build an image" Task. Since we added our Dockerfile in our git repository, according to "**/Dockerfile" setting, the pipeline can find our Dockerfile and use it to build the docker image.
5. Fill in your Azure Container Registry information in the "Push an image" Task.
6. Enable continuous integration in Triggers
Step 4: Create New Release Pipeline
1. Set the Artifacts, select your project name, Source (the build pipeline we just created in Step 3)
We can enable Continuous deployment trigger, so when there is any code change being pushed to our git repository, the release task will be triggered to run.
2. Add a new Stage using "Empty job" template, named it "Deploy to App"
3. Create a Task in this "Deploy to App" stage
4. Select "ubuntu-latest" as the job Agent
5. Add an Azure CLI task in this Agent job
6. Select your Azure subscription, and fill in the following Shell Inline script
az config set extension.use_dynamic_install=yes_without_prompt
az extension add --name spring-cloud
az spring-cloud app deploy \
--resource-group <your resource group name> \
--name <App name> \
--container-image $(Build.Repository.Name):$(Build.BuildId) \
--service <your Azure Spring Cloud service name> \
--container-registry <Azure Container Registry url> \
--registry-password <Azure Container Registry password> \
--registry-username <Azure Container Registry username>
Step 5: Trigger CICD docker image build and App deployment.
Since we enabled continuous integration in Step 3 & continuous deployment in Step 4, when we commit and push any code change in the git repository, the pipeline will be automatically triggered.
1. Push some changes in the git repo, then we can go to Pipeline -> Runs to check the build log
2. We can see detailed log for each build step
3. We can go to Pipeline -> Releases to check the release log
"Azure CLI" task log records all the Azure CLI commands and the response details.
4. After the new app deployment being successfully boot up, in Azure Spring Apps portal, we should be able to see Succeeded Provisioning state.
In the App -> Configuration portal, we should see the new custom docker image being set.
We can check the application being successfully brought up and responding incoming requests.