@@ -183,6 +183,35 @@ You can use the `CreateReleaseAnnotation` PowerShell script to create annotation
183
183
[parameter(Mandatory = $true)][string]$releaseName,
184
184
[parameter(Mandatory = $false)]$releaseProperties = @()
185
185
)
186
+
187
+ # Function to ensure all Unicode characters in a JSON string are properly escaped
188
+ function Convert-UnicodeToEscapeHex {
189
+ param (
190
+ [parameter(Mandatory = $true)][string]$JsonString
191
+ )
192
+ $JsonObject = ConvertFrom-Json -InputObject $JsonString
193
+ foreach ($property in $JsonObject.PSObject.Properties) {
194
+ $name = $property.Name
195
+ $value = $property.Value
196
+ if ($value -is [string]) {
197
+ $value = [regex]::Unescape($value)
198
+ $OutputString = ""
199
+ foreach ($char in $value.ToCharArray()) {
200
+ $dec = [int]$char
201
+ if ($dec -gt 127) {
202
+ $hex = [convert]::ToString($dec, 16)
203
+ $hex = $hex.PadLeft(4, '0')
204
+ $OutputString += "\u$hex"
205
+ }
206
+ else {
207
+ $OutputString += $char
208
+ }
209
+ }
210
+ $JsonObject.$name = $OutputString
211
+ }
212
+ }
213
+ return ConvertTo-Json -InputObject $JsonObject -Compress
214
+ }
186
215
187
216
$annotation = @{
188
217
Id = [GUID]::NewGuid();
@@ -192,7 +221,11 @@ You can use the `CreateReleaseAnnotation` PowerShell script to create annotation
192
221
Properties = ConvertTo-Json $releaseProperties -Compress
193
222
}
194
223
195
- $body = (ConvertTo-Json $annotation -Compress) -replace '(\\+)"', '$1$1"' -replace "`"", "`"`""
224
+ $annotation = ConvertTo-Json $annotation -Compress
225
+ $annotation = Convert-UnicodeToEscapeHex -JsonString $annotation
226
+
227
+ $body = $annotation -replace '(\\+)"', '$1$1"' -replace "`"", "`"`""
228
+
196
229
az rest --method put --uri "$($aiResourceId)/Annotations?api-version=2015-05-01" --body "$($body) "
197
230
198
231
# Use the following command for Linux Azure DevOps Hosts or other PowerShell scenarios
0 commit comments