我正在尝试使用Azure CLI使用新规范更新Azure API管理服务内部版本集中的现有版本。
我知道它确实支持在没有版本集的情况下将其作为API导入:
az apim api import `
--path "/as" `
--resource-group "myResourceGroup" `
--service-name "test-apim" `
--api-id "test-apim" `
--specification-format "OpenApiJson" `
--specification-path "..swagger.json"
我也知道你可以使用Azure Powershell模块来获取一个版本集,并使用它上传一个新的规范:
$apiMgmtContext = New-AzApiManagementContext `
-ResourceGroupName "myResourceGroup" `
-ServiceName "test-apim"
$versionSet = Get-AzApiManagementApiVersionSet -Context $apiMgmtContext |
Where-Object { $_.DisplayName -eq "my-version-set" } |
Sort-Object -Property ApiVersionSetId -Descending |
Select-Object -first 1
Import-AzApiManagementApi `
-Context $apiMgmtContext `
-ApiVersionSetId $versionSet.ApiVersionSetId `
-ServiceUrl "http" `
-SpecificationFormat "OpenApiJson" `
-SpecificationPath "..swagger.json" `
-Path "/as" `
-ApiId "test-apim"
但是,有人知道在powershell模块最终会过时的情况下,az-cli是否可以做到这一点吗?
查看文档,它支持版本集。
您需要使用参数--api-version-set-id
:
az apim api import `
--path "/as" `
--resource-group "myResourceGroup" `
--service-name "test-apim" `
--api-id "test-apim" `
--specification-format "OpenApiJson" `
--specification-path "..swagger.json" `
--api-version-set-id "my-version-set-id"
此外,目前还没有迹象表明Az Powershell会过时。