Regarding environment

Is there a configuration file where we can input actual backend service URI(eg:

env.dev1.yahooweather=http://weather.yahooapis.com)

& while creating proxy we provide the variable name ${env.dev1.yahooweather} instead of URI?

This way we can always change the backend uri from one env to other env.

&

What are the key configuration files on the server ?

-Vinay

Solved Solved
0 4 498
1 ACCEPTED SOLUTION

Dear @vinay poreddy ,

Apigee supports the concept of Target Servers -which abstracts the backend host from the proxies and also provides load balancing. Same target servers can be configured to point to different host for each environment.

To create a TargetServer in an environment :

$ curl -H "Content-Type:text/xml"-X POST -d \
'<TargetServer name="target1">
   <Host>1.mybackendservice.com</Host>
   <Port>80</Port>
   <IsEnabled>true</IsEnabled>
 </TargetServer>' \
-u myname:mypass https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/targetservers

Cheers,

Anil Sagar

View solution in original post

4 REPLIES 4

Dear @vinay poreddy ,

Apigee supports the concept of Target Servers -which abstracts the backend host from the proxies and also provides load balancing. Same target servers can be configured to point to different host for each environment.

To create a TargetServer in an environment :

$ curl -H "Content-Type:text/xml"-X POST -d \
'<TargetServer name="target1">
   <Host>1.mybackendservice.com</Host>
   <Port>80</Port>
   <IsEnabled>true</IsEnabled>
 </TargetServer>' \
-u myname:mypass https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/targetservers

Cheers,

Anil Sagar

I agree that TargetServers are generally the way to go. After you've created a target server, use this to configure your TargetEndpoint in your proxy.

Former Community Member
Not applicable

Hi @vinay poreddy another option is to specify multiple target endpoints and use route rules to route to the right target endpoint based on the current environment you are deployed in.

For eg: you can use the environment.name variable as the conditional element in your route rule:

<RouteRule name="TestEnvRoute">
  <Condition>environment.name = "test"</Condition>
  <TargetEndpoint>TestTargetEndpoint1</TargetEndpoint>
</RouteRule>

<RouteRule name="DevEnvRoute">
  <Condition>environment.name = "dev"</Condition>
  <TargetEndpoint>DevTargetEndpoint1</TargetEndpoint>
</RouteRule>


<RouteRule name="default">
 <TargetEndpoint>TargetEndpoint2</TargetEndpoint>
</RouteRule>

@vinay poreddy Use named target servers for that. TargetServer configurations decouple concrete endpoint URLs from TargetEndpoint configurations. You define a target server per environment, along with information like host, port, with an additional element to indicate whether the TargetServer is enabled or disabled. So when you move your API from one environment to the other, the target end point it connects to changes automatically. More details on Target Servers here.