Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "elasticPools" #520

Open
o-l-a-v opened this issue Apr 27, 2023 · 0 comments
Open

Add support for "elasticPools" #520

o-l-a-v opened this issue Apr 27, 2023 · 0 comments
Labels
enhancement Improvements that do not include new features feature request for new feature requests that do not just improve things

Comments

@o-l-a-v
Copy link

o-l-a-v commented Apr 27, 2023

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

@o-l-a-v o-l-a-v added enhancement Improvements that do not include new features feature request for new feature requests that do not just improve things labels Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements that do not include new features feature request for new feature requests that do not just improve things
Projects
None yet
Development

No branches or pull requests

1 participant