Skip to content
· 12 min watch
Mike Evans-Larah By Mike Evans-Larah Software Engineer III

Explore the Azure CNAB Quickstart Library for bundling, installing, and managing cloud-native apps. Learn to create and deploy bundles across various platforms.

About this talk

Azure CNAB Quickstarts Launch

Over the last few months, endjin have been working together with Microsoft to create the Azure CNAB Quickstart Library in GitHub.

CNAB (Cloud-Native Application Bundle) is a new specification designed for facilitating the bundling, installing and managing of cloud-native or distributed apps. It provides you with a way to containerise your installation process, and easily deploy & share your entire solution across any cloud, on-prem, or at the edge.

We're excited about CNAB as it offers a much needed abstraction for defining all the required artefacts and steps to install your applications, bringing together whatever multitude of tools, their pre-requisites, and the runbooks required.

We created the Quickstarts Library so that the community can discover and use bundles for deploying applications and solutions, learn how to create their own bundles, and contribute back to the library. The library is designed to be optimized for bundles that use Azure resources, but is not limited to Azure only.

Read the transcript

What's covered in this video

This video will provide an introduction to the Azure CNAB Quickstarts library. Firstly, we will introduce CNAB and explain what it is, and then Porter, a CNAB tool that is key to the Quickstart library. After that, we will explain what the Quickstarts library is and how to use it.

Let's start with CNAB. CNAB is the abbreviation for Cloud Native Application Bundles, and is a specification designed to facilitate the bundling, installing and managing of cloud native or distributed apps. The specification was developed by the consortium of companies you see here, including Microsoft. Version 1.0 of the core specification reached final draft status towards the end of 2019. Other important specifications should conclude shortly, including security.

A CNAB is made up of three components

A CNAB, or bundle for short, is made up of three components. Firstly, application images. These are application artifacts, most often containers, for example your web server or database images. Typically these will be Docker images, but the CNAB spec is not tied to any specific technology. Nothing is new here if you are already containerizing your applications.

Next is the invocation image. This can be thought of as an installer for your application. The image contains all the necessary tools and scripts to perform the installation. For instance, it may contain the Azure CLI and admin scripts for running Azure CLI commands if your application depends on Azure infrastructure, or the Helm CLI and associated commands for deploying a Helm chart into a Kubernetes cluster, or even just a collection of custom written Bash scripts. The upshot of this is that the person using your bundle does not need any of these tools installed on their local machine, nor do they need any knowledge of how these tools work. All the installation steps are captured in the invocation image, and this is what is run when the bundle is invoked.

Finally, we have the bundle descriptor, which is the metadata for your bundle. It contains the name and version of the bundle, the list of application and invocation images the bundle contains, and any parameters, credentials and outputs for the bundle. Whilst the CNAB spec defines well-known actions for bundles, which are install, upgrade and uninstall, you can also create custom actions that your invocation image will handle. For instance, an action which reports on the status of an installation. These custom actions will be listed in the bundle descriptor.

CNAB benefits

The benefit of all this is that it gives you a bundle format where you can package up your application along with everything necessary to install it. What may have previously been written as a complex series of steps in an instructional readme, or just knowledge inside an engineer's head, can be captured in the invocation container image, installed using any of the tools that understand the CNAB specification. One analogy is to think of CNAB as an MSI installer, but designed for the cloud.

CNAB tools and Porter

CNAB is only the specification. To make use of it, we need to use a tool that implements the spec. There are several tools that do this, including Duffle, which was used as the reference implementation for CNAB, and Docker App, which is Docker's product for using CNAB. We will be looking at Porter, as Porter is a tool being actively developed by Deis Labs, the Microsoft Azure open source division, and is the tool currently supported by the Azure CNAB Quickstarts library, which we'll discuss later in the video.

Porter is a CLI tool capable of building, publishing, managing and invoking bundles. It offers an opinionated view for how to do this, in order to make it simple and powerful for teams whilst still conforming to the CNAB specification. As previously mentioned, it is owned and developed by Deis Labs. It's completely open source, so you can join the community and contribute to its direction.

The Porter manifest and mixins

You create bundles in Porter by writing a manifest, and get Porter to build the bundle for you. The manifest defines the following: metadata for the bundle, which includes the name, version, description, the invocation image and bundle tags; an associated optional Dockerfile template; the associated application images for your bundle, with their description, image type, repository and either a digest or a tag; the credentials, parameters and outputs that apply to the bundle; and the mixins used by the bundle.

Mixins are adapters between Porter and an existing tool or system. Finally, the manifest defines the steps needed to complete each of the actions for your bundle, where each step uses one of the mixins defined above. Each mixin is used for a specialized task. There are built-in mixins available for things like Kubernetes, Azure, Terraform, AWS, Helm, and a generic exec mixin for executing scripts and tools using a shell. You can also build your own mixins and include them in the steps if you require custom tasks.

Building a bundle with Porter

With the manifest in place, you can then use the Porter CLI to run the build command. This will first create the bundle descriptor based on the metadata in the manifest. Then it will produce a Dockerfile to use for creating the invocation image. This Dockerfile is based on the steps for each of the actions defined in the Porter manifest, plus combined with an optional custom Dockerfile template that you can provide. It also copies the Porter runtime and any necessary mixin runtimes from your local Porter installation to a temporary location.

Once these files are in place, internally Porter uses Docker to build the invocation image, which will contain the manifest, the Porter and mixin runtimes, and any additional files that you have specified that are required for your application. The invocation image and bundle descriptor, together with your application images, which may be in an external container registry, make up your logical bundle.

Publishing and invoking bundles

Now that the bundle is built, Porter can perform other actions. You can use Porter publish to publish the bundle to an OCI registry, such as Docker Hub or Azure Container Registry. This will publish both the invocation image and the bundle descriptor as artifacts to the target repository, using the tags defined in the Porter manifest. You can also invoke your bundle actions, like install, upgrade and uninstall. For instance, you can invoke the install action to install your application using the porter install command. This can be done using the local bundle descriptor file, or by specifying the tag and pointing to the OCI registry artifact.

The CNAB specification has a notion of thin bundles and thick bundles. The thin bundle is just a bundle descriptor file. The invocation image and application images are merely referenced by the descriptor. A thick bundle is an archive of the bundle descriptor along with the invocation image and application images. This can be useful for installing applications on air-gapped systems, for instance. Porter can create this thick bundle by running the porter archive command, which will create a gzip tar archive of all the necessary components for the bundle.

Porter bundle management

There are other commands available in Porter for management of bundles too, such as inspect, for showing the details of a bundle; explain, which additionally shows parameters, credentials, outputs and custom actions; list, for listing instances of installed bundles; show, for showing a specific instance of a bundle; and copy, for copying a bundle between registries. This brings us to the end of the overview of Porter, and the reason we have been discussing Porter in this video is because it's the tool supported by the Azure CNAB Quickstarts library.

Azure CNAB Quickstarts

So what is the Quickstarts library? The Quickstarts library is designed to be a collection of bundles that can be used for easily deploying applications, solutions and samples, where those that make use of Azure resources can be highly optimized. The library enables authors to build bundles for sharing using Porter, and for consumers to easily install the bundles, either via one-click "Deploy from Azure" button deployments, or from the command line in Azure Cloud Shell.

The Quickstarts repository is located on GitHub under the Azure organization as azure-cnab-quickstarts. In the repository, quickstarts are grouped by the tool used to create them, which is currently only Porter, as this is the only supported tool, and within the tool folder each quickstart has its own directory. You can also view a list of all the available quickstarts on the table of contents page, which also displays the current version and short description.

At the root of each quickstart is a readme with all the information you require. There is an introduction explaining what the quickstart is, followed by two sections explaining how to deploy the quickstart. The first option for deploying is to use the "Deploy from Azure" buttons, either simple or advanced, which differ in the number of options made available to the user. The second option is to follow the instructions for deploying from Azure Cloud Shell using the supplied command. The readme also contains a list of the parameters and credentials for the bundle, and a list of any known issues, which are automatically updated from the related GitHub issues in the repo.

Azure Cloud Shell deployment

We'll now briefly explain how the two deployment mechanisms work. Firstly, the Azure Cloud Shell deployment. The command in the readme instructs you to run Porter in Cloud Shell using the -d flag with azure as the value. This tells Porter to use the Azure driver to invoke the bundle. Be aware that you will need to run a setup script in Cloud Shell the first time you use the environment, which will install Porter and the Azure driver. There are instructions in the readme which explain how to do this.

When running the installation with the Azure driver, Porter will create an instance of Azure Container Instances, or ACI for short, for doing the work. ACI pulls down the invocation image for the bundle from the publicly accessible CNAB Quickstarts Azure Container Registry. All the bundles and invocation images from the Quickstarts library are published to this registry as part of the GitHub CI/CD workflow configured for the Quickstarts repo. Using this invocation image, ACI then runs the install action to install the application.

"Deploy from Azure" button deployment

The "Deploy from Azure" button deployment mechanism works similarly, but with some extra internal steps. The user first clicks the button. This will take them into the Azure portal custom deployment screen and present them with the UI for filling in the required parameters for the bundle. When filled in, the user submits the deployment. This then uses Azure Resource Manager to create an Azure Container Instance.

This container instance pulls down a CNAB Azure driver image from the CNAB Quickstarts registry. This image is essentially a bootstrapper for running the process. When this image runs, it will run the same porter install command we saw in the Cloud Shell deployment, using the Azure driver. This creates a second container instance, which, like in the Cloud Shell deployment, pulls down the invocation image for the bundle from the registry and then runs the image to install the application. At the end of the process, the temporary resources created in Azure are deleted.

The Azure CNAB Quickstarts repository

The full instructions for using these deployment methods are contained in documentation in the repo. Although these two deployment methods are documented for ease of use, users can use the quickstart bundles with any CNAB compliant tool they wish. To assist with authoring quickstarts, the Quickstarts repository also has a documentation guide with the steps necessary, including showing how to get started from a Porter template that is included in the repo, how to submit a PR with the new quickstart, and describing the steps that take place in the CI/CD workflow that runs, using a mixture of built-in and custom-built GitHub Actions. It is this workflow that publishes the quickstart bundles into the publicly accessible Azure Container Registry so they can be consumed.

Summary

This concludes this introductory video, which has provided an overview of CNAB and Porter, and also an introduction to the Azure CNAB Quickstarts library. For more information about individual quickstarts, you can refer to the information available in the repo. Thank you.

About the presenter

Mike Evans-Larah

Software Engineer III

Mike Evans-Larah

Mike is a Software Engineer at endjin with over a decade of experience in solving business problems with technology. He has worked on a wide range of projects for clients across industries such as financial services, recruitment, and retail, with a strong focus on Azure technologies.