没有内置的 Azure Powershell/CLI 命令来执行此操作,在这种情况下,您可以直接使用 powershell
Apis - Create Or Update
或 CLI Invoke-AzRestMethod
直接调用 REST API - az rest
。
Powershell示例:
$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
门户查看:
上面的场景有什么解决方案吗?