0

I am trying to update the elasticpool parameters with powershell script following this official documentation provided by Microsoft Elasticpools - Update

I am currently working with the Azure DevOps REST API to update a azureId parameter using the PATCH method. I am encountering a situation where the PATCH request returns a successful response with a status code of 200, indicating that the request has been accepted and processed. However, the expected changes are not reflected in the resource.

Here is my script

$AzureDevOpsPAT = "PAT"
$OrganizationName = "my-org"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)"))
$AzureDevOpsAuthenicationHeader = @{
    Authorization = "Basic $base64AuthInfo"

}

$uri = "https://dev.azure.com/$OrganizationName/_apis/distributedtask/elasticpools/PoolId?api-version=7.0"
$patchData = "{
  `"/azureId`": `"/subscriptions/subcriptionID/resourceGroups/rgName/providers/Microsoft.Compute/virtualMachineScaleSets/my-scaleSetName`"
}"


$response = Invoke-RestMethod -Uri $uri -Headers $AzureDevOpsAuthenicationHeader -Method PATCH -Body $patchData -ContentType "application/json"

$response | ConvertTo-Json -Depth 4

Trying with maxCapacity param and others seem to not be affected at all. Nothing changes in the DevOps AgentPools UI, and GET request return old values.

Has anyone else encountered this situation where the PATCH request to the Azure DevOps API returns a successful response (status code 200), but the changes specified in the PATCH operation are not being applied to the resource? What could be the potential causes of this behavior?

I appreciate any insights or suggestions on how to troubleshoot and resolve this issue. Thank you!

SPT
  • 139
  • 1
  • 6
nD0613
  • 135
  • 1
  • 11

1 Answers1

0

Try passing azureId in the patchData instead of /azureId

$patchData = "{
  "azureId": "/subscriptions/subcriptionID/resourceGroups/rgName/providers/Microsoft.Compute/virtualMachineScaleSets/my-scaleSetName"
}"

how to troubleshoot and resolve this issue

You can add below lines in your script to get the output of Patch request.

Write-Host "Response Content:" 
Write-Host $response

You can try to make the Patch call using Postman as well, using the same URL and Request Body.

Ikhtesam Afrin
  • 897
  • 1
  • 1
  • 6