Re-visiting Dev Container Features
Tags: cloudnative, vscode, devcontainers, azure
Published: 2022-12-02 22:00:11

---
title: Re-visiting Dev Container Features
published: true
date: 2022-12-02 15:00:10 UTC
tags: cloudnative, vscode, devcontainers, azure
canonical_url: https://paulyu.dev/article/revisiting-devcontainer-features/
---

A few months ago I wrote a post that described how you can [add custom features to your Dev Containers](https://github.com/microsoft/dev-container-features-template). That didn't age very well 😅

But good news is that there is a better way to add or extend functionality for your Dev Containers. 🥳

Since my original post, [@BrigitMurtaugh](https://twitter.com/BrigitMurtaugh) published a post on the VS Code blog announcing new repos, the [open dev container specification](https://containers.dev/) and discussed a new way of adding features. If you haven't read the post, go check it out [here](https://code.visualstudio.com/blogs/2022/09/15/dev-container-features). 

Additionally, a community member submitted feedback in the new [devcontainers/features](https://github.com/devcontainers/features) repo suggesting that Azure CLI extensions should just be supported as part of the [`azure-cli`](https://github.com/devcontainers/features/tree/main/src/azure-cli) feature. And so, I was happy to contribute the Azure CLI extension installation code that I wrote about previously to this new azure-cli feature.

## What's new with the `azure-cli` feature

The new feature can be added by referencing the package URL: `ghcr.io/devcontainers/features/azure-cli:1.0.7`. 

> Dev Container Features are published as GitHub packages

It accepts two new options: `extensions` and `installBicep`.

The `extensions` option expects a comma-separated list of Azure CLI extension names. Make sure you have the extension name spelled correctly here. If you misspelled an extension name, the azure-cli feature installation code will skip over it and continue installing other extensions in the list. You will see output in the container build logs stating the misspelled extension wasn't found, but it's easy to miss if you aren't paying attention to the logs.

The `installBicep` option expects a boolean value (`true` or `false`). When set to `true`, Azure Bicep will be installed and will be made available to you using either the `az bicep` command or the standalone `bicep` command. 

Here is an example of what your `devcontainer.json` file would look like if you needed Azure CLI with Azure Bicep and the Azure Managed Grafana, AKS (preview), and Azure Container Apps extensions installed:

```json
{
  "name": "Ubuntu",
  "image": "mcr.microsoft.com/devcontainers/base:jammy",
  "features": {
    "ghcr.io/devcontainer/features/azure-cli:1.0.7": {
      "version": "latest",
      "extensions": "amg,aks-preview,containerapp",
      "installBicep": true
    }
  },
  "remoteUser": "vscode"
}
```


## More Dev Container features

The list of [available features](https://containers.dev/features) is impressive and includes features that are maintained by the **Dev Container Spec Maintainers** team as well as features that are maintained by folks in the community. So if there's a feature for your Dev Container that you'd like to share, please feel free to contribute to the public repo. 

The cool thing here is that even if you don't contribute a feature to the public repo, you can always create a feature using the new [feature-starter](https://github.com/devcontainers/feature-template) template and host it in your own GitHub repo. The template includes a GitHub Action workflow file that will publish the feature for you. If you'd like to share your self-hosted feature with a broader audience, fork the [containers.dev site repo](https://github.com/devcontainers/devcontainers.github.io), edit the [collection-index.yml](https://github.com/devcontainers/devcontainers.github.io/blob/gh-pages/_data/collection-index.yml) file, and issue a Pull Request to have your feature appear in the available features list.

I highly encourage you all to provide feedback and/or contribute features to make Dev Containers awesome for everyone!

As always, hit me up on [Twitter](https://twitter.com/pauldotyu) or in the comments below if you have any questions ✌️

Happy packaging!

## Resources

* [Custom Dev Container Features](https://code.visualstudio.com/blogs/2022/09/15/dev-container-features)
* [Development Container Specification](https://containers.dev/implementors/spec/)
* [Available Dev Container Features](https://containers.dev/features)
* [Feature quick start repository](https://github.com/devcontainers/feature-template)