Chapter 7. Managing and Deploying your Code
"Do the difficult things while they are easy and do the great things while they are small. A journey of a thousand miles must begin with a single step."
DevOps is currently one of the most discussed terms at conferences, in technical discussions, team meetings, and in customer engagements too. It is a buzzword nowadays and everyone wants to implement DevOps practices to gain the advantages of them.
Let's be very clear on the definition of DevOps. This term is a combination of development and operations. DevOps is not a tool or a technology or a framework. DevOps is a culture. It is a culture that brings improvement in the outcome and productivity of the resources.
As we have already stated, it is not a tool or technology; however, tools and technology play an important role in the implementation of DevOps practices. Along with tools, technology, and disruptive innovation in information technology, there are two other important aspects that...
We want to achieve CI/CD as depicted in the following diagram:
We will utilize Visual Studio Team Services (VSTS) for Continuous Integration and Continuous Delivery to deploy Azure Functions as and when code changes are committed in the Git repository hosted in VSTS:
- First, we will create a project in VSTS so that we can store code and configure Continuous Integration and Continuous Delivery using the build and release definitions:
- Visit visualstudio.com and sign in:
- On the VSTS dashboard, create a new account or select an existing account.
- We already have a few projects available in the dashboard.
- Click on
New Project
:
- Provide the details for the
Project name
, Version control
, and Work item process
. Click on Create
:
- Click on
Generate Git credentials
:
- Provide the details as required and click on
Save Git Credentials
:
- Once we have Git set up in the VSTS dashboard, go to the directory where Azure Function code is available.
- If Git for Windows is not installed, then install it first...
Continuous Integration is one of the most popular and core DevOps practices. Continuous Integration is a practice where code is committed to a shared repository such as Git, and the committed code is verified against static code analysis, automated build, and unit test cases.
- Let's create a build definition.
- Click on the Git repository and click on
Set up build
:
- Select a template
Azure Web App
and click on Apply
:
- Keep only
Get sources
and Publish Artifact
tasks. - Click on
Add Task
and add Copy Files
task to the Build definition:
- We want to copy all the files available from the Azure Functions project.
- Provide the details for
Target Folder
:
Publish Artifact
is used to make available files to be used in the Release definition:
- In the
Triggers
section, enable the Continuous Integration trigger. Now, if any new code is checked in, then Continuous Integration will take place:
- Click on
Save
. Our Build definition is ready.
In the next section, we will create the Release definition.
Continuous Delivery is the practice of deploying a package into a non-production environment in an automated manner.
Once our Continuous Integration process is completed successfully, we can deploy a package using the Continuous Delivery practice in an automated way.
- Click on the
Releases
in VSTS.
- Select the
Azure App Service Deployment
template and click on Next
:
- Select the
Project
and Build
definition that we created in the previous section. - Select the Continuous Deployment checkbox.
- It means that whenever the associated Build definition is successfully executed, release definition will be triggered automatically. Click on
Create
:
- The new Release definition is ready.
- Let's configure it.
- We need to configure Azure Subscription first.
- Click on
New Service Endpoint
. - Select new
Azure Resource Manager
:
- Provide a
Connection name
and select Subscription
:
- Verify the newly created endpoint:
- Go to the
Release Definitions
. Refresh the list of Azure subscriptions...
DevOps is a culture and it is more effective when people, processes, and technology come along together to change the culture.
In serverless computing too, we can utilize DevOps practices such as Continuous Integration and Continuous Delivery.
In this chapter, we have configured Continuous Integration using the Build definition and Continuous Delivery using the Release definition. We have executed them manually and also configured the Build and Release definitions triggers.
We have also used the Git repository available in VSTS for code management.
In the next chapter, we will discuss the different options available for monitoring, pricing-related details, and best practices.