Private/azuredevops.ps1

function Invoke-RKDevOpsAPI {
    param([string]$API,
        [string]$RequestType)

    $AzureDevOpsAuthenicationHeader = Get-RKDevOpsHeaders
    
    $URI = "https://dev.azure.com/$env:AZUREDEVOPS_ORGANIZATION/$env:AZUREDEVOPS_PROJECTNAME/_apis/$API"
    Return Invoke-RestMethod -Method $RequestType -Uri $URI -Headers $AzureDevOpsAuthenicationHeader -ContentType application/json    
}

function Invoke-RKDevOpsAPIPut {
    param([string]$API,
        $Body)

    $AzureDevOpsAuthenicationHeader = Get-RKDevOpsHeaders
    
    $URI = "https://dev.azure.com/$env:AZUREDEVOPS_ORGANIZATION/$env:AZUREDEVOPS_PROJECTNAME/_apis/$API"
    Return Invoke-RestMethod -Method 'PUT' -Body $Body -Uri $URI -Headers $AzureDevOpsAuthenicationHeader -ContentType application/json    
}


function Get-RKDevOpsHeaders {
    $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
    $currentAzContext = Get-AzContext 
    $profileClient = New-Object Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient($azProfile)
    $token = $profileClient.AcquireAccessToken($currentAzContext.Subscription.TenantId) 
    $AccessToken = $token.AccessToken
    
    $Authorization = "{0} {1}" -f ("Bearer" , $AccessToken)

    $AzureDevOpsAuthenicationHeader = @{"Authorization" = $Authorization;
        "X-TFS-FedAuthRedirect"                         = "Suppress"
    } 

    return $AzureDevOpsAuthenicationHeader
}