Loading...

Azure Tips and Tricks - How to perform Serverless operations with Azure DevOps

Azure Tips and Tricks - How to perform Serverless operations with Azure DevOps

How to perform Serverless operations with Azure DevOps

 

 

Build and deploy Azure Functions with Azure DevOps

Azure Functions are great for running tasks on demand, like processing queue messages or resizing images. They can run serverless, which means that you can run them without having to configure and maintain infrastructure. And with Azure DevOps Pipelines, Microsofts' Continuous Integration (CI) and Continuous Deployment (CD) solution, you can easily compile your Azure Functions and deploy to the Azure.

In this post, we'll take a look at how we can use Azure DevOps Pipelines to easily build and deploy an Azure Function to the cloud.

 

Prerequisites

If you want to follow along, you'll need the following:

 

Creating a build and release pipeline in minutes with Azure DevOps Pipelines

We'll start by creating a build pipeline in Azure DevOps Pipelines. This will compile the code for the Azure Function and make it into a package that can be deployed.

  1. Go to the Azure DevOps portal (https://dev.azure.com) and select your project
  2. In the menu on the left, select Pipelines
  3. Now select Create Pipeline to start creating one
  4. The first step asks you where your code is. Before we give that information, click on the link below that says "Use the classic editor" to switch to the visual designer. This is easy to start with and from there you can still go back into the YAML configuration if you want
  5. Now tell it where your source code is. This can be in Azure Repos, GitHub or somewhere else. Select the right code branch and select Continue
  6. Next, you can select a build template to start from. There are many templates that come out of the box and you can also create a build pipeline from scratch. Scroll down to the template called Azure Functions for .NET and select Apply

manojsrinivas_0-1656023661850.png

 

(Select a build template in the Azure DevOps portal)

 

  1. You'll now see the build pipeline. It has steps to compile the code, package the resulting files and publish them to a drop location, so that they can be used by another process, like a release pipeline. This all works out of the box and you can configure it as you like and add steps to the pipeline. Select Save and queue and Save and run after that to save the pipeline and start the build process.

manojsrinivas_1-1656023661822.png

 

(Working build pipeline in the Azure DevOps portal)

 

Now that you have a working Continuous Integration (CI) pipeline that builds your Azure Function code, we will create a release pipeline that takes the result from the build and deploys that to Azure.

  1. In the Azure DevOps portal, select Releases in the left menu
  2. Click New pipeline to create your first release pipeline
  3. The first thing that you'll see is the Select a template blade. Here, you can select a template to create a release process for one of the stages in your pipeline. Find the template called Deploy a function app to Azure Functions and select Apply
  4. Next, you'll be asked to provide a name for the stage that you've just selected a template for. You can create multiple stages, like Dev, Test, Acceptance and production and deploy your application through all of them. You can even configure when a certain stage should start deploying and you can indicate that somebody needs to approve the deployment to certain stages. Fill in something like "Production".
  5. Now click on the stage to drill down into it and configure its steps

manojsrinivas_2-1656023661867.png

 

(Release pipeline in the Azure DevOps portal)

 

  1. We only have one step in the process and that is Deploy Azure Function App. Select the step
  2. Select the Azure Subscription to use for the deployment. If this is the first time that you use this subscription with Azure DevOps, you need to select Authorize to grant Azure DevOps permissions to use the subscription
  3. Next, select Function App on Windows for App Type
  4. For App Service name, select the App Service that you want to deploy your Function to
  5. Click Save
  6. Go back to the stages by selecting Releases in the breadcrumb menu and Edit after that

manojsrinivas_3-1656023661876.png

(Release pipeline in the Azure DevOps portal)

 

  1. In the overview, click on the Add an artifact tile, and select the results of the build process
  2. Click on the lightning icon of the artifact to configure continuous deployment. This automatically starts a release when a build successfully finishes
  3. Now select Create release in the right-hand corner and select Create after that, to start deploying the Function to Azure
  4. You should see a message that says that your release has been created. Click on the link to the release to see it running

manojsrinivas_4-1656023661892.png

 

(Release results in the Azure DevOps portal)

 

After a while, the release will be finished and your Function is deployed to the Azure Function in Azure.

 

Conclusion

You've just used Azure DevOps pipelines to create a complete Continuous Integration (CI) and Continuous Deployment (CD) solution to deploy an Azure Function to Azure. This was incredibly easy and took just a couple of minutes to complete. You can see how powerful Azure DevOps pipelines is as you can easily point the pipeline to other source code, add more tasks to the pipelines or select other templates, and use YAML to create more advanced pipelines. To learn more, create a trial account today and go and check it out

Published on:

Learn more
Azure Developer Community Blog articles
Azure Developer Community Blog articles

Azure Developer Community Blog articles

Share post:

Related posts

Setting up Team-Based Access for Dynamics 365 CRM Documents Stored on SharePoint, Dropbox or Azure Blob Storage

Attach2Dynamics by Inogic is a seamless document management solution for Dynamics 365 CRM that integrates with popular cloud storage platforms...

19 hours ago

Azure SDK Release (October 2024)

The Azure SDKs release every month. This post includes the month's highlights and release notes. The post Azure SDK Release (October 2024) app...

1 day ago

Using Entra profile information in Azure DevOps

We’re excited to announce the ability to use Entra profile information in Azure DevOps. This has been a long-standing feature request from the...

1 day ago

Exploring SUSE Enterprise Linux on Azure

Exploring SUSE Enterprise Linux on Azure In today's cloud-centric world, leveraging robust and reliable operating systems is crucial for busin...

1 day ago

Azure Adaptive Cloud Pre-Days at Microsoft Ignite 2024

As the excitement builds for Microsoft Ignite 2024, tech enthusiasts and professionals worldwide are eagerly anticipating the Azure Adaptive C...

1 day ago

Build Intelligent Apps Code-First with Prompty and Azure AI

      Building Generative AI applications can feel daunting for traditional app developers. What does the end-to-end applicati...

3 days ago

Soccer Analytics Copilot with Azure SQL and OpenAI

The Football (aka Soccer in US 😀) Analisys Copilot provides an intuitive interface for users to interact with complex football data without n...

3 days ago

End-to-End Full-Stack Web Application with Azure AD B2C Authentication: A Complete Guide

Application Overview The purpose of this sample application is to demonstrate the usage of Azure Active Directory B2C (Azure AD B2C) for authe...

4 days ago

Updates to Azure Cosmos DB’s Portal Networking Settings

We are happy to share with you an update to the Azure Cosmos DB networking configuration options within the Azure Portal. This update introduc...

4 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy