| Command | Description |
|--- |--- |
|az pipelines environment create | Create an environment |
|az pipelines environment list | Show all environments in a project |
|az pipelines environment show | Show details of an environment |
|az pipelines environment delete | Delete an environment |
|az pipelines environment resource add | Add a resource to an environment |
|az pipelines environment resource list | List all the resources in an environment |
|az pipelines environment resource delete | Delete a resource in an environment |
Any ETA for this? It would be very useful for us to be able to read environment metadata (even if it was just in the form of hashtags in the description) and use that to influence the terraforming that's happening in our branch yaml pipeline.
Environments concept is still undergoing changes due to which they haven't made the APIs public yet. Until the APIs for environments are released we cannot support these commands or comment on an ETA for it.
Can't you release an preview just like with AKS preview features that were associated by an Azure-Cli preview?
@BoSoeborgPetersen Preview features still require the API to be exposed publically even if it is released in preview mode. So we will have to wait for the API release before we can introduce these commands.
If you still need to automate something related.. you can checkout the API being called from the UI and use CLI az devops invoke command to send the same request from CLI.
@atbagga Okay, fair enough, thanks for the info.
I am not using Azure DevOps Server, so how would you suggest that I "checkout the API being called from the UI"?
@BoSoeborgPetersen Networks tab in the browser developer tools windows.
e.g. here is a screenshot from chrome..

@atbagga Thank you very much.
I figured out that to perform CRUD operations on environments using 'az devops invoke' either:
az devops invoke --area distributedtask --resource environments --route-parameters project=<project> [enviromentId=<id>] --http-method <CRUD> --api-version 6.0-preview -o json --in-file <config_file_path>.json
or:
az devops invoke --area environments --resource environments --route-parameters project=<project> [enviromentId=<id>] --http-method <CRUD> --api-version 6.0-preview -o json --in-file <config_file_path>.json
can be used, as specified by the templates returned from 'az devops invoke':
{
"area": "distributedtask",
"id": "8572b1fc-2482-47fa-8f74-7e3ed53ee54b",
"maxVersion": 6.0,
"minVersion": 5.0,
"releasedVersion": "0.0",
"resourceName": "environments",
"resourceVersion": 1,
"routeTemplate": "{project}/_apis/{area}/{resource}/{environmentId}"
}
or:
{
"area": "environments",
"id": "d86b72de-d240-4d6f-8d06-08c2d66b015d",
"maxVersion": 6.0,
"minVersion": 5.2,
"releasedVersion": "0.0",
"resourceName": "environments",
"resourceVersion": 1,
"routeTemplate": "{project}/_apis/pipelines/{resource}/{environmentId}"
}
Also to add Kubernetes resources to environments using 'az devops invoke' either:
az devops invoke --area distributedtask--resource kubernetes --route-parameters project=<project> environmentId=<environment_id> [resourceId=<id>] --http-method POST --api-version 6.0-preview --in-file <config_file_path> -o json
or:
az devops invoke --area environments --resource kubernetes --route-parameters project=<project> environmentId=<environment_id> [resourceId=<id>] --http-method POST --api-version 6.0-preview --in-file <config_file_path> -o json
can be used, as specified by the templates returned from 'az devops invoke':
{
"area": "distributedtask",
"id": "73fba52f-15ab-42b3-a538-ce67a9223a04",
"maxVersion": 6.0,
"minVersion": 5.0,
"releasedVersion": "0.0",
"resourceName": "kubernetes",
"resourceVersion": 1,
"routeTemplate": "{project}/_apis/{area}/environments/{environmentId}/providers/{resource}/{resourceId}"
}
or:
{
"area": "environments",
"id": "73fba52f-33ab-42b3-a538-ce67a9223b15",
"maxVersion": 6.0,
"minVersion": 5.2,
"releasedVersion": "0.0",
"resourceName": "kubernetes",
"resourceVersion": 2,
"routeTemplate": "{project}/_apis/pipelines/environments/{environmentId}/providers/{resource}/{resourceId}"
}
I can also delete Kubernetes resources using --http-method DELETE, with resourceId=<id>.
The only problem now is that I cannot figure out how to get a list of resources for an environment, so that I can use the ID's of the resources to delete and replace them with new ones?
I tried:
az devops invoke --area environments --resource kubernetes --route-parameters project=<project> environmentId=<environment_id> --http-method GET --api-version 6.0-preview -o json
but it is not supported without an resource ID:
request failed: The requested resource does not support http method 'GET'.
I cannot find any relevant templates that seem to cover this either with 'DistributedTask' or 'Environment', as the area.
Also:
az devops invoke --area environments --resource environments --route-parameters project=<project> --http-method GET --api-version 6.0-preview
does not return the resources associated with the environment?
Would be useful if this could also include the ability to manipulate and list tags associated with pipeline environments as well.
I am currently using a number of VMs in an environment and use tags to target specific deployments to the correct machines (think 3 tier app sort of arrangement), I would like to be able to get a list of VMs that match a certain tag so that I can then use the Agent Name as a variable for other pipelines.
I would truly appreciate this as well.
Any update on this? This feature would be really helpful. Surely the environment API is set by now.
i'm able to get the list of kubernetes resources with curl, same should work with az rest i guess:
curl -u:<PAT> "https://<ORGANIZATION>/<PROJECT>/_apis/distributedtask/environments/<ENVIRONMENT_ID>?expands=resourceReferences&api-version=6.0-preview.1"
Most helpful comment
@atbagga Thank you very much.
I figured out that to perform CRUD operations on environments using 'az devops invoke' either:
az devops invoke --area distributedtask --resource environments --route-parameters project=<project> [enviromentId=<id>] --http-method <CRUD> --api-version 6.0-preview -o json --in-file <config_file_path>.jsonor:
az devops invoke --area environments --resource environments --route-parameters project=<project> [enviromentId=<id>] --http-method <CRUD> --api-version 6.0-preview -o json --in-file <config_file_path>.jsoncan be used, as specified by the templates returned from 'az devops invoke':
or:
Also to add Kubernetes resources to environments using 'az devops invoke' either:
az devops invoke --area distributedtask--resource kubernetes --route-parameters project=<project> environmentId=<environment_id> [resourceId=<id>] --http-method POST --api-version 6.0-preview --in-file <config_file_path> -o jsonor:
az devops invoke --area environments --resource kubernetes --route-parameters project=<project> environmentId=<environment_id> [resourceId=<id>] --http-method POST --api-version 6.0-preview --in-file <config_file_path> -o jsoncan be used, as specified by the templates returned from 'az devops invoke':
or:
I can also delete Kubernetes resources using
--http-method DELETE, withresourceId=<id>.The only problem now is that I cannot figure out how to get a list of resources for an environment, so that I can use the ID's of the resources to delete and replace them with new ones?
I tried:
az devops invoke --area environments --resource kubernetes --route-parameters project=<project> environmentId=<environment_id> --http-method GET --api-version 6.0-preview -o jsonbut it is not supported without an resource ID:
request failed: The requested resource does not support http method 'GET'.I cannot find any relevant templates that seem to cover this either with 'DistributedTask' or 'Environment', as the area.
Also:
az devops invoke --area environments --resource environments --route-parameters project=<project> --http-method GET --api-version 6.0-previewdoes not return the resources associated with the environment?