Skip to content

Commit 161aeef

Browse files
authored
Update release-and-work-item-insights.md
switched script from using az rest to Invoke-ReskMethod to make it work for both windows and linux both the az cli command and the provided solution (Invoke-AzRestMethod) fail on ubuntu-latest azure pipelines
1 parent ef72cb6 commit 161aeef

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

articles/azure-monitor/app/release-and-work-item-insights.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,19 @@ You can use the `CreateReleaseAnnotation` PowerShell script to create annotation
224224
$annotation = ConvertTo-Json $annotation -Compress
225225
$annotation = Convert-UnicodeToEscapeHex -JsonString $annotation
226226
227-
$body = $annotation -replace '(\\+)"', '$1$1"' -replace "`"", "`"`""
228-
229-
az rest --method put --uri "$($aiResourceId)/Annotations?api-version=2015-05-01" --body "$($body) "
230-
231-
# Use the following command for Linux Azure DevOps Hosts or other PowerShell scenarios
232-
# Invoke-AzRestMethod -Path "$aiResourceId/Annotations?api-version=2015-05-01" -Method PUT -Payload $body
227+
$accessToken = (az account get-access-token | ConvertFrom-Json).accessToken
228+
$headers = @{
229+
"Authorization" = "Bearer $accessToken"
230+
"Accept" = "application/json"
231+
"Content-Type" = "application/json"
232+
}
233+
$params = @{
234+
Headers = $headers
235+
Method = "Put"
236+
Uri = "https://management.azure.com$($aiResourceId)/Annotations?api-version=2015-05-01"
237+
Body = $annotation
238+
}
239+
Invoke-RestMethod @params
233240
```
234241
235242
> [!NOTE]

0 commit comments

Comments
 (0)