How To Set Up Continuous Integration Pipelines with Azure Pipelines and PCF
Introduction
Azure Pipelines is a CI/CD suite that enables you to continuously build, test, and deploy to any platform or cloud. It has cloud-hosted agents for Linux, macOS, and Windows, powerful workflows with native container support, and flexible deployments to Cloud Foundry, Kubernetes, VMs, and serverless environments.
In this guide, we will demonstrate how to use Azure pipelines to automatically deploy your application to PCF. To demonstrate, we will configure a continuous integration pipeline for a sample application written in .NET Core and push application to Pivotal hosted Cloud Foundry.
Prerequisites
Before you begin, you will need accounts to access tools and platform, if you already have these accounts, you can skip below step.

When creating an account on Azure DevOps, you will be prompted to create a organization, select region and create project, this project will be used later in this tutorial
In this tutorial, most of the work will be done on Azure pipelines portal and Pivotal web services portal, so you will need very minimal number of tools on your local system.
This tutorial assumes that you have your application source code somewhere in Github or Azure repos, if not you can still use the sample code from here.
“It is easy to shoot your foot off with git, but also easy to revert to a previous foot and merge it with your current leg.”
—Jack William Bell
Installing Cloud Foundry Extension to Azure DevOps portal
Cloud Foundry extension will help us to push our apps to any Cloud Foundry platform.
Login to your Azure DevOps portal, default project will be visible which you created during account creation. We will be adding Cloud Foundry extension to out Azure DevOps portal, from Azure DevOps marketplace which is a one stop shop to get all your cool Azure DevOps extensions.
Click on that shopping bag or you can go to marketplace using this link. Search for Cloud Foundry on marketplace.


Click on Get it free, after which you will be prompted to select organization , after selecting organization, click on install.

Click on Proceed to organization

Adding Service Endpoint for Cloud Foundry extension
Service endpoints are defined to connect to external and remote services to execute tasks for a build or deployment. We will be create a Generic type service endpoint.

We will be prompted for credentials to our Pivotal web services account.

Connection Name can be anything meaningful, eg PCF / cloud foundry
Server URL: https://api.run.pivotal.io
User name: your email address to pivotal web services
Password: your password to pivotal web services
Once we have created this service connection, we can use it for our pipelines deployment.
Initialize your repository
If you already have a repository in your project, you can skip to the next step creating-our-first-pipeline.
To create a new repository, go to Repos tab in left pane, and select + New repository from dropdown menu


Now once we have our code repository, let’s push our code along with the Cloud Foundry CLI.
What is the need to commit CF cli along with my source code?
According to Azure DevOps Cloud Foundry extension Github repository, we need to add cf cli with our code, because cf cli binary is still not available out of the box.
You can select Cloud Foundry cli binary based on your OS from here
After you push your code to above repo / import public repository using import button on your Azure repo, you will get a view like this on your Azure repo

Creating our First Azure pipeline
Once we are inside our project & done with importing our code to Azure repos, let’s create our first pipeline. On left hand pane, there are multiple options, including Pipelines.
Click on New pipeline button

There are few pipeline templates to choose from, but for our tutorial we will be choosing Empty job. Add the name of the stage, eg deploy to pcf and click anywhere on screen to save the changes.

Adding Artifact in our pipeline
Once we have our empty template, we need to add an artifact, which in our case will be Azure repository which we created.
Click on Add an artifact and configure to use our Azure code repo, refer below snapshot.

To enable continuous integration, we need to enable trigger on our code artifact.

Adding tasks to our pipeline stage
Next step is to add task to our deploy to pcf stage, click on the Tasks tab drop down menu to select deploy to pcf task.

Selecting agent
Now we need select agent which will be executing our task to push application to PCF.

Click on Agent job to list agent properties, you can change the name of the agent or choose the OS type.
There are different agents to choose from, depending on type of workstation you work on, or the which tools you want to use, you can choose Agents out of:

Choose Hosted Windows Container, if you are using cf.exe along with your repository. I used Hosted macOS as i develop code on Mac.
Click on save with default settings for folder prompt.
Adding task to agent
Click on + besides Agent job to add the task, click on marketplace to search for Cloud Foundry extension.


Add Cloud Foundry task from the marketplace.
Configure Push to Cloud Foundry Task
Select the Cloud Foundry endpoint from dropdown menu, which we created earlier in this tutorial.

From Connection Settings, choose whether to skip ssl validation, org and spaces from your Pivotal web services account. Refer below snapshot.
Org is rbanka-org
Space is development


From Deployment options, you can choose either deploy manually or using manifest file. Select the path of manifest file by clicking on … on Manifest file field.

Now the most important part of configuration, Advanced fields
This part of configuration, helps the agent to detect location of Cloud Foundry CLI and set the working directory for the source code.
Select the properties from each field by clicking on … and selecting the file path and working directory

Click on Save to save the pipeline.

Creating a Release
Now we have our pipeline, lets create a release to deploy our code.

After creating the automated release, it will be scheduled and will start deploy. To view the release click on … besides Release name

Once scheduled, task will be assigned to agent and app will be deployed to PCF.



Once the change is committed in repository, you’ll see a new release will be created automatically and deploys application.
You can visit the deployed application here
For more details visit below links:
Vert well explained. Thank you a lot for this step by step guide.
Can I share your article on my website with reference to this article?
Sure!