Asked
Active
Viewed 743 times
1
I have an Azure Functions instance added to an API Management API by using "Import from Azure Functions".
When I update my Azure Functions instance, the API Management API it's not automatically updated. I searched everywhere for a command able to reimport my Azure Function into my API Management API, but I can't find any solution/workaround.
That's what I want to automate:

johnykes
- 1,663
- 2
- 9
- 25
1 Answers
0
There is no built-in Azure Powershell/CLI command to do that, in this case, you could simply call the REST API - Apis - Create Or Update
directly with powershell Invoke-AzRestMethod
or CLI az rest
.
Powershell Sample:
$groupname = "xxxxxxx"
$APIMname = "joyapim"
$FullApiVersionName = "joyfunapim-v2"
$sourceApiName = "joyfunapim"
$apiVersion = "v2"
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $groupname -ServiceName $APIMname
$Api = Get-AzApiManagementApi -Context $ApiMgmtContext -ApiId $sourceApiName
$apiVersionSetId = (Get-AzApiManagementApiVersionSet -Context $ApiMgmtContext | Where-Object {$_.DisplayName -eq $sourceApiName}).ApiVersionSetId
$Apim = Get-AzApiManagement -ResourceGroupName $groupname -Name $APIMname
$path = $Apim.Id + "/apis/" + $ApiFullVersionName + ";rev=1?api-version=2019-12-01"
$payload = @{
"properties" = @{
"sourceApiId" = $Api.Id
"apiVersion" = $apiVersion
"apiVersionSetId" = "/apiVersionSets/"+ $apiVersionSetId
"apiVersionSet" = @{
"versioningScheme" = "Segment"
"name" = $sourceApiName
}
}
} | ConvertTo-Json -Depth 10
Invoke-AzRestMethod -Path $path -Method PUT -Payload $payload
Check in the portal:

Joy Wang
- 39,905
- 3
- 30
- 54
-
Nice script, but this does not solve my problem because I want to update the API Management APIs definition (new operations, methods, paths, etc) using my Azure Functions. I don't have a OpenAPI / Swagger file, but the manual import works perfect. – johnykes Apr 30 '21 at 13:06
-
@johnykes I have the same requirement as yours, do we know how to go about it? – Santhosh Aug 02 '21 at 12:09