Skip to content

Commit

Permalink
Fix check on spec if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalvanderheiden committed Apr 26, 2024
1 parent 211724e commit 4e7837a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/azure-apim-discovery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ if (!$azdenv.APIM_RESOURCE_ID) {
else
{
Write-Host "API Management found, checking if APIs need to be imported..."
$api = az apic api list -g $azdenv.RESOURCE_GROUP_NAME -s $azdenv.APIC_SERVICE_NAME --output json | ConvertFrom-Json
$matchingApi = $api | Where-Object { $_.name -eq $azdenv.APIM_SAP_API_NAME }
if (!$matchingApi) {
Write-Host "API not found, importing..."
# AZ CLI METHOD to import all APIs from APIM
# $allApis = "$($azdenv.APIM_RESOURCE_ID)/apis/*"
# az apic service import-from-apim -g $azdenv.RESOURCE_GROUP_NAME -s $azdenv.APIC_SERVICE_NAME --source-resource-ids $allApis
# Write-Host "Importing APIs from Azure API Management completed"
# AZ CLI METHOD to import all APIs from APIM
# $allApis = "$($azdenv.APIM_RESOURCE_ID)/apis/*"
# az apic service import-from-apim -g $azdenv.RESOURCE_GROUP_NAME -s $azdenv.APIC_SERVICE_NAME --source-resource-ids $allApis
# Write-Host "Importing APIs from Azure API Management completed"

$apiDef = az apic api definition list -g $azdenv.RESOURCE_GROUP_NAME -s $azdenv.APIC_SERVICE_NAME --api-name $azdenv.APIM_SAP_API_NAME --version $azdenv.APIM_SAP_VERSION_NAME --output json | ConvertFrom-Json
$matchingApi = $apiDef | Where-Object { $_.value -eq null }
if (!$matchingApi) {
Write-Host "OpenAPI Specification not found, importing..."
# SMAPI METHOD to import only the SAP API Sepc, as the rest is created via Bicep
# Obtain an access token
$accessToken = az account get-access-token --query accessToken -o tsv
Expand Down

0 comments on commit 4e7837a

Please sign in to comment.