Within the "Classic" deployment pipelines in Azure Devops we would utilise Azure Deployment Agents Groups to spin up a docker instance and then do things inside the container.
We are moving to YAML pipelines and are struggling to execute the same workflow.
It seems that there isn't feature parity so we need to utilise Environments within DevOps. I have a docker container that can register itself as a resource within a Environment with no issue. I can also use the REST API to query and create these on the fly.
My issue is that it doesn't seem to be possible to delete a resource without nuking the entire environment? We can query then via /_apis/distributedtask/environments/62?expands=resourceReferences
We can of course unregister the resource by running the remove command on the container, but then doesn't cater for the scenario of "what if the docker container dies/goes offline". We would be left with dangling resources which would block the creation of new ones
I originally got around this by creating a new dynamically named environment per container, but it seems that due to YAML evaluating the deployment environments ahead of running, this would not be viable (as the env wouldn't exist!)
So back to the actual question: Is it possible to delete/unregister a resource within an environment?