Reputation: 595
Looking for a command or set of commands that can associate an Operation and its corresponding tags of a API version in Azure APIM
Upvotes: 0
Views: 42
Reputation: 8018
PowerShell Azure command to get the Tags associated with an Operation for an API version in Azure API Management:
To achieve your requirement, you can use below script executed successfully with the help of Az PowerShell commands Get-AzApiManagementApi
and Get-AzResource
as shown below.
Also, you can refer SO by @Joy Wang for the relevant information.
Firstly, set the context of APIM to retrieve Api operation details using New-AzApiManagementContext
command.
$ResourceGroup = "Jahnavi"
$APIM = "newapimjah"
$Context = New-AzApiManagementContext -ResourceGroupName $ResourceGroup -ServiceName $APIM
$Apis_info = Get-AzApiManagementApi -Context $Context
Once it's done, use below foreach
loop to iterate through the Api's under API management service and retrieve the tags as shown below.
foreach($Api in $Apis_info){
$Id = $Api.ApiId
$Name = $Api.Name
$tags = (Get-AzResource -ResourceGroupName $ResourceGroup -ResourceType Microsoft.ApiManagement/service/apis/tags -ResourceName "$APIM/$Id" -ApiVersion 2018-01-01).Name
Write-Host "API Id of each API:" $Id
Write-Host "Tags from each" $Name : $tags
}
Upvotes: 1