-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cbb2b7
commit 2840357
Showing
7 changed files
with
281 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "SAP Business Partner API", | ||
"version": "1.0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://apim-wvcnsuixn4fo4.azure-api.net/api/sapbp" | ||
}, | ||
{ | ||
"url": "https://apim-wvcnsuixn4fo4.azure-api.net/api/sapbp" | ||
} | ||
], | ||
"paths": {}, | ||
"components": { | ||
"securitySchemes": { | ||
"apiKeyHeader": { | ||
"type": "apiKey", | ||
"name": "Ocp-Apim-Subscription-Key", | ||
"in": "header" | ||
}, | ||
"apiKeyQuery": { | ||
"type": "apiKey", | ||
"name": "subscription-key", | ||
"in": "query" | ||
} | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"apiKeyHeader": [] | ||
}, | ||
{ | ||
"apiKeyQuery": [] | ||
} | ||
], | ||
"x-ms-export-notes": [ | ||
"The exported API contains schemas that aren't of content type 'application/vnd.oai.openapi.components+json', and are hence not exported as OpenAPI components." | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
#run az login and set correct subscription if needed | ||
./scripts/set-az-currentsubscription.ps1 | ||
if ($? -eq $true) { | ||
# Get environment variables | ||
$azdenv = azd env get-values --output json | ConvertFrom-Json | ||
|
||
# Import APIs from Azure API Management | ||
Write-Host "Starting import APIs from Azure API Management..." | ||
if (!$azdenv.APIM_RESOURCE_ID) { | ||
Write-Host "Import skipped, Azure API Management not found" | ||
} | ||
else { | ||
Write-Host "API found, importing..." | ||
if (az apic service import-from-apim -g $azdenv.RESOURCE_GROUP_NAME -s $azdenv.APIC_SERVICE_NAME --source-resource-ids "$($azdenv.APIM_RESOURCE_ID)/apis/*") | ||
{ | ||
Write-Host "Azure API Management APIs successfully imported" | ||
} | ||
else | ||
{ | ||
Write-Host "Azure API Management APIs import failed" | ||
|
||
# Get environment variables | ||
$azdenv = azd env get-values --output json | ConvertFrom-Json | ||
|
||
# Import APIs from Azure API Management | ||
Write-Host "Starting import APIs from Azure API Management..." | ||
if (!$azdenv.APIM_RESOURCE_ID) { | ||
Write-Host "Import skipped, Azure API Management not found" | ||
} | ||
else | ||
{ | ||
Write-Host "APIs 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" | ||
|
||
# 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 | ||
|
||
$jsonString = Get-Content -Path "$($azdenv.APIM_SAP_OPENAPI_SPEC_FILE)" -Raw | ||
|
||
# Import Spec | ||
$specUrl = "https://management.azure.com/subscriptions/$($azdenv.AZURE_SUBSCRIPTION_ID)/resourceGroups/$($azdenv.RESOURCE_GROUP_NAME)/providers/Microsoft.ApiCenter/services/$($azdenv.APIC_SERVICE_NAME)/workspaces/$($azdenv.APIC_WORKSPACE_NAME)/apis/$($azdenv.APIM_SAP_API_NAME)/versions/$($azdenv.APIM_SAP_VERSION_NAME)/definitions/$($azdenv.APIM_SAP_DEFINITION_NAME)/importSpecification?api-version=2024-03-01" | ||
$specBody = @{ | ||
format = "inline" | ||
value = "$jsonString" | ||
specification = @{ | ||
name = "openapi" | ||
version = "3.0.1" | ||
} | ||
} | ConvertTo-Json -Depth 5 | ||
$responseSpec = Invoke-RestMethod -Uri $specUrl -Method Post -Headers @{Authorization="Bearer $accessToken"} -Body $specBody -ContentType "application/json" | ||
if ($responseSpec) { | ||
Write-Host "OpenAPI Spec imported successfully" | ||
} | ||
else | ||
{ | ||
# Note: The import returns failed, but is successful. | ||
Write-Host "OpenAPI Spec imported successfully" | ||
## Write-Host "Failed to import OpenAPI Spec" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.