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

[BUG] Error with publisher - unable to map provided backend with the API #550

Closed
kpemmasani opened this issue May 15, 2024 · 8 comments
Closed

Comments

@kpemmasani
Copy link

kpemmasani commented May 15, 2024

Release version

v6.0.0-alpha.1.0.2

Describe the bug

We are running into issues with set backend policy when publishing new APIs, we followed steps as per the documentation, but publisher keeps trying to create APIs before backend is created.

This works fine if we publish just the backend first as a separate commit and then publish APIs, it looks like a async issue on the order of artifacts created.

We tried various v6+ versions and we are running into same issue, this was working fine in v4.7.0, any guidance on this issue will be highly appreciated.

Expected behavior

Artifacts should be published without any issue when all the required files are provided.

Actual behavior

Publish fails even when we provide all the necessary files for creating new APIs.

Error Message:
##[error]Unhandled exception. System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/XXXXXXX/resourceGroups/rg-XXXX/providers/Microsoft.ApiManagement/service/apimdev/apis/appname/policies/policy?api-version=2022-08-01 failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"set-backend-service","message":"Error in element 'set-backend-service' on line 16, column 10: Backend with id 'appname-backend' could not be found."}]}}'.
at common.HttpPipelineExtensions.<>c__DisplayClass8_0.b__0(Response response)

Reproduction Steps

Adding APIs to our Repo

Step 1: Add Named Values
Step 2: Add Backend Configuration
mkdir artifacts/backends/{backend-name}
Create Backend Configuration File: Create a JSON file named backendInformation.json with the necessary backend settings.

backendInformation.json:

{
"properties": {
"credentials": {
"header": {},
"query": {}
},
"description": "API_BACKEND_DESCRIPTION",
"protocol": "http",
"tls": {
"validateCertificateChain": false,
"validateCertificateName": false
},
"url": "BACKEND_URL"
}
}
Note: The "set-backend-service" policy in API Management allows you to direct incoming API requests to a specified backend. For example:

[...] Step 3: Create a New API Folder with folder name Step 4: Add OpenAPI Specification in specification.json Step 5: Add API Information in apiInformation.json Step 6: Add Policy Configuration

Running the publisher with publish all

Error: Publisher fails with backend not found message.

Copy link

  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.

@kpemmasani kpemmasani changed the title [BUG] Error with set backend not found while publishing with valid backend folder [BUG] Error with publisher - unable to map provided backend with the API May 15, 2024
@waelkdouh
Copy link
Contributor

Please don't use the alpha version. It's broken. Use v5.x.

@Hackababa
Copy link

We encountered this issue in v 5.0.1, so we upgraded to 5.1.4, but the issue still presists.

@metu
Copy link

metu commented Jun 6, 2024

I was experiencing same issue on v6.0.0-alpha.1.0.4 (I saw the comment about not using alpha release). I never tried v5 but when switching to v6.0.0-alpha.1.0.4 I never experienced that issue. Not sure if it's just a case of the backends coincidentally completing before the API that needs it is created, or if the issue was actually fixed in the newer releases (never checked the release notes). There were about 4 backends that needed to still be created in my case.

UPDATE
Never mind, issue still present in v6.0.0-alpha.1.0.8

@EdiFirst
Copy link

EdiFirst commented Jun 7, 2024

Guys the tool are presenting lot bug, I also received this error, was necessary rename the backends folder inside backends to match the az functions name that I'm integrating with apim. Was necessary to create a script aside to do that and to create the backend json definition based on cong.prod.yaml ( that was needed to create manually , its terrible aproach).
I'm using the [v6.0.0-alpha.1.0.8, because when I tried to use other I receive the 404 from the Uri var, among others bugs.

@waelkdouh
Copy link
Contributor

We currently don't advice v6 yet. We are working on fixing some outstanding issues with v6 and plan on releasing some fixes soon.

This is an open source project so we are doing our best to address all the bugs as we go. But please feel free to create a PR if you come up with fixes.

Also please keep in mind that v6 is a major release so please wait on us to push the fixes for v6 before you start submitting any PRs.

@EdiFirst
Copy link

I couldn't to use other version, because I received the error 404 as I mentioned. I can't to crontribute right now, because my script is in powershell and your binaries make use of other language

@guythetechie
Copy link
Contributor

This issue should have been addressed in the latest v6 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants