Azure DevOps Training by www.flexmind.co

Azure DevOps with Octopus Deploy

In this blog Azure DevOps with Octopus Deploy you will learn how to use Octopus Deploy with Azure DevOps.

Octopus Deploy is a single place for your team to manage releases, automate deployments, and automate the runbooks that keep your software operating.

Octopus Deploy is an automated deployment server that makes it easy to automate the deployment of ASP.NET web applications, Java applications, NodeJS application and custom scripts to multiple environments.

Azure DevOps will be handling the build/CI automation part of the process and will work with Octopus Deploy to handle deployment orchestration. The Octopus setup contains a central deployment server, along with “Tentacle” agents that run on any target VMs where deployment will take place.

Octopus Deploy has two components:

  • Octopus Server — a centralized web front-end that orchestrates deployments, and
  • Tentacle — agent that needs to be on every target endpoint.

We will spin up an Octopus server on Azure. Click the Deploy to Azure button below to provision an Octopus Server.

  1. It takes approximately 15 minutes for the deployment to complete. Once the deployment is successful, connect to the Octopus server using DNS, and login with the Octopus Admin username and password.
Octopus Server login

2. You will see the Octopus deploy web portal.

Octopus deploy web portal

Generating Service Principal Names(SPN) details from Azure

We need to generate SPN details to get Tenant IDApplication ID and Application Password/Key which will be used in the later part of the lab.

  1. Login to your Azure account and click on Cloud Shell.
Azure Cloud Shell

2. Select Bash or Powershell to run the command which will generate the SPN details.

3. Create a Storage account as Azure Cloud Shell requires an Azure file share to persist files, if you already have one select it or create new. Select the subscription and click on Create storage.

4. Once the storage account is provisioned, enter the following command by replacing ServicePrincipalName with your desired value.

az ad sp create-for-rbac -n ServicePrincipalName

5. It will give you a JSON output as shown in the image. Copy the output to notepad or text file. You will need them later.

Azure Cloud Shell JSON output.

Setting up the Deployment Target

Since, the deployment target is an Azure WebApp, we need to create one. Click the button below to provision an Azure WebApp.

Generate Octopus API Key

An API key is used to authenticate Azure DevOps with Octopus server. Using API key lets you keep your username and password a secret.

  1. From the Octopus Deploy portal, select Profile under User menu.
Octopus Deploy Portal

2. Select My API Key and click New API Key to create one. We will use the API Key to connect Octopus Deploy with Azure DevOps.

Octopus Deploy API Key

3. Specify a purpose, for instance, Azure DevOps Integration and click Generate New.

Octopus Deploy New API Key

4. Copy the API Key to clipboard and save this to a notepad as you might use it for future requests.

Octopus Deploy Generate New API Key

Configure Deployment Target in Octopus Server

In this lab, we are using Azure App Service as the deployment target.

  1. On the Octopus portal dashboard, select Create environments to go into the Infrastructure page.
Octopus Deploy create environment

2. Once inside, click Add Environment.

Octopus Deploy Add Environment

3. Provide the environment name and click Save.

4. Octopus Deploy provides first-class support for deploying Azure Cloud Services and Azure Web Applications. To deploy software to Azure, we must add our Azure subscription to Octopus Deploy, and then use the built-in step templates to deploy to the cloud. Once the environment is created, click on Accounts select Azure Subscription from the ADD ACCOUNT dropdown.

Octopus Deploy Azure Web Application

Octopus Deploy authenticates with Azure with one of the two methods:

To deploy to Azure Resource Manager (ARM), Octopus requires Azure Service Principal Account.

To deploy to Cloud Services and Azure Web Apps, Octopus requires Azure Management Certificate.

Name: Provide an account name

Subscription ID: Your Azure Subscription ID

Authentication Method: Choose Use a Service Principal

Tenant IDApplication IDApplication Password/Key: Created earlier in the lab

Octopus Deploy Infrastructure
Octopus Deploy Infrastructure - 2

5. Click SAVE AND TEST and notice that your account is verified.

6. To add the deployment target, go to Deployment Targets, click on ADD DEPLOYMENT TARGET, select Azure Web App and click NEXT.

Octopus Deployment Targets
Octopus Deployment Targets 2

7. In the Create deployment target page, provide Display Name, choose Environment from the dropdown, add Target Roles(Tags), select the Account which was created earlier, and select Azure Web App from the dropdown as shown below and click Save.

Octopus Targets Roles
Octopus Targets Roles 2

Create Project in Octopus

Project is a collection of deployment steps and configuration variables that define how your software is deployed.

  1. Go to the Octopus dashboard and click on Create a project.
Octopus Add Project 2

2. Click on ADD PROJECT, provide the project name, description and click on SAVE.

Octopus Add Project
Octopus Add New Project

3. Once the project is created, click Define your deployment process. The deployment process is like a recipe for deploying your software.

4. Click on ADD STEP to see a list of built-in step templates, custom step templates, and community contributed step templates.

Octopus Add Step

5. Search for Azure Web App template and click Add.

Octopus Azure Web App

6. Populate the step template with required details –

Step Name : A short, unique name for the template.

On Behalf Of : Choose the target role from the drop down that was created in previous exercise step 8.

Package ID : Type-in as Asp.netcore (if you are providing different package ID, update it in Package Application task of the build definition)

Octopus Azure Web App - 2
Octopus Azure Web App - 3

7. Click Save to complete the project creation and its deployment process.

Triggering CI-CD

  1. Go to Builds under Pipelines tab, select Octopus build definition and click on Edit.
Octopus Azure DevOps

2. In Push Packages to Octopus task, update Octopus Deploy Server field with the created endpoint value.

Octopus Azure DevOps Build Pipeline

3. In the Create Octopus Release task, update the Octopus Deploy Server field with the created endpoint value, and choose the created Project from the dropdown.

Octopus Azure DevOps Build Pipeline 2

4. In Deploy Octopus Release task, update Octopus Deploy Server field with the created endpoint value, choose the appropriate values from the drop down for fields — Project and Deploy to Environments and Save & Queue the build definition.

Octopus Azure DevOps Build Pipeline 3

5. Navigate back to the Build tab see progress of the build.

Octopus Azure DevOps Build Pipeline 4

6. Once the build completes, go to Octopus portal project dashboard to see the release progress.

Octopus Deploy App

7. Go to the created Azure Web App from your Azure Portal and click Browse.

Octopus Azure Web App Browse

We will see the associated ASP.NET Core application up and running.

Octopus Azure Web App Browse 2

Recommended Courses

VILT & Self-Paced
Azure Developer Certification

AZ-204: Developing Solutions for Microsoft Azure

This self-paced course will help you prepare for the Azure Developer certification exam AZ-204: Developing Solutions for Microsoft Azure.

BUY NOW

Self-Paced
Azure Developer Certification

AZ-900: Microsoft Azure Fundamentals Tutorial

AZ-900: Microsoft Azure Fundamentals Tutorial provides foundational level knowledge on cloud concepts; core Azure services; security, privacy, compliance, and trust; and Azure pricing and support.

BUY NOW

Self-Paced
Azure DevOps Online Course

AZ-400: Designing and Implementing Microsoft DevOps Solutions

This self-paced course will help you prepare for the Azure DevOps certification exam AZ-400: Designing and Implementing Microsoft DevOps Solutions.

BUY NOW


Sharing is Caring

1 thought on “Azure DevOps with Octopus Deploy”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top