【问题标题】:Getting tags associated with an API in Azure API Management在 Azure API 管理中获取与 API 关联的标签
【发布时间】:2019-11-15 20:44:01
【问题描述】:

有没有办法通过 Powershell 获取与 API 关联的标签?

Get-AzApiManagementApi 命令返回 API 列表,但其响应中不包含标签。

【问题讨论】:

标签: 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
}

【讨论】:

    【解决方案2】:

    从 Powershell 试试这个。您也可以从资源浏览器中获取此信息。

    Get-AzureRmResource -ResourceGroupName Integration-Resources -ResourceType Microsoft.ApiManagement/service/tags -ResourceName "integration-common/test" -ApiVersion 2018-01-01

    通过使用Rest API,你可以得到它 Tag - Get By Api https://docs.microsoft.com/en-us/rest/api/apimanagement/2019-01-01/tag/getbyapi

    您也可以关注此 GitHub 问题以供参考。 https://github.com/MicrosoftDocs/azure-docs/issues/21817

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 2020-03-21
      相关资源
      最近更新 更多