ππ» Welcome, developer! This repository contains scripts and resources to help you understand how Microsoft Dev Box and Azure Deployment Environments work.
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.
- Create a
.env
file by copying the.env-sample
. - Populate it with your GitHub PAT. See GitHub documentation on creating a PAT if you need help.
az extension add --name devcenter
az login --use-device-code
View Script: 00-variables-and-registrations.sh
source scripts/00-minimal-setup/00-variables-and-registrations.sh
π¦ Minimal Setup: Resource Group π¦, Dev Center π’, and Projects π·πΌββοΈπ·π»ββοΈ
source scripts/00-minimal-setup/01-create-rg.sh
View Script: 02-create-dev-center.sh
source scripts/00-minimal-setup/02-create-dev-center.sh
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
View Script: 01-create-dev-box-definition.sh
source scripts/01-basic-devbox/01-create-dev-box-definition.sh
View Script: 02-create-dev-box-pool.sh
source scripts/01-basic-devbox/02-create-dev-box-pool.sh
Congrats π! Access the Developer Portal and create a new dev box using any user in the Devs group π©πΌβπ»π¨π»βπ».
View Script: 01-create-azure-compute-gallery.sh
source scripts/02-custom-devbox/image-builder/01-create-azure-compute-gallery.sh
View Script: 02-create-image-definition.sh
source scripts/02-custom-devbox/image-builder/02-create-image-definition.sh
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
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.
- Install Packer.
- 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.
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
View Script: 01-create-vnet-and-network-connections.sh
source scripts/03-network-integration/01-create-vnet-and-network-connections.sh
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
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 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.
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
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
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.
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
View Script: 11-check-usage.sh
source scripts/05-usage/11-check-usage.sh
π Congratulations! You did it! To clean up all resources:
Note: Delete user-created environments before deleting resources.
source scripts/clean-up.sh