Azure / apiops

APIOps applies the concepts of GitOps and DevOps to API deployment. By using practices from these two methodologies, APIOps can enable everyone involved in the lifecycle of API design, development, and deployment with self-service and automated tools to ensure the quality of the specifications and APIs that they’re building.
https://azure.github.io/apiops
MIT License
321 stars 187 forks source link

[BUG] Error "Not valid api-version" while publishing named values #484

Closed marcovanluyk closed 8 months ago

marcovanluyk commented 8 months ago

Release version

APIOPS 5.1.1

Describe the bug

During the publishing process (Publishing to UAT environment) of named values we got the following exception:

System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/providers/Microsoft.ApiManagement/service/namedValues/xxxxxxx?api-version=2022-04-01-preview failed with status code 400. Content is '{"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2022-04-01-preview' is invalid.

I edited the publisher files and used the ARM_API_VERSION parameter but it didn't work.

Expected behavior

Pipeline will publish the artifacts.

Actual behavior

Error.

Reproduction Steps

Run Pipeline based on publisher.yaml file.

github-actions[bot] commented 8 months ago
  Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
  Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.
guythetechie commented 8 months ago

I'm not able to reproduce this. Your URL looks off; you have https://management.azure.com/subscriptions/***/resourceGroups/providers/Microsoft.ApiManagement/service/namedValues/xxxxxxx?api-version=2022-04-01-preview, but it's missing a service name. Should be Microsoft.ApiManagement/service/yourapiminstancename/namedValues/xxxxxxx?api-version=2022-04-01-preview.

Can you make sure you've set the APIM instance name correctly for that environment? Should be coming from apimServiceName or API_MANAGEMENT_SERVICE_NAME in configuration.

marcovanluyk commented 8 months ago

Thanks for your fast reply. I checked it again and now I get the same error withe the APIM instance:

https://management.azure.com/subscriptions/***/resourceGroups/providers/Microsoft.ApiManagement/service/xxxxxxxapis-uat-xxx/namedValues/xxxxdata-url?api-version=2022-04-01-preview failed with status code 400. Content is '{"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2022-04-01-preview' is invalid.

I have really no idea what is going wrong....! :-(

guythetechie commented 8 months ago

You're also missing a resource group name in your URL. Should look like this:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}?api-version={api-version}.

The subscription, resource group, and service name all come from environment variables you've configured in your pipeline.

marcovanluyk commented 8 months ago

Yeah, I think the main issue is solved. But now I got an error with the logge (app insights):

I have one subscription with 3 ressource groups: 1 RG for dev 1 RG for uat 1 RG for monitoring (logger) --> dev/uat should use the same instance

System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/API-Management-uat-rg/providers/Microsoft.ApiManagement/service/xxxapis-uat-apim/loggers/xxxapis-appi?api-version=2022-04-01-preview failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"One or more Properties ['{0}'] specified are missing.","message":"Logger-Credentials--65d6107b46346125c8xxxxxx"}]}}'. at common.HttpPipelineExtensions.Validate(Response response, Uri requestUri)

How can I handle this conflict?

waelkdouh commented 8 months ago

It means you are not overriding the logger details correctly. Please search closed issues that have addressed this same topic in the past.

marcovanluyk commented 8 months ago

OK-I will search for it thanks....

waelkdouh commented 8 months ago

Welcome. Please close the issue when you get a chance.

marcovanluyk commented 8 months ago

It is working!