azure - PowerShell 获取 Azure API 报告?

标签 azure powershell azure-powershell azure-api-management

使用下面的 PowerShell,如何为我的 Azure 租户下的所有 API 创建 .CSV 格式的报告?

我尝试使用以下帐户作为全局管理员帐户,但仍然失败。

Get-AzApiManagement

$Context = Get-AzContext

Get-AzApiManagementBackend -Context $Context
Get-AzApiManagementProduct -Context $Context
Get-AzApiManagementPolicy -Context $Context

错误:

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

最佳答案

-context 参数接受 PsApiManagementContext 的实例。

您需要使用 New-AzApiManagementContext cmdlet 创建 ApiManagementcontext,然后将上下文传递给 -context 参数,再传递给 Get-AzApiManagementBackend cmdlet 如下所示。

enter image description here

您可以引用此文档以获取有关这些 powershell cmdlet for APIM 的更多信息

关于azure - PowerShell 获取 Azure API 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74124928/

相关文章:

c# - Azure CDN 端点使用 https 提供 502 错误网关

Powershell - 添加到 $Error

powershell - 如何使用powershell为azure ad中的应用程序授予权限

Azure ARM 模板单元测试

powershell - Azure PowerShell DSC 安装额外模块

azure - Power BI 容量

azure - 如何通过 ARM 模板管理 Azure Api 管理 CA 证书

powershell - 我如何修改此 PowerShell 脚本以包括将目录名称更改为 lower?

azure-powershell - 如何清理坏的 Azure PowerShell 卸载?

c# - AppDelegate 已经定义了 FinishedLaunching