Skip to content

Commit a146e58

Browse files
committed
Update to use new developer portal publish api
1 parent 55a376d commit a146e58

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

Azure API Management Developer portal.code-workspace

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"path": "."
55
}
66
],
7-
"settings": {}
7+
"settings": {},
8+
"extensions": {
9+
"recommendations": [
10+
"ms-azuretools.vscode-apimanagement",
11+
"ms-vscode.powershell"
12+
]
13+
}
814
}

Import-APIMDeveloperPortal.ps1

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,17 @@ Get-ChildItem -File -Recurse $mediaFolder `
117117
}
118118

119119
"Publishing developer portal"
120-
# Ref: https://github.com/Azure/api-management-developer-portal/issues/953
121-
# Newer way to do it:
122-
# $revision = [DateTime]::UtcNow.ToString("yyyyMMddHHmm")
123-
# $data = @{
124-
# description = "Migration $revision"
125-
# isCurrent = $true
126-
# }
127-
# $body = ConvertTo-Json $data
128-
# Invoke-AzRestMethod -Path "$baseUri/portalRevisions/$($revision)?api-version=2019-12-01" -Method PUT -Payload $body
129-
130-
# Old way to do it:
131-
$resourceName = $APIMName + "/1"
132-
$parameters = @{
133-
"keyType" = "primary"
120+
$revision = [DateTime]::UtcNow.ToString("yyyyMMddHHmm")
121+
$data = @{
122+
description = "Migration $revision"
123+
isCurrent = $true
124+
properties = @{}
134125
}
135-
136-
$body = ConvertTo-Json $parameters
137-
$token = Invoke-AzResourceAction -ResourceGroupName $ResourceGroupName -ResourceType "Microsoft.ApiManagement/service/users" -Action "token" -ResourceName $resourceName -ApiVersion "2019-12-01" -Parameters $parameters -Force
138-
$headers = @{Authorization = ("SharedAccessSignature {0}" -f $token.value) }
139-
140-
$publishResponse = Invoke-RestMethod -Headers $headers -Uri "$developerPortalEndpoint/publish?api-version=2019-12-01" -Method POST
126+
$body = ConvertTo-Json $data
127+
$publishResponse = Invoke-AzRestMethod -Path "$baseUri/portalRevisions/$($revision)?api-version=2019-12-01" -Method PUT -Payload $body
141128
$publishResponse
142129

143-
if ("OK" -eq $publishResponse) {
130+
if (202 -eq $publishResponse.StatusCode) {
144131
"Import completed"
145132
return
146133
}

0 commit comments

Comments
 (0)