1

I would like to create an Azure DevOps Pipeline Environment from Powershell.

enter image description here

Using Azure CLI or the Azure REST API however, I can not find any information on this. There are some notions about the environments in the release but that's not what I need.

When using the portal following URL is called "/_apis/distributedtask/environments" but can't find any information about this REST API endpoint.

Does anyone know how to automate this?

1 Answer 1

2

You're right, If I check the network section when I create a new environment I can see it uses this api:

https://dev.azure.com/{org}/{project}/_apis/distributedtask/environments

With this JSON body:

{
    "description":"",
    "name":"test"
}

I don't see it domunetd but it should work :)

Sign up to request clarification or add additional context in comments.

2 Comments

Running this code: $uriAccount = $BaseUri + "distributedtask/environments?api-version=5.1-preview" $body = "@{description=""a"";name=""b""}" | ConvertTo-Json Invoke-RestMethod -Uri $uriAccount -Method Post -Body $body -ContentType "application/json" -Headers $azureDevOpsAuthenicationHeader Invoke-RestMethod : {"$id":"1","innerException":null,"message":"TF400898: An Internal Error Occurred. Activity Id: 5e...","typeName":"System.NullReferenceException, mscorlib","typeKey":"NullReferenceException","errorCode":0,"eventId":0}
Ok its fixed now, my body was wrong and it works with $body = @{"description"="a";"name"="b"} | ConvertTo-Json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.