Create and access an environment by using the Azure CLI
This article shows you how to create and access an environment in an existing Azure Deployment Environments project.
Prerequisites
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.
Complete the following steps in the Azure CLI to create an environment and configure resources. You can view the outputs as defined in the specific Azure Resource Manager template (ARM template).
Note
Only a user who has the Deployment Environments User role, the DevCenter Project Admin role, or a built-in role that has the required permissions can create an environment.
Sign in to the Azure CLI:
az login
Install the Azure Dev Center extension for the CLI.
az extension add --name devcenter --upgrade
List all the Azure Deployment Environments projects you have access to:
az graph query -q "Resources | where type =~ 'microsoft.devcenter/projects'" -o table
Configure the default subscription as the subscription that contains the project:
az account set --subscription <name>
Configure the default resource group as the resource group that contains the project:
az config set defaults.group=<name>
List the type of environments you can create in a specific project:
az devcenter dev environment-type list --dev-center <name> --project-name <name> -o table
List the environment definitions that are available to a specific project:
az devcenter dev environment-definition list --dev-center <name> --project-name <name> -o table
Create an environment by using an environment-definition (an infrastructure as code template defined in the manifest.yaml file) from the list of available environment definitions:
az devcenter dev environment create --dev-center-name <devcenter-name> --project-name <project-name> --environment-name <name> --environment-type <environment-type-name> --environment-definition-name <environment-definition-name> --catalog-name <catalog-name>
If the specific environment-definition requires any parameters, use
--parameters
and 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 <devcenter-name> --project-name <project-name> --environment-name <name> --environment-type <environment-type-name> --environment-definition-name <environment-definition-name> --catalog-name <catalog-name> --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: 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 <devcenter-name> --project-name <project-name>
View the access endpoints to various resources as defined in the ARM template outputs.
Access the specific resources by using the endpoints.
Next steps
- Learn how to add and configure a catalog.
- Learn how to add and configure an environment definition.
Feedback
Submit and view feedback for