Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a54cf0e

Browse files
Merge pull request #29 from raksit31667/azure-publish-api-definitions
Publish API definitions to Azure APIM via OpenAPI Swagger URL
2 parents 46a8fc9 + be5ffff commit a54cf0e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<#
2+
.SYNOPSIS
3+
Script to publish API definitions to Azure APIM via OpenAPI Swagger URL.
4+
.DESCRIPTION
5+
Script to publish API definitions to Azure APIM via OpenAPI Swagger URL, with a healthcheck endpoint for liveness check.
6+
7+
The script works for those who are using Swagger as a API documentation (see more https://swagger.io/)
8+
9+
Please ensure that this script will run after web server has been updated accordingly.
10+
11+
Please ensure that web server SSL certificate is trusted.
12+
13+
.PARAMETER ApiId
14+
Specify the ID of the API to publish.
15+
16+
.PARAMETER ApiPath
17+
Specify a web API path as the last part of the API's public URL.
18+
19+
.PARAMETER SwaggerUrl
20+
Specify the Swagger OpenAPI JSON or YAML file (e.g. https://example.com/v2/api-docs)
21+
22+
.PARAMETER ResourceGroup
23+
Specify the Resource Group of desired APIM.
24+
25+
.PARAMETER ApimServiceName
26+
Specify APIM name.
27+
28+
.EXAMPLE
29+
/AZURE-APIM-Publish_API_Definitions_Swagger.ps1 -ResourceGroup "MyRG" -ApiId "MyApp" -ApiPath "swagger" -SwaggerUrl "https://example.com/v2/api-docs" -ApimServiceName "MyApim"
30+
31+
.NOTES
32+
33+
VERSION HISTORY
34+
1.0 | 2020/10/113 | Raksit Mantanacharu (raksit.m@ku.th)
35+
initial version
36+
#>
37+
[cmdletBinding()]
38+
Param(
39+
[Parameter(Mandatory = $true)]
40+
[string] $ApiId,
41+
[Parameter(Mandatory = $true)]
42+
[string] $ApiPath,
43+
[Parameter(Mandatory = $true)]
44+
[string] $SwaggerUrl,
45+
[Parameter(Mandatory = $true)]
46+
[string] $ResourceGroup,
47+
[Parameter(Mandatory = $true)]
48+
[string] $ApimServiceName,
49+
)
50+
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $ResourceGroup -ServiceName $ApimServiceName
51+
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "Swagger" -SpecificationUrl $SwaggerUrl -Path $ApiPath -ApiId $ApiId
52+
53+
New-AzApiManagementOperation -Context $ApiMgmtContext -ApiId $ApiId -OperationId "getHealthUsingGET" -Name "health probe" -Method "GET" -UrlTemplate "/healthz/liveness" -Description "Use this operation to get liveness status"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /