azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Import-AzureApiManagementApi -Path parameter mandatory?

Open qxx opened this issue 3 years ago • 5 comments

Description

Documentation (https://docs.microsoft.com/en-us/powershell/module/az.apimanagement/import-azapimanagementapi?view=azps-7.5.0) suggests -Path is not required, while running the command without -Path, it gives an error. I have a workaround but this should be addressed either in the code or in the documentation. Similar to https://github.com/Azure/azure-powershell/issues/6965.

Workaround: pass an empty path -Path ""

Issue script & Debug output

PS> Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -SpecificationFormat Swagger -SpecificationPath $specificationPath
DEBUG: 7:07:16 PM - ImportAzureApiManagementApi begin processing with ParameterSet 'ImportFromLocalFile'.
DEBUG: 7:07:16 PM - using account id 'xxxxxxxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxxxxxxx', environment: 'AzureCloud', tenant: 'xxxxxxxx'
......
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'xxxxxxxx', UserId: 'xxxxxxxx'
Import-AzApiManagementApi: 'Path' cannot be null.
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:2.3.2; CommandName: Import-AzApiManagementApi; PSVersion: 7.1.4; IsSuccess: False; Duration: 00:00:00.0670476; Exception: 'Path' cannot be null.;
DEBUG: Finish sending metric.
DEBUG: 7:07:17 PM - ImportAzureApiManagementApi end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.7.6                 Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script     2.3.2                 Az.ApiManagement                    {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagementProductToGroup, Add-AzApiManagementRegion…}

Error output

Message        : 'Path' cannot be null.
StackTrace     :    at Microsoft.Azure.Management.ApiManagement.Models.ApiCreateOrUpdateParameter.Validate()
                    at Microsoft.Azure.Management.ApiManagement.ApiOperations.BeginCreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch, Dictionary`2 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperations.CreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String serviceName, String apiId, ApiCreateOrUpdateParameter
                 parameters, String ifMatch, Dictionary`2 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperationsExtensions.CreateOrUpdateAsync(IApiOperations operations, String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperationsExtensions.CreateOrUpdate(IApiOperations operations, String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch)
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.ApiManagementClient.ApiImportFromFile(PsApiManagementContext context, String apiId, PsApiManagementApiFormat
                 specificationFormat, String specificationPath, String apiPath, String wsdlServiceName, String wsdlEndpointName, Nullable`1 apiType, PsApiManagementSchema[] protocols, String serviceUrl,
                 String apiVersionSetId, String apiVersion)
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.ImportAzureApiManagementApi.ExecuteApiManagementCmdlet()
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.AzureApiManagementCmdletBase.ExecuteCmdlet()
Exception      : Microsoft.Rest.ValidationException
InvocationInfo : {Import-AzApiManagementApi}
Line           : Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -SpecificationFormat Swagger -SpecificationPath $specificationPath
Position       : At line:1 char:1
                 + Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -Specif …

qxx avatar Apr 26 '22 23:04 qxx

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Apr 27 '22 08:04 ghost

@qxx We are looking into it and get back to you for any additional information.

SaurabhSharma-MSFT avatar Apr 27 '22 18:04 SaurabhSharma-MSFT

Hello @qxx Thanks for reaching out on this issue! We are routing this to Service Teams Attention!

SatishBoddu-MSFT avatar May 02 '22 20:05 SatishBoddu-MSFT

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @adrianhall, @KedarJoshi.

Issue Details

Description

Documentation (https://docs.microsoft.com/en-us/powershell/module/az.apimanagement/import-azapimanagementapi?view=azps-7.5.0) suggests -Path is not required, while running the command without -Path, it gives an error. I have a workaround but this should be addressed either in the code or in the documentation. Similar to https://github.com/Azure/azure-powershell/issues/6965.

Workaround: pass an empty path -Path ""

Issue script & Debug output

PS> Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -SpecificationFormat Swagger -SpecificationPath $specificationPath
DEBUG: 7:07:16 PM - ImportAzureApiManagementApi begin processing with ParameterSet 'ImportFromLocalFile'.
DEBUG: 7:07:16 PM - using account id 'xxxxxxxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxxxxxxx', environment: 'AzureCloud', tenant: 'xxxxxxxx'
......
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'xxxxxxxx', UserId: 'xxxxxxxx'
Import-AzApiManagementApi: 'Path' cannot be null.
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:2.3.2; CommandName: Import-AzApiManagementApi; PSVersion: 7.1.4; IsSuccess: False; Duration: 00:00:00.0670476; Exception: 'Path' cannot be null.;
DEBUG: Finish sending metric.
DEBUG: 7:07:17 PM - ImportAzureApiManagementApi end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.7.6                 Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script     2.3.2                 Az.ApiManagement                    {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagementProductToGroup, Add-AzApiManagementRegion…}

Error output

Message        : 'Path' cannot be null.
StackTrace     :    at Microsoft.Azure.Management.ApiManagement.Models.ApiCreateOrUpdateParameter.Validate()
                    at Microsoft.Azure.Management.ApiManagement.ApiOperations.BeginCreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch, Dictionary`2 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperations.CreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String serviceName, String apiId, ApiCreateOrUpdateParameter
                 parameters, String ifMatch, Dictionary`2 customHeaders, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperationsExtensions.CreateOrUpdateAsync(IApiOperations operations, String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch, CancellationToken cancellationToken)
                    at Microsoft.Azure.Management.ApiManagement.ApiOperationsExtensions.CreateOrUpdate(IApiOperations operations, String resourceGroupName, String serviceName, String apiId,
                 ApiCreateOrUpdateParameter parameters, String ifMatch)
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.ApiManagementClient.ApiImportFromFile(PsApiManagementContext context, String apiId, PsApiManagementApiFormat
                 specificationFormat, String specificationPath, String apiPath, String wsdlServiceName, String wsdlEndpointName, Nullable`1 apiType, PsApiManagementSchema[] protocols, String serviceUrl,
                 String apiVersionSetId, String apiVersion)
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.ImportAzureApiManagementApi.ExecuteApiManagementCmdlet()
                    at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.AzureApiManagementCmdletBase.ExecuteCmdlet()
Exception      : Microsoft.Rest.ValidationException
InvocationInfo : {Import-AzApiManagementApi}
Line           : Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -SpecificationFormat Swagger -SpecificationPath $specificationPath
Position       : At line:1 char:1
                 + Import-AzApiManagementApi -Context $apimContext -ApiId $apiId -Specif …
Author: qxx
Assignees: -
Labels:

API Management, Service Attention, bug, customer-reported

Milestone: -

ghost avatar May 02 '22 20:05 ghost

Any updates on this?

TimSchSkaylink avatar Aug 30 '22 09:08 TimSchSkaylink

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Jan 05 '23 02:01 ghost