Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ steps:
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name) `
-ArtifactPath ${{ parameters.ArtifactPath }} `
-RepoRoot $(Build.SourcesDirectory) `
-APIKey $(azuresdk-apiview-apikey) `
-ConfigFileDir '${{ parameters.ConfigFileDir }}' `
-BuildDefinition $(System.CollectionUri)$(System.TeamProject)/_build?definitionId=$(System.DefinitionId) `
-PipelineUrl $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) `
Expand Down
18 changes: 0 additions & 18 deletions eng/common/scripts/Create-APIReview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ Set-StrictMode -Version 3
. (Join-Path $PSScriptRoot common.ps1)
. (Join-Path $PSScriptRoot Helpers ApiView-Helpers.ps1)

# Get Bearer token for APIView authentication
# In Azure DevOps, this uses the service connection's Managed Identity/Service Principal
function Get-ApiViewBearerToken()
{
try {
$tokenResponse = az account get-access-token --resource "api://apiview" --output json 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to acquire access token: $tokenResponse"
return $null
}
return ($tokenResponse | ConvertFrom-Json).accessToken
}
catch {
Write-Error "Failed to acquire access token: $($_.Exception.Message)"
return $null
}
}

# Submit API review request and return status whether current revision is approved or pending or failed to create review
function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVersion, $packageType)
{
Expand Down
34 changes: 31 additions & 3 deletions eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
. ${PSScriptRoot}\..\logging.ps1

# Get Bearer token for APIView authentication
# In Azure DevOps, this uses the service connection's Managed Identity/Service Principal
function Get-ApiViewBearerToken()
{
try {
$tokenResponse = az account get-access-token --resource "api://apiview" --output json 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to acquire access token: $tokenResponse"
return $null
}
return ($tokenResponse | ConvertFrom-Json).accessToken
}
catch {
Write-Error "Failed to acquire access token: $($_.Exception.Message)"
return $null
}
}

function MapLanguageToRequestParam($language)
{
$lang = $language
Expand All @@ -22,15 +40,25 @@ function MapLanguageToRequestParam($language)
return $lang
}

function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiKey, $apiApprovalStatus = $null, $packageNameStatus = $null)
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiApprovalStatus = $null, $packageNameStatus = $null)

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature for Check-ApiReviewStatus has been changed to remove the $apiKey parameter, but there is still a caller in eng/common/scripts/Prepare-Release.ps1 (line 187) that passes the -apiKey parameter. This will cause a breaking change and runtime errors when Prepare-Release.ps1 is executed.

The Prepare-Release.ps1 script at line 187 calls:

Check-ApiReviewStatus -PackageName $fullPackageNameInApiView -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey

This needs to be updated to remove the -apiKey $apiKey parameter to match the new function signature. Additionally, lines 184-185 that retrieve the API key from KeyVault should be removed since they are no longer needed.

Suggested change
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiApprovalStatus = $null, $packageNameStatus = $null)
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiApprovalStatus = $null, $packageNameStatus = $null, $apiKey = $null)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this breaking change. This was one of the reasons all changes have been reverted in commit 8beda25. The eng/common directory should not be modified in this repository as it's synced from azure-sdk-tools.

{
# Get API view URL and API Key to check status
# Get API view URL and Bearer token to check status
Write-Host "Checking API review status for package: ${packageName}"
$lang = MapLanguageToRequestParam -language $language
if ($lang -eq $null) {
return
}
$headers = @{ "ApiKey" = $apiKey }

# Get Bearer token for authentication
$bearerToken = Get-ApiViewBearerToken
if (-not $bearerToken) {
Write-Error "Failed to acquire Bearer token for APIView authentication."
return
}

$headers = @{
"Authorization" = "Bearer $bearerToken"
}

if (!$apiApprovalStatus) {
$apiApprovalStatus = [PSCustomObject]@{
Expand Down
4 changes: 1 addition & 3 deletions eng/common/scripts/Validate-All-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Param (
[string]$ArtifactPath,
[Parameter(Mandatory=$True)]
[string]$RepoRoot,
[Parameter(Mandatory=$True)]
[string]$APIKey,
[string]$ConfigFileDir,
[string]$BuildDefinition,
[string]$PipelineUrl,
Expand Down Expand Up @@ -83,7 +81,7 @@ function VerifyAPIReview($packageName, $packageVersion, $language)
Details = ""
}
Write-Host "Checking API review status for package $packageName with version $packageVersion. language [$language]."
Check-ApiReviewStatus $packageName $packageVersion $language $APIViewUri $APIKey $apiStatus $packageNameStatus
Check-ApiReviewStatus $packageName $packageVersion $language $APIViewUri $apiStatus $packageNameStatus

Write-Host "API review approval details: $($apiStatus.Details)"
Write-Host "Package name approval details: $($packageNameStatus.Details)"
Expand Down
4 changes: 1 addition & 3 deletions eng/common/scripts/Validate-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ param (
[Parameter(Mandatory=$True)]
[string] $RepoRoot,
[Parameter(Mandatory=$True)]
[string] $APIKey,
[Parameter(Mandatory=$True)]
[string] $ConfigFileDir,
[string] $BuildDefinition,
[string] $PipelineUrl,
Expand Down Expand Up @@ -95,7 +93,7 @@ function VerifyAPIReview($packageName, $packageVersion, $language)
Details = ""
}
Write-Host "Checking API review status for package $packageName with version $packageVersion. language [$language]."
Check-ApiReviewStatus $packageName $packageVersion $language $APIViewUri $APIKey $apiStatus $packageNameStatus
Check-ApiReviewStatus $packageName $packageVersion $language $APIViewUri $apiStatus $packageNameStatus

Write-Host "API review approval details: $($apiStatus.Details)"
Write-Host "Package name approval details: $($packageNameStatus.Details)"
Expand Down
Loading