Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Azure Deployment Environments is in maintenance mode, with no additional features planned.
Existing capabilities remain available. Use this documentation for current functionality and operational guidance. For details, see Maintenance mode for Azure Deployment Environments.
This article explains how to create and access an environment in an existing Azure Deployment Environments project by using the Azure CLI.
Prerequisites
| Category | Requirement |
|---|---|
| Installation | Install the Azure CLI extension for Azure Deployment Environments. |
| Procedure | Completion of Create and configure a dev center by using the Azure CLI. |
| Procedure | Completion of Create and configure a project by using the Azure CLI. |
| Permissions | To create an environment: The Deployment Environments User role, the DevCenter Project Admin role, or a built-in role that has appropriate permissions. |
Create an environment
Creating an environment automatically creates the required resources and a resource group to store them. The resource group name follows the pattern {projectName}-{environmentName}. You can view the resource group in the Azure portal.
To create an environment and configure resources, complete the following steps in the Azure CLI. You can view the outputs as defined in the specific Azure Resource Manager template (ARM template).
Note
Only users who have the Deployment Environments User role, the DevCenter Project Admin role, or a built-in role that has appropriate permissions can create an environment. Users who have the Deployment Environments Reader role can view their own environments and environments created by others.
Sign in to the Azure CLI:
az loginInstall or upgrade the Azure Dev Center extension for the CLI:
az extension add --name devcenter --upgradeList all the Azure Deployment Environments projects that you have access to:
az graph query -q "Resources | where type =~ 'microsoft.devcenter/projects'" -o tableConfigure the default subscription as the subscription that contains the project:
az account set --subscription <subscriptionName>Configure the default resource group as the resource group that contains the project:
az config set defaults.group=<resourceGroupName>List the type of environments that you can create in a specific project:
az devcenter dev environment-type list --dev-center-name <devcenterName> --project-name <projectName> -o tableList the environment definitions that are available to a specific project:
az devcenter dev environment-definition list --dev-center-name <devcenterName> --project-name <projectName> -o tableAn environment-definition is an infrastructure-as-code template that's defined in the environment.yaml file. Create an environment by using an environment-definition from the list of available environment-definitions:
az devcenter dev environment create --dev-center-name <devcenterName> --project-name <projectName> --environment-name <environmentName> --environment-type <environmentType> --environment-definition-name <environmentDefinitionName> --catalog-name <catalogName>If the specific environment-definition* requires any parameters, use
--parametersand provide the parameters as a JSON string or a JSON file. For example:$params = "{ 'name': 'firstMsi', 'location': 'northeurope' }" az devcenter dev environment create --dev-center-name <devcenterName> --project-name <projectName> --environment-name <environmentName> --environment-type <environmentType> --environment-definition-name <environmentDefinitionName> --catalog-name <catalogName> --parameters $params
Note
You can use --help to view more details about any command, accepted arguments, and examples. For example, use az devcenter dev environment create --help to view more details about creating an environment.
Troubleshoot a permissions error
You must have the Deployment Environments User role, the DevCenter Project Admin role, or a built-in role that has the required permissions to create an environment.
If you don't have the correct permissions, the environment isn't created. An error message like the following example might appear:
(EnvironmentNotFound) The environment resource was not found.
Code: EnvironmentNotFound
Message: The environment resource was not found.
To resolve the issue, assign the correct permissions. See Give access to the development team.
Access an environment
To access an environment:
List existing environments that are available in a specific project:
az devcenter dev environment list --dev-center-name <devcenterName> --project-name <projectName>View the access endpoints to various resources as defined in the ARM template outputs.
Access the specific resources by using the endpoints.
Deploy an environment
az devcenter dev environment deploy --action-id "deploy" --dev-center-name <devcenterName> \
-g <resourceGroupName> --project-name <projectName> --environment-name <environmentName> --parameters <parametersJsonString>
Delete an environment
az devcenter dev environment delete --dev-center-name <devcenterName> --project-name <projectName> --environment-name <environmentName> --user-id "me"