Automate Azure Function Deployments by Setting up Azure Pipelines

September 28, 2022 | Comments(1) |

TABLE OF CONTENT

1. Introduction
2. Prerequisites
3. Steps to create a Function App
4. Steps to create a Pipeline into the Function App
5. Conclusion
6. About CloudThat
7. FAQs

 

Introduction

Serverless computing has answered many requirements like reducing administration of production workloads, refactoring an application into different individual independent functionalities, massively scaling with minimal downtime, and delivering quick services without the need to manage servers. Azure Function is a serverless offering from Azure, which supports different programming languages and various sources for the trigger.

Azure pipelines are used to automate the deployment process to accomplish your CI and CD needs.

Prerequisites

  1. An active Azure subscription for creating a function app
  2. A GitHub repository with the code to deploy
  3. An Azure DevOps Organization, if you do not have any, you can create one for free

Steps to create a Function App

  1. Login to your Azure portal and Search for Function Apps. Click on create new.
  2. Give required fields like subscription, resource group, Function app name, runtime stack, and storage accounts.
  3. Wait till the deployment process is completed, once done click on Go to resource

function_app

Steps to create a Pipeline to build and deploy your code into the Function App

1. Go to your Azure DevOps Organization and create a new project.step12. You need to create a service connection that stores your credentials for azure pipelines to connect with your Azure.

3. Go to project settings at the bottom of the navigation bar. Select service connection under pipelines. Click on new service connection → Azure resource manager → Service Principle(auto) → Under subscription scope gives your details and save it.

step3

4. You can add the variables with the variable group in the library under pipelines which can be referenced inside the pipeline YAML file. You can add your Function App name as a variable and reference it while adding the deployment stage.

step4

5. Go inside the project and navigate to pipelines and click on create a pipeline. Select GitHub and select repository, then it will ask you to authenticate your GitHub account. Select configure as starter pipeline.

step5

6. You can add the different stages for build, test, and deployment. For each stage, you can define a job to run on a specific agent with steps required according to your application. Use the assistant showing on the right side for adding tasks like building the application, archiving the files, publishing the artifact to the pipeline, downloading the artifact from the building, deploying the application to the function app, etc.

step6

7. You can use the Azure Functions template in the assistant to add your target function deployment step as a task

step7

8. Once the YAML is ready click on Save and run, give a commit message, and run the pipeline. It will push the YAML file into the specified repository and trigger the pipeline to run
9. Verify that the pipeline job ran successfully and go inside and click on jobs to trace the tasks as it runs

step9

step9b

10. Verify the deployment from the function app or get the function URL and verify through the browser

step10

If you want to know more about Infrastructure-as-Code Pipelines in Azure here.

Conclusion

Based on your application and the DevOps tools you use, you can select among the wide variety of deployment strategies available in Azure DevOps. Azure DevOps can be extended to different target resources, and you can leverage the templates in your YAML. A proper Service Connection is required for the pipeline to authenticate to Azure.

About CloudThat

CloudThat is the official AWS (Amazon Web Services) Advanced Consulting Partner, Microsoft Gold Partner, Google Cloud Partner, and Training Partner helping people develop knowledge of the cloud and help their businesses aim for higher goals using best-in-industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Explore our consulting here.

If you have any queries regarding Azure and Azure Functions drop a line below the comments section. I will get back to you at the earliest.

FAQs

Q1. What is an agent in Azure DevOps?
A. An agent is an Infrastructure for computational needs for running the jobs during pipeline execution. You can use Microsoft-hosted agents to reduce your management workload or Self-hosted agents to gain more control over the agent.

Q2. What is a parallel Job?

A. A Pipeline can contain any number of jobs. Each job runs as a parallel job on separate agents, and if all parallel jobs are consumed, then the remaining jobs will queue up and run one after the other.

 


One Response to “Automate Azure Function Deployments by Setting up Azure Pipelines”

Leave a Reply