Keep migration to new endpoint

This commit is contained in:
Alitzel Mendez 2025-12-08 16:10:25 -08:00 committed by azure-sdk
parent ef74176810
commit 28ae0f9bba

View File

@ -1,11 +1,9 @@
[CmdletBinding()] [CmdletBinding()]
Param ( Param (
[Parameter(Mandatory=$False)]
[array] $ArtifactList,
[Parameter(Mandatory=$True)] [Parameter(Mandatory=$True)]
[string] $ArtifactPath, [array] $ArtifactList,
[Parameter(Mandatory=$False)] [Parameter(Mandatory=$False)]
[string] $APIKey, [string] $ArtifactPath,
[string] $SourceBranch, [string] $SourceBranch,
[string] $DefaultBranch, [string] $DefaultBranch,
[string] $RepoName, [string] $RepoName,
@ -97,25 +95,17 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
$uri = "${APIViewUri}/upload" $uri = "${APIViewUri}/upload"
# Try Bearer token first, fall back to API key # Get Bearer token for authentication
$bearerToken = Get-ApiViewBearerToken $bearerToken = Get-ApiViewBearerToken
if ($bearerToken) { if (-not $bearerToken) {
$headers = @{ Write-Error "Failed to acquire Bearer token for APIView authentication."
"Authorization" = "Bearer $bearerToken";
"content-type" = "multipart/form-data"
}
}
elseif ($APIKey) {
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key."
$headers = @{
"ApiKey" = $APIKey;
"content-type" = "multipart/form-data"
}
}
else {
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
return 401 return 401
} }
$headers = @{
"Authorization" = "Bearer $bearerToken";
"content-type" = "multipart/form-data"
}
try try
{ {
@ -156,23 +146,16 @@ function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $review
Write-Host "Request to APIView: $uri" Write-Host "Request to APIView: $uri"
# Try Bearer token first, fall back to API key # Get Bearer token for authentication
$bearerToken = Get-ApiViewBearerToken $bearerToken = Get-ApiViewBearerToken
if ($bearerToken) { if (-not $bearerToken) {
$headers = @{ Write-Error "Failed to acquire Bearer token for APIView authentication."
"Authorization" = "Bearer $bearerToken"
}
}
elseif ($APIKey) {
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key. Please migrate to using AzureCLI@2 task with service connection."
$headers = @{
"ApiKey" = $APIKey
}
}
else {
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
return 401 return 401
} }
$headers = @{
"Authorization" = "Bearer $bearerToken"
}
try try
{ {