【问题标题】:Getting tags associated with an API in Azure API Management在 Azure API 管理中获取与 API 关联的标签
【发布时间】:2019-11-15 20:44:01
【问题描述】:
【问题讨论】:
标签:
azure
azure-powershell
azure-api-management
api-management
apim
【解决方案1】:
命令Get-AzApiManagementApi不会返回每个API的标签,解决方法是使用Get-AzResource。
试试下面的脚本,它会返回每个 API 的标签。
$ResourceGroupName = "<resource-group-name>"
$APImg = "<API-Management-service-name>"
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $APImg
$Apis = Get-AzApiManagementApi -Context $ApiMgmtContext
foreach($Api in $Apis){
$ApiId = $Api.ApiId
$ApiName = $Api.Name
$tags = (Get-AzResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.ApiManagement/service/apis/tags -ResourceName "$APImg/$ApiId" -ApiVersion 2018-01-01).Name
Write-Host "Tags of" $ApiName : $tags
}