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] Unable to override the x-functions-key in the backend resources #429

Closed
laksharun opened this issue Dec 2, 2023 · 6 comments · Fixed by #430
Closed

[BUG] Unable to override the x-functions-key in the backend resources #429

laksharun opened this issue Dec 2, 2023 · 6 comments · Fixed by #430
Labels
bug Something isn't working

Comments

@laksharun
Copy link

laksharun commented Dec 2, 2023

Release version

v4.11.0

Describe the bug

I am not sure what I am missing but we are unable to override the x-functions-key value in the backend resource. After extracting the APIM data, we can the initial x-functions-key value in the backendInformation.json file of the backend resource as shown below.

{
  "properties": {
    "credentials": {
      "header": {
        "x-functions-key": [
          "test"
        ]
      },
      "query": {}
    },
    "description": "test",
    "protocol": "http",
    "resourceId": "https://management.azure.com/subscriptions/subid/resourceGroups/rgname/providers/Microsoft.Web/sites/testsite",
    "tls": {
      "validateCertificateChain": true,
      "validateCertificateName": true
    },
    "url": "https://testsite.azurewebsites.net/v1"
  }
}

Then we override the value for the x-functions-key in the configuration.stg.yaml file like below.

backends:
  - name: test
    properties:      
      credentials:
        header:
          x-functions-key: 
            - "{{stagesite-key}}"
      resourceId: "https://management.azure.com/subscriptions/subid/resourceGroups/rgname/providers/Microsoft.Web/sites/stagesite"
      url: "https://stagesite.azurewebsites.net/v1"

stagesite-key is added as a named value in the configuration.stg.yaml file like below.

namedValues:
  - name: stagesite-key
    properties:
      displayName: stagesite-key
      value: "{#STAGESITE_KEY#}"

Expected behavior

The initial value for the x-functions-key, that is test must be replaced with the named value {{stagesite-key}} in the backend resource.

Actual behavior

The new value is added along with the old value instead of replacing it.

image

Reproduction Steps

  • Add a value to the x-functions-key header in the Authorization credentials section of the backend configuration in APIM.
  • Run the extractor workflow to extract the APIM properties.
  • Override the value for x-functions-key header in the configuration.[env].yaml and run the publisher workflow.
Copy link

github-actions bot commented Dec 2, 2023

  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.

@laksharun
Copy link
Author

I wonder if it is because the initial value is a text and we are trying to override it with a named value?

@waelkdouh waelkdouh added the question Further information is requested label Dec 2, 2023
@guythetechie guythetechie linked a pull request Dec 4, 2023 that will close this issue
@guythetechie
Copy link
Contributor

The current behavior combines array objects. If you have key: [1] in your artifacts and key: [2] in your configuration override, key: [1, 2] will be passed to the REST API.

I think the better behavior for overrides should be a replacement. Creating a PR to address this, but this might be a breaking change for those who've relied on the default union behavior.

@waelkdouh
Copy link
Contributor

@laksharun please get release 5.0.0 and let us know if this addresses your issue.

@guythetechie
Copy link
Contributor

guythetechie commented Dec 4, 2023

@laksharun - one other thing; I don't know if you can override the x-functions-key property with a named value. If that doesn't work, try this instead:

backends:
  - name: test
    properties:      
      credentials:
        header:
          x-functions-key: 
            - "{#STAGESITE_KEY#}"

STAGESITE_KEY will come from a variable in your CI/CD pipeline. The pipeline will replace that value in the configuration file before passing it to the publisher.

@laksharun
Copy link
Author

@guythetechie @waelkdouh Thanks for the fix! It works now. I am able to override the x-functions-key property with a named value.

@waelkdouh waelkdouh added bug Something isn't working and removed question Further information is requested labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants