Skip to content

0GiS0/azure-dev-center-demos

Repository files navigation

πŸš€ Microsoft Dev Box πŸ’» & Azure Deployment Environments πŸ—οΈ Demos for Platform Engineering

πŸ‘‹πŸ» Welcome, developer! This repository contains scripts and resources to help you understand how Microsoft Dev Box and Azure Deployment Environments work.

πŸ“‘ Table of Contents


πŸ› οΈ Prerequisites

This repo use Dev Containers extension with Visual Studio Code to get all required tools pre-installed.

If you don't want to use Dev Containers, you can install the following tools manually πŸ˜…:

Important: You will also need a .env file with a personal access token (PAT) to read GitHub repo contents.


🚦 Getting Started

1. Install Azure Dev Center Extension 🧩

az extension add --name devcenter

2. Log in to Your Azure Subscription

az login --use-device-code

3. Set Environment Variables

View Script: 00-variables-and-registrations.sh

source scripts/00-minimal-setup/00-variables-and-registrations.sh

βš™οΈ Setup Options

πŸ“¦ Minimal Setup: Resource Group πŸ“¦, Dev Center 🏒, and Projects πŸ‘·πŸΌβ€β™€οΈπŸ‘·πŸ»β€β™‚οΈ

Create a Resource Group πŸ“¦

View Script: 01-create-rg.sh

source scripts/00-minimal-setup/01-create-rg.sh

Create a Dev Center 🏒

View Script: 02-create-dev-center.sh

source scripts/00-minimal-setup/02-create-dev-center.sh

Create Projects and Entra ID Groups

Dev Center uses Microsoft Entra ID groups to manage access to projects. You can create a group (or use existing ones) for developers and assign them to the project.

Create a Microsoft Entra ID Group for your developers:

View Script: 03-create-entra-id-groups.sh

source scripts/00-minimal-setup/03-create-entra-id-groups.sh

Create projects:

View Script: 03-create-projects.sh

source scripts/00-minimal-setup/03-create-projects.sh

πŸ–₯️ Basic Setup: Create a Dev Box from Azure Marketplace Image πŸ–₯️

Create a Dev Box Definition πŸ“¦

View Script: 01-create-dev-box-definition.sh

source scripts/01-basic-devbox/01-create-dev-box-definition.sh

Create a Dev Box Pool

View Script: 02-create-dev-box-pool.sh

source scripts/01-basic-devbox/02-create-dev-box-pool.sh

Access the Developer Portal

Congrats πŸŽ‰! Access the Developer Portal and create a new dev box using any user in the Devs group πŸ‘©πŸΌβ€πŸ’»πŸ‘¨πŸ»β€πŸ’».


πŸ–ΌοΈ Create a Custom Image πŸ–ΌοΈ

Option 1: Azure Image Builder

1. Create a Gallery πŸ–Ό

View Script: 01-create-azure-compute-gallery.sh

source scripts/02-custom-devbox/image-builder/01-create-azure-compute-gallery.sh

2. Create Image Definition ✏

View Script: 02-create-image-definition.sh

source scripts/02-custom-devbox/image-builder/02-create-image-definition.sh

3. Create Image Version 🏞️

Set up identity and custom role for Image Builder:

View Script: 03-create-azure-image-builder-identity-and-role.sh

source scripts/02-custom-devbox/image-builder/03-create-azure-image-builder-identity-and-role.sh

Define your image template (e.g., custom-images/win11-with-vscode.json):

View Script: 04-create-an-image-template.sh

source scripts/02-custom-devbox/image-builder/04-create-an-image-template.sh

4. Use the Custom Image

View Script: 05-create-dev-box-definition.sh

source scripts/02-custom-devbox/image-builder/05-create-dev-box-definition.sh

View Script: 06-create-dev-box-pool.sh

source scripts/02-custom-devbox/image-builder/06-create-dev-box-pool.sh

Access the Developer Portal to create a dev box with your custom image.


Option 2: Packer

  1. Install Packer.
  2. Create a service principal:
SUBSCRIPTION_ID=$(az account show --query id -o tsv)
RESULT=$(az ad sp create-for-rbac --name hcp-packer --role Contributor --scopes /subscriptions/$SUBSCRIPTION_ID)

Set environment variables:

export ARM_CLIENT_SECRET=$(echo $RESULT | jq -r .password)
export ARM_CLIENT_ID=$(echo $RESULT | jq -r .appId)
export ARM_TENANT_ID=$(az account show --query tenantId -o tsv)
export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
export ARM_RESOURCE_GROUP_NAME=$PACKER_GALLERY_RESOURCE_GROUP

IMPORTANT: Update variables.pkr.hcl with your own values.

3.Create resources using Terraform:

View Script: 01-create-resources-using-tf.sh

source scripts/02-custom-devbox/packer/01-create-resources-using-tf.sh

4.Attach the gallery and create definitions/pools:

View Script: 02-assign-packer-gallery.sh

source scripts/02-custom-devbox/packer/02-assign-packer-gallery.sh

View Script: 03-create-dev-box-definitions-for-packer-images.sh

source scripts/02-custom-devbox/packer/03-create-dev-box-definitions-for-packer-images.sh

View Script: 04-create-dev-box-pool-with-packer-images.sh

source scripts/02-custom-devbox/packer/04-create-dev-box-pool-with-packer-images.sh

Check the Developer Portal for your new images.


πŸ‘©πŸΌβ€πŸ’» Individual Customization πŸ‘©πŸΌβ€πŸ’»

The Microsoft Dev Box customizations feature helps you streamline the setup of the developer environment. With customizations, you can configure ready-to-code workstations with the necessary applications, tools, repositories, code libraries, packages, and build scripts.

Platform admins define a Catalog of allowed tasks (YAML + script). Attach the allowed-tasks folder to the Dev Center:

View Script: 00-attach-catalog-with-allowed-tasks.sh

source scripts/02-custom-devbox/customizations/00-attach-catalog-with-allowed-tasks.sh

Create a new dev box with customizations by uploading devbox-customizations/workload.yaml in the Developer Portal.

Installed example: Visual Studio Code


🌐 Integrate Dev Box with a Virtual Network 🌐

Create Network Connections πŸ“ž

View Script: 01-create-vnet-and-network-connections.sh

source scripts/03-network-integration/01-create-vnet-and-network-connections.sh

Create a SQL Server VM in the VNet

View Script: 02-create-vm-with-sql-server-in-that-vnet.sh

source scripts/03-network-integration/02-create-vm-with-sql-server-in-that-vnet.sh

Create a Dev Box Pool πŸ–₯️

View Script: 03-create-dev-box-pool.sh

source scripts/03-network-integration/03-create-dev-box-pool.sh

Go to the Developer Portal and create a dev box πŸ‘©πŸΌβ€πŸ’».



πŸ‘©πŸ½β€πŸ€β€πŸ‘¨πŸΎ Team Customizations πŸ‘©πŸ½β€πŸ€β€πŸ‘¨πŸΎ

Team customizations are used to create a shared configuration for a team of developers. In this folder team-customization-files you can find the YAML files that define the team customizations.

And with this script you can attach the team customizations folder to a particular project in your dev center:

View Script: 01-attach-project-catalog-with-team-customizations.sh

source scripts/02-custom-devbox/customizations/01-attach-project-catalog-with-team-customizations.sh

It will create a new pool for each team customization.

More information on Team Customizations.


☁️ Azure Deployment Environments ☁️

Using ARM

An environment definition consists of:

  • An ARM template (e.g., azuredeploy.json)
  • A configuration file (environment.yaml)

See examples in the catalog folder.

View Script: 01-create-a-catalog.sh

source scripts/04-environments/01-create-a-catalog.sh

Define Environments with Bicep

az bicep build --file {bicep_file} --outfile {out_file}
# Example:
az bicep build --file catalog/ARMTemplates/tour-of-heroes-environment/main.bicep --outfile catalog/ARMTemplates/tour-of-heroes-environment/azuredeploy.json

ADE Extensibility Model

You can use Bicep, Terraform, or Pulumi templates. For Terraform, do not create the resource group in your files:

variable "resource_group_name" {}

data "azurerm_resource_group" "rg" {
  name = var.resource_group_name
}

The resource group is created by Dev Center.

Check Deployment Logs

az devcenter dev environment list --project $PROJECT_FOR_ENVIRONMENTS --dev-center $DEV_CENTER_NAME
az devcenter dev environment show --environment-name $DEV_ENVIRONMENT_TYPE --project $PROJECT_FOR_ENVIRONMENTS --dev-center $DEV_CENTER_NAME

Get operation logs:

YOUR_ENVIRONMENT_NAME="direwolvescosmos"
OPERATION_ID=$(az devcenter dev environment list-operation \
  --environment-name $YOUR_ENVIRONMENT_NAME \
  --project $PROJECT_FOR_ENVIRONMENTS \
  --dev-center $DEV_CENTER_NAME \
  --query "[-1].operationId" -o tsv)

watch az devcenter dev environment show-logs-by-operation \
  --environment-name $YOUR_ENVIRONMENT_NAME \
  --project $PROJECT_FOR_ENVIRONMENTS \
  --operation-id $OPERATION_ID \
  --dev-center $DEV_CENTER_NAME

Delete an environment:

az devcenter dev environment delete \
  --environment-name direwolvesweb \
  --project $PROJECT_FOR_ENVIRONMENTS \
  --dev-center $DEV_CENTER_NAME

πŸ“Š Check Usage πŸ“Š

View Script: 11-check-usage.sh

source scripts/05-usage/11-check-usage.sh

🧹 Clean Up

πŸŽ‰ Congratulations! You did it! To clean up all resources:

Note: Delete user-created environments before deleting resources.

View Script: clean-up.sh

source scripts/clean-up.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •