使用下面的 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 如下所示。
您可以引用此文档以获取有关这些 powershell cmdlet for APIM 的更多信息
关于azure - PowerShell 获取 Azure API 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74124928/