Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-AzureRmApiManagementApiToProduct give apiId pattern exception #6560

Closed
yongyangiQ opened this issue Jun 28, 2018 · 3 comments
Closed

Add-AzureRmApiManagementApiToProduct give apiId pattern exception #6560

yongyangiQ opened this issue Jun 28, 2018 · 3 comments
Assignees
Labels
API Management Service Attention This issue is responsible by Azure service team.

Comments

@yongyangiQ
Copy link

yongyangiQ commented Jun 28, 2018

Description

Can successful use Import-AzureRmApiManagementApi to import swagger file by use apiId like "alerts.v1".

but use Add-AzureRmApiManagementApiToProduct throw apiId not match pattern exception.

The Add-AzureRmApiManagementApiToProduct should keep use same apiId pattern as Import-AzureRmApiManagementApi.

Script/Steps for Reproduction

Use apiId like "alerts.v1" when execute Add-AzureRmApiManagementApiToProduct

Add-AzureRmApiManagementApiToProduct -Context $apiManagementContext -ProductId "unpublished" -ApiId 'alerts.v1'

Module Version

Get-Module -Name AzureRM -ListAvailable

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.3.0      AzureRM
Script     5.7.0      AzureRM

Environment Data

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.112
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.112
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Debug Output

PS C:\Users\xxxxx\source\setSwaggerOp\Azure.APIManagement> Add-AzureRmApiManagementApiToProduct -Context $apiManagementContexts -ProductId "unpublished" -ApiId alerts.v1
DEBUG: 4:20:34 PM - AddAzureApiManagementApiToProduct begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 4:20:34 PM - using account id 'xxxxxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxxxxxx', environment: 'AzureCloud', tenant: 'xxxxxx'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/28/2018 23:20:34: xxxxxxxxf - AcquireTokenHandlerBase: === Token Acquisition started:
 Authority: https://login.microsoftonline.com/xxxxx/
 Resource: https://management.core.windows.net/
 ClientId: xxxxxxx
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (1 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/28/2018 23:20:34:  - TokenCache: Deserialized 1 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/28/2018 23:20:34: xxxxxx - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/28/2018 23:20:34: xxxxxxx - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 06/28/2018 23:20:34: xxxxx - TokenCache: 25.6143573533333 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/28/2018 23:20:34: xxxxx - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 06/28/2018 23:20:34: xxxxx - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
 Access Token Hash: xxxxxx
 Refresh Token Hash: xxxxx
 Expiration Time: 06/28/2018 23:46:11 +00:00
 User Hash: xxxxx

Add-AzureRmApiManagementApiToProduct : 'apiId' does not match expected pattern '(^[\w]+$)|(^[\w][\w\-]+[\w]$)'.
At line:1 char:1
+ Add-AzureRmApiManagementApiToProduct -Context $apiManagementContexts  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureRmApiManagementApiToProduct], ValidationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.AddAzureApiManagementApiToProduct

DEBUG: AzureQoSEvent: CommandName - Add-AzureRmApiManagementApiToProduct; IsSuccess - False; Duration - 00:00:00.0608927; Exception - Microsoft.Rest.ValidationException: 'apiId' does not match expected
pattern '(^[\w]+$)|(^[\w][\w\-]+[\w]$)'.
   at Microsoft.Azure.Management.ApiManagement.ProductApiOperations.<CreateOrUpdateWithHttpMessagesAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ApiManagement.ProductApiOperationsExtensions.<CreateOrUpdateAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ApiManagement.ProductApiOperationsExtensions.CreateOrUpdate(IProductApiOperations operations, String resourceGroupName, String serviceName, String productId, String apiId)
   at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.ApiManagementClient.ApiAddToProduct(PsApiManagementContext context, String productId, String apiId)
   at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.AddAzureApiManagementApiToProduct.ExecuteApiManagementCmdlet()
   at Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.AzureApiManagementCmdletBase.ExecuteCmdlet();
DEBUG: Finish sending metric.
DEBUG: 4:20:35 PM - AddAzureApiManagementApiToProduct end processing.
DEBUG: 4:20:35 PM - AddAzureApiManagementApiToProduct end processing.
@cormacpayne
Copy link
Member

@solankisamir Hey Samir, would you mind taking a look at this issue?

@solankisamir
Copy link
Member

Working on the fix.

@solankisamir
Copy link
Member

This should be fixed in the release https://github.com/Azure/azure-powershell/releases/tag/v6.6.0-July2018. Can you please upgrade and see if you are unblocked.

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Management Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants