Skip to content

Add support for "elasticPools" #520

Description

@o-l-a-v

Proposal

Please add support for creating, getting and setting "elasticPools". I want to create a Azure Automation Account runbook that sets minimum amount of VMSS / Azure DevOps self-hosted scale set agents to 1 during work hours, else 0. I planned to use VSTeam module, but don't think you have cmdlets for that yet?

Anyhow, here is a PowerShell example for getting a elasticPool:

# Set PAT
$PAT = [securestring](Read-Host -Prompt 'Paste PAT' -AsSecureString)

# Set TLS version
if ([System.Net.ServicePointManager]::SecurityProtocol.ToString() -ne 'Tls12') {
    [System.Net.ServicePointManager]::SecurityProtocol = 'Tls12'
}

# Get pool
Invoke-RestMethod -Uri 'https://dev.azure.com/<redacted>/_apis/distributedtask/pools/<redacted>?api-version=7.0' -Method 'Get' -Headers @{
    'Authorization' = [string] 'Basic {0}' -f (
        [Convert]::ToBase64String(
            [System.Text.Encoding]::UTF8.GetBytes(
                ':'+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PAT))
            )
        )
    )
}

# Get elasticPool
Invoke-RestMethod -Uri 'https://dev.azure.com/<redacted>/_apis/distributedtask/elasticPools/<redacted>?api-version=7.0' -Method 'Get' -Headers @{
    'Authorization' = [string] 'Basic {0}' -f (
        [Convert]::ToBase64String(
            [System.Text.Encoding]::UTF8.GetBytes(
                ':'+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PAT))
            )
        )
    )
}

And here are some documentation:

Solved Problem

Would help me to scale VMSS ADO agents up and down.

Additional info / code snippets?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovements that do not include new featuresfeature requestfor new feature requests that do not just improve things

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions