Reputation: 1153
Using the PowerShell below, How can I create the report in a .CSV format for all APIs under my Azure Tenant ?
I tried using the below, as a Global Admin account, but it still failed.
Get-AzApiManagement
$Context = Get-AzContext
Get-AzApiManagementBackend -Context $Context
Get-AzApiManagementProduct -Context $Context
Get-AzApiManagementPolicy -Context $Context
Error:
Get-AzApiManagementBackend : Cannot bind parameter 'Context'. Cannot convert the "Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" value of type
"Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" to type "Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementContext".
At line:3 char:37
+ Get-AzApiManagementBackend -Context $Context
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzApiManagementBackend], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.GetAzureApiManagementBackend
Get-AzApiManagementProduct : Cannot bind parameter 'Context'. Cannot convert the "Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" value of type
"Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" to type "Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementContext".
At line:4 char:37
+ Get-AzApiManagementProduct -Context $Context
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzApiManagementProduct], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.GetAzureApiManagementProduct
Get-AzApiManagementPolicy : Cannot bind parameter 'Context'. Cannot convert the "Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" value of type
"Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext" to type "Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementContext".
At line:5 char:36
+ Get-AzApiManagementPolicy -Context $Context
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzApiManagementPolicy], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.GetAzureApiManagementPolicy
Upvotes: 1
Views: 492
Reputation: 17363
Example commands as text, for easy copy&paste:
$rgName = "resource group name"
$apimName = "APIM instance name"
$apimContext = New-AzApiManagementContext -ResourceGroupName $rgName -ServiceName $apimName
Get-AzApiManagementUser -Context $apimContext
Upvotes: 1
Reputation: 5546
-context
parameter accepts Instance of PsApiManagementContext.
You need to create the ApiManagementcontext using the New-AzApiManagementContext
cmdlet and then pass the Context to the -context
parameter to Get-AzApiManagementBackend
cmdlet as shown below.
You can refer to this documentation for more information about these powershell cmdlet for APIM
Upvotes: 3