Search code examples
ibm-cloudcloud-foundry

CF update env variable


I'm having application that pushed to CF which is working fine.

when I do cf env appName I got the section User-Provided:

in this section I see several of objects with values and I want to update new value to existing object, how I should do this ?

e.g.

when I use cf env

System-Provided:
....


User-Provided:

    SERVICES: []
    annotations: [
      {
        "name": "Book",
        "url": "https://stackoverflow.com"
      }
    ]

And what I want is to change the URL value inside the annotations ... I try with CF set-env but it create additional filed, I want to update existing field with the command line without the need to restart my app.


Solution

  • As you already pointed out, variables can be set and updated using the cf set-env command. The problem is in your case is that one of the variables, annotations, is a complex JSON object.

    You would need to update annotations and provide the full, updated object:

    cf set-env yourapp annotations '[{"name": "book", "url": "updated URL"}]'