Basically I am working on revamping a pipeline we have that generates an elastic pool in Azure DevOps. I keep running into issues because we are relying on the Azure API. The pipeline first seems to remove Queues that are attached to the elastic pool, and then attempted to do a POST to create a new elastic pool, but when I run it with my updated packer image (with windows 2022) I keep running into the same error: ##[error]Agent pool already exists.
I can manually delete the elastic pool through the UI and re-run the pipeline, but then it fails at a different step that is calling the cmdlet: Update-AzVmssInstance
So my block/question is: is there a way to properly delete + recreate an elastic pool in Azure DevOps or somehow overwrite an existing one with the new machine image using the APIs (https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/elasticpools/create?view=azure-devops-rest-7.1).
I encountered something similar to this with the UI recently. I had deleted an existing elastic pool and attempted to recreate it, it also told me that the agent pool with identifier x already exists.
This may not be useful for your situation - but I tried creating it again with the same parameters and it worked.