Configure Azure Deployment Environments service using Azure CLI

This article shows you how to use the Deployment Environments Azure CLI extension to configure an Azure Deployment Environments Preview service. In Azure Deployment Environments Preview, you'll use Deployment Environments Azure CLI extension to create environments.

Important

Azure Deployment Environments is currently in preview. For legal terms that apply to Azure features that are in beta, in preview, or otherwise not yet released into general availability, see the Supplemental Terms of Use for Microsoft Azure Previews.

Setup

  1. Install the Deployment Environments Azure CLI Extension:

    Automated install

    Execute the script https://aka.ms/DevCenter/Install-DevCenterCli.ps1 directly in PowerShell to install:

    iex "& { $(irm https://aka.ms/DevCenter/Install-DevCenterCli.ps1 ) }"
    

    This will uninstall any existing dev center extension and install the latest version.

    Manual install

    Run the following command in the Azure CLI:

    az extension add --source https://fidalgosetup.blob.core.windows.net/cli-extensions/devcenter-0.1.0-py3-none-any.whl
    
  2. Sign in to Azure CLI.

    az login
    
  3. Set the default subscription to the subscription where you'll be creating your specific Deployment Environment resources.

    az account set --subscription {subscriptionId}
    

Commands

Create a new resource group

az group create -l <region-name> -n <resource-group-name>

Optionally, set defaults (which means there is no need to pass the argument into each command):

az configure --defaults group=<resource-group-name>

Get help for a command

az devcenter admin <command> --help
az devcenter dev <command> --help

Dev centers

Create a dev center with User Assigned identity

az devcenter admin devcenter create --identity-type "UserAssigned" --user-assigned-identity
    "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1" --location <location-name> -g <resource-group-name> - <name>

Create a dev center with System Assigned identity

az devcenter admin devcenter create --location <location-name> -g <resource-group-name> -n <name> \
    --identity-type "SystemAssigned"

List dev centers (in the selected subscription if resource group is not specified or configured in defaults)

az devcenter admin devcenter list --output table

List dev centers (in the specified resource group)

az devcenter admin devcenter list -g <resource-group-name>

Get a specific dev center

az devcenter admin devcenter show -g <resource-group-name> --name <name>

Delete a dev center

az devcenter admin devcenter delete -g <resource-group-name> --name <name>

Force delete a dev center

az devcenter admin devcenter delete -g <resource-group-name> --name <name> --yes

Environment Types

Create an Environment Type

az devcenter admin environment-type create --dev-center-name <devcenter-name> -g <resource-group-name> --name <name>

List environment types by dev center

az devcenter admin environment-type list --dev-center-name <devcenter-name> --resource-group <resource-group-name>

List environment types by project

az devcenter admin environment-type list --project-name <devcenter-name> --resource-group <resource-group-name>

Delete an environment type

az devcenter admin environment-type delete --dev-center-name <devcenter-name> --name "{environmentTypeName}" \
    --resource-group <resource-group-name>

List environment types by dev center and project for developers

az devcenter dev environment list --dev-center <devcenter-name> --project-name <project-name>

Project Environment Types

Create project environment types

az devcenter admin project-environment-type create --description "Developer/Testing environment" --dev-center-name \
    <devcenter-name> --name "{environmentTypeName}" --resource-group <resource-group-name> \
    --deployment-target-id "/subscriptions/00000000-0000-0000-0000-000000000000" \
    --status Enabled --type SystemAssigned

List project environment types by dev center

az devcenter admin project-environment-type list --dev-center-name <devcenter-name> \
    --resource-group <resource-group-name>

List project environment types by project

az devcenter admin project-environment-type list --project-name <project-name> --resource-group <resource-group-name>

Delete project environment types

az devcenter admin project-environment-type delete --project-name <project-name> \
    --environment-type-name "{environmentTypeName}" --resource-group <resource-group-name>

List allowed project environment types

az devcenter admin project-allowed-environment-type list --project-name <project-name> \
    --resource-group <resource-group-name>

Catalogs

Create a catalog with a GitHub repository

az devcenter admin catalog create --git-hub secret-identifier="https://<key-vault-name>.azure-int.net/secrets/<secret-name>" uri=<git-clone-uri> branch=<git-branch> -g <resource-group-name> --name <name> --dev-center-name <devcenter-name>

Create a catalog with a Azure DevOps repository

az devcenter admin catalog create --ado-git secret-identifier="https://<key-vault-name>.azure-int.net/secrets/<secret-name>" uri=<git-clone-uri> branch=<git-branch> -g <resource-group-name> --name <name> --dev-center-name <devcenter-name>

Sync a catalog

az devcenter admin catalog sync  --name <name> --dev-center-name <devcenter-name> -g <resource-group-name>

List catalogs in a dev center

az devcenter admin catalog list -g <resource-group-name> --dev-center-name <devcenter-name>

Delete a catalog

az devcenter admin catalog delete -g <resource-group-name> --dev-center-name <devcenter-name> -n <name>

Catalog items

List catalog items available in a project

az devcenter dev catalog-item list --dev-center-name <devcenter-name> --project-name <name>

Project

Create a project

az devcenter admin project create -g <resource-group-name> -n <project-name> --dev-center-id <devcenter-resource-id>

List projects (in the selected subscription if resource group is not specified or configured in defaults)

az graph query -q "Resources | where type =~ 'microsoft.devcenter/projects' | project id, name"

List projects (in the specified resource group)

az devcenter admin project list -g <resource-group-name>

Delete a project

az devcenter admin project delete -g <resource-group-name> --name <project-name>

Environments

Create an environment

az devcenter dev environment create --dev-center-name <devcenter-name> \
    --project-name <project-name> -n <name> --environment-type <environment-type-name> \
    --catalog-item-name <catalog-item-name> ---catalog-name <catalog-name> \
    --parameters <deployment-parameters-json-string>

Deploy an environment

az devcenter environment deploy-action --action-id "deploy" --dev-center <devcenter-name> \
    -g <resource-group-name> --project-name <project-name> -n <name> --parameters <parameters-json-string>

List environments in a project

az devcenter dev environment list --dev-center <devcenter-name> --project-name <project-name>

Delete an environment

az devcenter dev environment delete --dev-center <devcenter-name>  --project-name <project-name> -n <name> --user-id "me"