In your .ebextensions/myoptions.config :
option_settings: - option_name: MyServiceUrl value: change me
This will add the "MyServiceUrl" parameter to the "EB Environment Properties" section (as you can already see). When deployed, this will add the following to your Web.Config file:
<appSettings> <add key="MyServiceUrl" value="change me" /> </appSettings>
If you use RDP in your EC2 instance, you will see this.
When you change a property using the EB console, this setting will be changed in your Web.Config file.
So, you get access to this property using the standard AppSettings method:
string value = ConfigurationManager.AppSettings["MyServiceUrl"];
Catch:
You need to make sure that your Web.Config file Web.Config not contain this parameter, otherwise EB will not replace it. If your Visual Studio deployment package includes this option, EB will not replace it, and you will always get the expanded value when accessing the property through your code.
Decision:
In the Web.Release.config file Web.Release.config remove the parameter during the deployment of Visual Studio:
<appSettings> <add key="MyServiceUrl" xdt:Transform="Remove" xdt:Locator="Match(key)" /> </appSettings>
This will remove the parameter from Web.Config during the deployment of Visual Studio and allow EB to add the value to the file during the deployment of EB.
Matt Houser Nov 01 '15 at 18:39 2015-11-01 18:39
source share